PHPetite 2024-02-02T18:05:24+00:00 https://phpetite.btxx.org/ Bradley Taunt bt@btxx.org Cleaning Things Up & Future PHPetite Updates 2022-06-28T00:00:00+00:00 https://phpetite.btxx.org/#2022-06-28-cleaning-things-up-future-phpetite-updates <h1>Cleaning Things Up &amp; Future PHPetite Updates</h1> <p>It has been quite a long time since I've reviewed or updated this little project of mine. Since it's release, I've created another minimal blogging system (based on <code>bash</code> this time) called <a href="https://shinobi.website">Shinobi</a> and converted my personal website to use <em>that</em> instead.</p> <p>But I still love this single file blogging concept. So, I thought it was time for some basic cleanup. That "cleanup" slowly turned into a TODO list of sorts and now there are extra features I plan to add.</p> <h2>The Cleanup</h2> <p>* I first started by including the specific <code>$_SERVER['DOCUMENT_ROOT'].</code> parameter in the main PHP includes. I noticed when pulling the project in a "fresh" instance that the build failed without this setup. Sorry for anyone who may have ran into this issue previously!</p> <p>* The default build script has been moved into a proper <code>makefile</code>. Now, generating the website only requires you to run <code>make</code> from the main directory. Running <code>make serve</code> builds the website and also runs a local server for testing at <code>localhost:8000</code>. Nothing groundbreaking but pretty helpful.</p> <p>* The original dark mode CSS styling has been removed in favor of using the browser supported <code>color scheme</code> meta tag.</p> <p>* Post dates are now listed at the top of each blog article (see above for reference)</p> <h2>What's to Come</h2> <p>I keep a running list of features I plan to implement (in no particular order) on the main <a href="#about">about section</a>. Feel free to open an issue on the <a href="https://todo.sr.ht/~bt/phpetite">official sourcehut todo</a> if you have other features and suggestions. Don't be shy!</p> <h2>Follow Along</h2> <p>Rolling out any new updates for this project will take time. I'm in no <em>real</em> rush and I do have other projects that require my attention. That said, if you wish to stay up-to-date, I recommend following along via the <a href="/atom.xml">official RSS feed</a>.</p> <p>Thanks for reading and happy single-file blogging!</p> <p>-- Brad</p> Converting Custom Fonts to Base64 Strings 2021-02-27T00:00:00+00:00 https://phpetite.btxx.org/#2021-02-27-converting-custom-fonts-to-base64-strings <h1>Converting Custom Fonts to Base64 Strings</h1> <p>There are currently no plans to automatically convert custom fonts to base64 strings within the project itself - <strong>but</strong> it is very easy to do so manually for Mac/Linux users.</p> <p>Simply open a terminal window and navigate to where your custom font file is located. The enter the following command (replacing the font extension name with your appropriate file name):</p> <pre><code class="bash">base64 your-custom-font.woff2 &gt; font-base64.txt</code></pre> <p>Then in your <code>style.css</code> file, add the custom font as you normally would via the <code>@font-face</code> property but this time utilizing base64:</p> <pre><code class="css">@font-face { font-family: 'FontName; src: url(data:font/woff2;base64,[BASE64 CODE]) format('woff2'); }</code></pre> <h2>Things to Keep in Mind</h2> <p>Remember that by using base64 strings you are <em>significantly</em> increasing the overall size of your single file project. This should be used for extreme use cases where a single file website/blog isn't allowed access to 3rd party URLs or extra files on the root server. Hence why by default it isn't include in the PHPetite project itself.</p> <h2>Live Example</h2> <p>You can check out the <a href="https://thrifty.name">ThriftyName</a> project (built on PHPetite) to see base64 custom fonts in use.</p> Disable Image to Base64 Conversion 2021-02-18T00:00:00+00:00 https://phpetite.btxx.org/#2021-02-18-disable-image-to-base64-conversion <h1>Disable Image to Base64 Conversion</h1> <p>Some users<sup><a href="#" class="footnote-ref">2</a></sup> may wish to host their imagery and media via a 3rd party source or simply want to avoid the heavy weight added with using base64 strings (~133%+ in size). </p> <p>To disable this feature, open your <code>_phpetite/_config.php</code> file and change the <code>images_to_base64</code> variable to false.</p> <pre><code class="php">// Activate or disable images to base64 strings $images_to_base64 = false;</code></pre> <div class="footnotes"> <hr /> <ol> <li> <p>Thanks to <a href="https://news.ycombinator.com/user?id=Minor49er">Minor49er</a> for suggesting this option on <a href="https://news.ycombinator.com/item?id=26175904">Hacker News</a>&#160;<a href="#" class="footnote-backref">&#8617;</a></p> </li> </ol> </div> Automatic RSS 2021-02-08T00:00:00+00:00 https://phpetite.btxx.org/#2021-02-08-automatic-rss <h1>Automatic RSS</h1> <p>PHPetite ships with a very basic and crude auto-generated RSS feed. When you run the project's build script:</p> <pre><code class="bash">bash build.sh</code></pre> <p>it not only generates the single HTML blog file, but also creates an <code>atom.xml</code> file in the root directory. Simply share this with your followers or link it somewhere on your site itself (eg. <code>yourdomain.com/atom.xml</code>).</p> <p>You can view this site's RSS feed here: </p> <p><a href="https://phpetite.org/atom.xml">https://phpetite.org/atom.xml</a></p> The Benefits of a Single File Blog 2021-02-07T00:00:00+00:00 https://phpetite.btxx.org/#2021-02-07-the-benefits-of-a-single-file-blog <h1>The Benefits of a Single File Blog</h1> <p>Rendering your blog or website as a single file using PHPetite is pretty fantastic. It gives you the freedom to easily share, host or edit your site's content on almost any hosting provider. </p> <p>Since the entire blog's content is generated inline on <code>build</code>, you don't need to fiddle around with external <code>CSS</code> and <code>JS</code> files. There is also no need to worry about broken <code>img</code> sources since PHPetite converts all images into proper base64 strings.</p> <p>Using this website as an example: this blog weighs in at <strong>~21KB</strong><sup><a href="#" class="footnote-ref">2</a></sup>. </p> <p>That is incredibly tiny in terms of website size. Some sections on other web pages are larger than that!</p> <p>The portability of having a <em>single</em> <code>HTML</code> file as your blog is quite liberating. Though it should be noted, if your blog consists of high resolutions imagery or includes massive amounts of content, a single file might be a little impractical for you.</p> <h2>Hosting for Newcomers</h2> <p>I suggest using <a href="https://app.netlify.com/drop">Netlify Drop</a> if this is your first time setting up a hosting environment or you don't consider yourself too tech-savvy. Once you have your rendered <code>index.html</code> file, simply drag-and-drop the file into Netlify Drop - that's it!</p> <p>From there you can always setup a permanent subdomain or use your own custom domain.</p> <h2>Local Development</h2> <p>Simply follow the instructions found on the <a href="#generating-this-blog">Generating This Blog</a> page and you'll be running a local version of your site in seconds.</p> <div class="footnotes"> <hr /> <ol> <li> <p>At this time of writing (Feb 2021)&#160;<a href="#" class="footnote-backref">&#8617;</a></p> </li> </ol> </div> Converting from Jekyll 2021-02-06T00:00:00+00:00 https://phpetite.btxx.org/#2021-02-06-converting-from-jekyll <h1>Converting from Jekyll</h1> <p>This walkthrough is still being tweaked and optimized. Check back soon for the final version!</p> Markdown examples 2021-01-09T00:00:00+00:00 https://phpetite.btxx.org/#2021-01-09-markdown-examples <h1><abbr title="Markdown is a lightweight markup language for creating formatted text using a plain-text editor">Markdown</abbr> examples</h1> <p>On top of plain <abbr title="Markdown is a lightweight markup language for creating formatted text using a plain-text editor">Markdown</abbr>, <a href="https://michelf.ca/projects/php-markdown/extra"><abbr title="Markdown is a lightweight markup language for creating formatted text using a plain-text editor">Markdown</abbr> Extra</a> adds support for footnotes, abbreviations, definition lists, tables, <code>class</code> and <code>id</code> attributes, fenced code blocks, and <abbr title="Markdown is a lightweight markup language for creating formatted text using a plain-text editor">Markdown</abbr> inside <abbr title="Hypertext Markup Language">HTML</abbr> blocks.</p> <p>Additionally, images are properly enclosed in figure elements (with optional figcaption), and the <code>loading="lazy"</code> attribute is added.</p> <hr /> <p>This is <strong>bold</strong>, <em>italic</em>, this is an <a href="#2021-01-11-hello-world">internal link</a>, this is <del>not</del> <code>code</code>, press <kbd>alt</kbd>.</p> <figure><img src="content/img/image.png" alt="This is the image alt text" title="This is the image title." width="1280" height="800" loading="lazy" /><figcaption>This is the image caption (line begins with a space). The image above is actually a rendered base64 encoding.</figcaption> </figure> <blockquote> <p>This text is in a blockquote.</p> </blockquote> <h2>This is a level 2 heading</h2> <h3>This is a level 3 heading</h3> <ul> <li>This</li> <li>is</li> <li>a list</li> </ul> <ol start="0"> <li>This</li> <li>is</li> <li>an</li> <li>ordered list</li> </ol> <pre><code class="txt">This is preformatted text.</code></pre> <table> <thead> <tr> <th>this is a table</th> <th>header</th> <th style="text-align: right;">this column is right-aligned</th> </tr> </thead> <tbody> <tr> <td>these</td> <td>content</td> <td style="text-align: right;">1234</td> </tr> <tr> <td>are</td> <td>cells</td> <td style="text-align: right;">56789</td> </tr> </tbody> </table> <p>This sentence has a footnote.<sup><a href="#" class="footnote-ref">2</a></sup></p> <div class="footnotes"> <hr /> <ol> <li> <p>This is a footnote&#160;<a href="#" class="footnote-backref">&#8617;</a></p> </li> </ol> </div>