HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!-- <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script> -->
<div class="app-container">
<nav id="navbar">
<div class="nav-collapsible closed" id="nav-collapsible">
<header>
Logtweet Docs
</header>
<ul class="nav-link-list">
<li><a class="nav-link" onclick="closeNav()" href="#Introduction">Introduction</a></li>
<li><a class="nav-link" onclick="closeNav()" href="#Usage">Usage</a></li>
<li><a class="nav-link" onclick="closeNav()" href="#Options">Options</a></li>
<li><a class="nav-link" onclick="closeNav()" href="#Installation">Installation</a></li>
<li><a class="nav-link" onclick="closeNav()" href="#Configuration">Configuration</a></li>
<li><a class="nav-link" onclick="closeNav()" href="#Development">Development</a></li>
<li><a class="nav-link" onclick="closeNav()" href="#Testing">Testing</a></li>
<li><a class="nav-link" onclick="closeNav()" href="#Linting">Linting</a></li>
<li><a class="nav-link" onclick="closeNav()" href="#Distribution">Distribution</a></li>
</ul>
</div>
<div class="nav-toggle-container">
<div class="nav-toggler" onclick="toggleNav()"></div>
</div>
</nav>
<!-- <div class="nav-container"></div> -->
<!-- <div class="page-container"></div> -->
<div class="page-container">
<main id="main-doc">
<section class="main-section" id="Introduction">
<header>Introduction</header>
<p>
Logtweet is a command line tool to generate a tweet based on a #100DaysOfCode log message.
</p>
</section>
<section class="main-section" id="Usage">
<header>Usage</header>
<p>
The log from which the tweet will be generated has to have a format like my log.
You can find my log at <a href="https://log100days.lpld.io/log.md">https://log100days.lpld.io/log.md</a>.
My log is based on the <a href="https://github.com/kallaway/100-days-of-code/blob/master/log.md">original #100DaysOfCode log repo</a>.
But I am diverting from that format a little.
Specifically, I am using sub-headings (of the third level <code>### ...</code>) instead of strong text <code>**...**</code> to delimit the daily sub-sections ("Today's Progress", "Thoughts", "Links").
Check out <a href="https://raw.githubusercontent.com/tbrlpld/100-days-of-code/master/log.md">my raw log</a> for details.
</p>
<p>
This is a markdown log, that is converted into an HTML page.
I have created a little <a href="https://github.com/tbrlpld/log100days">Quart/Flask app that converts my log to an HTML site</a> using the <code>markdown2</code> package.
But other Markdown converters should work similar.
</p>
<p>
Once you have an HTML document with <code>h2</code> day headers and <code>h3</code> sections for "Today's Progress" and "Link(s)", you can point the tool at the URL of your HTML log page and generate a Tweet from it.
</p>
<p>
To actually enable the tweeting, you need to create a Twitter developer account and get an API key, API secret, Access Token and Access Token Secret.
</p>
<p>
The tweet will also contain the first link that you define in the "Link(s)" section under today's log.
To save some space, the link is shortened.
By default, I use <a href="https://s.lpld.io">my own link shortener</a>.
</p>
<p>
If you want to, you can also use the https://bit.ly service.
Their links might be a bit shorter and they provide you with some engagement and tracking info.
My link shortener does not do that.
To use the Bitly service, you need to generate an API key through them and add it to the config (see below).
</p>
</section>
<section class="main-section" id="Options">
<header>Options</header>
<p>
If you want to create a tweet for a different day than today, you can do so with the <code>--offset</code> command line flag.
The offset is defined in integer days relative to today.
So to generate a tweet for yesterday use <code>-o -1</code>.
</p>
<p>
If you want to suppress the actual tweeting and only see the message in the console, use the <code>--testmode</code> command line flag.
</p>
<ul>
<li><code>--offset</code>, <code>-o</code> — Offset in days from today.</li>
<li><code>--testmode</code>, <code>-t</code> — Suppress actual tweeting and only print to console.</li>
</ul>
</section>
<section class="main-section" id="Installation">
<header>Installation</header>
<p>
I recommend <code>pipx</code> to install python scripts and other tools in isolated virtual environments. This keeps the your platform Python installation clean and you don't have to worry about activating a particular virtual environment to use a tool/script.
</p>
<pre>
$ pipx install logtweet
</pre>
<p>
This way you will have a clean environment and the tool still available on the command line.
</p>
<p>
But if you want to, you should be able to install it with <code>pip install logtweet</code>.
</p>
</section>
<section class="main-section" id="Configuration">
<header>Configuration</header>
<p>
You need a configuration file for the script to work.
The <code>config.ini</code> can either be in the current working directory or in <code>~/.config/logtweet/</code>.
</p>
<p>
Because I can not figure out how to define a "post-install hook" that is run by <code>pip</code>, I can not generate an example config at the defined location.
This means you have to put the config there manually.
You can find an <a href="./config.ini.example">example config on GitHub</a>.
</p>
<p>
In that config file you define the URL where your log can be found and the API keys and access tokens that are needed for Twitter and Bit.ly.
</p>
<ul>
<li><code>config.ini</code> file in working directory.</li>
<li><code>~/.config/logtweet/config.ini</code> file in use's home directory.</li>
</ul>
</section>
<section class="main-section" id="Development">
<header>Development</header>
<p>
Install with
</p>
<pre>
$ python -m pip install -e ".[develop]"
</pre>
<p>
This installs the app dependencies as well as tools to develop and distribute the package.
</p>
</section>
<section class="main-section" id="Testing">
<header>Testing</header>
<p>
Run tests with
</p>
<pre>
$ pytest
</pre>
</section>
<section class="main-section" id="Linting">
<header>Linting</header>
<p>
This project makes use of code linters to keep the code quality consistent.
</p>
<ul>
<li>Run <code>flake8</code> for general code quality check.</li>
<li>Run <code>mypy .</code> to check type hints in the code.</li>
</ul>
<p>
To keep an eye on the current code quality, I would suggest installing the appropriate plugin for you editor/IDE to show the lints while working on it.
</p>
</section>
<section class="main-section" id="Distribution">
<header>Distribution</header>
<p>
To distribute the package on PyPi, first create the latest build with:
</p>
<pre>
$ python setup.py sdist bdist_wheel
</pre>
<p>
This creates the new distribution files in the <code>/dist</code> directory.
</p>
<p>Upload the created files (e.g. for version 0.1.4) with <code>twine</code>.</p>
<pre>
$ twine upload dist/logtweet-0.1.4*
</pre>
</section>
</main>
<footer>
<a href="https://github.com/tbrlpld/logtweet">Official Logtweet Repo on Github</a>
</footer>
</div>
</div>
* {
box-sizing: border-box;
font-family: 'Helvetica Neue', Arial, sans-serif;
}
html,
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
ol,
ul {
margin: 0;
padding: 0;
}
html {
color: black;
color: hsl(0, 0%, 20%);
background-color: white;
background-color: hsl(0, 0%, 100%);
font-size: 1rem;
line-height: 1.6;
}
::selection {
background-color: yellow;
background-color: hsla(80, 100%, 50%, 50%);
}
h1,
h2,
h3,
h4,
h5,
h6 {
line-height: 1.2;
margin-top: 1em;
}
h1 {
font-size: 2rem;
margin-top: 2em;
}
h2 {
font-size: 1.5rem;
margin-top: 2em;
}
h3 {
font-size: 1.25rem;
}
p,
ul,
ol,
pre {
margin-top: 0.75em;
}
li {
margin-top: 0.25em;
}
code,
pre {
max-width: 100%;
overflow: scroll;
background-color: lightgray;
background-color: hsl(204, 15%, 95%);
border-radius: 0.2em;
padding: 0.3em 0.4em;
font-family: monospace;
font-size: 1.0rem;
}
code {
display: inline;
}
a {
color: blue;
color: hsl(210, 100%, 50%);
text-decoration: none;
}
a:hover {
/*border-bottom: 2px hsl(210, 100%, 55%) solid;*/
text-decoration: underline
}
a:visited {
color: magenta;
color: hsl(210, 100%, 40%);
}
ul,
ol {
list-style-position: outside;
padding-left: 1.75em;
}
ul > li,
ol > li {
padding-left: 0.5em;
}
ul > li {
list-style: disc;
}
hr {
border: none;
border-top: 1px solid lightgray;
border-top: 1px solid hsl(0, 0%, 90%);
margin: 50px 0;
}
input,
textarea,
select,
button,
fieldset {
border: 1px solid lightgray;
border: 1px solid hsl(0, 0%, 90%);
border-radius: 2px;
}
button,
input,
select,
textarea {
background: none;
background-color: white;
background-color: hsl(0, 0%, 100%);
background-color: hsla(0, 0%, 100%, 0%);
color: black;
color: hsl(0, 0%, 20%);
font-size: 1rem;
line-height: 1.6;
padding: 0.2em 0.5em;
}
::placeholder {
color: lightgray;
color: hsl(0, 0%, 70%);
}
select {
display: inline-block;
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='10px' width='10px'><polygon points='1,1 9,1 5,9' style='fill:hsl(0, 0%, 70%);' /></svg>");
background-origin: border-box;
background-repeat: no-repeat;
background-position: center right 5px;
padding-right: 1em;
}
button:hover,
input[type=button]:hover,
input[type=submit]:hover {
background: lightgray;
background: hsl(0, 0%, 90%);
}
button:active,
input[type=button]:active,
input[type=submit]:active {
background: gray;
background: hsl(0, 0%, 80%);
border-color: gray;
border-color: hsl(0, 0%, 80%);
}
img {
max-width: 100%;
height: auto;
}
/*LAYOUT*******************************************************************************************/
.app-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
/*background-color: orange;*/
}
.page-container {
flex: 3 1;
overflow: scroll;
/*background-color: lightblue;*/
}
nav {
position: fixed;
top: 0;
left: 0;
width: 100%;
}
@media (min-width: 700px) {
nav {
position: relative;
flex: 1 3;
border-right: 1px solid hsl(0, 0%, 90%);
/*background-color: yellow;*/
}
}
main {
margin: 0 auto;
padding: 1rem;
max-width: 80ch;
}
main section {
margin-top: 2rem;
}
footer {
margin-top: 2rem;
padding: 2em;
background-color: hsl(204, 15%, 97%);
text-align: center;
}
/*MODULE*******************************************************************************************/
.nav-collapsible {
padding: 1rem;
border-bottom: 1px solid hsl(0, 0%, 90%);
background-color: white;
}
@media (min-width: 700px) {
.nav-collapsible {
border-bottom: none;
}
}
.nav-link-list {
padding: 0;
max-height: 51vh;
overflow-y: scroll;
}
@media (min-width: 700px) {
.nav-link-list {
max-height: 80vh;
}
}
.nav-link-list > li {
padding: 0;
margin: 0;
list-style: none;
border-top: 1px solid hsl(0, 0%, 90%);
min-height: 40px;
line-height: 40px;
}
.nav-link-list > li:first-of-type {
border-top: none;
}
.nav-toggle-container {
text-align: right;
}
.nav-toggler {
position: relative;
display: inline-block;
min-height: 40px;
min-width: 40px;
margin: 10px;
border: 1px solid hsl(0, 0%, 90%);
border-radius: 2px;
background-color: white;
text-align: center;
}
.nav-toggler::before {
height: 40px;
line-height: 40px;
content: "\2630";
}
@media (min-width: 700px) {
.nav-toggler {
display: none;
}
}
nav header {
font-size: x-large;
font-weight: 500;
}
section header {
font-size: x-large;
font-weight: 500;
}
/*STATE********************************************************************************************/
.nav-collapsible.closed {
display: none;
}
@media (min-width: 700px) {
.nav-collapsible.closed {
display: inherit;
}
}
.nav-collapsible.open {
display: inherit;
}
/*THEME********************************************************************************************/
function switchClassClosedToOpen (element) {
element.classList.add('open')
element.classList.remove('closed')
}
function switchClassOpenToClose (element) {
element.classList.add('closed')
element.classList.remove('open')
}
function toggleNav () {
const COLLAPSIBLE = document.getElementById('nav-collapsible')
const IS_CLOSED = COLLAPSIBLE.classList.contains('closed')
if (IS_CLOSED === true) {
switchClassClosedToOpen(COLLAPSIBLE)
} else {
switchClassOpenToClose(COLLAPSIBLE)
}
}
function closeNav () {
const COLLAPSIBLE = document.getElementById('nav-collapsible')
const IS_OPEN = COLLAPSIBLE.classList.contains('open')
if (IS_OPEN === true) {
switchClassOpenToClose(COLLAPSIBLE)
}
}
Also see: Tab Triggers