<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>LINICKX.com</title><link>https://www.linickx.com/</link><description></description><lastBuildDate>Sat, 07 Mar 2020 11:05:00 +0000</lastBuildDate><item><title>Adding Dark Mode to your website is super easy!</title><link>https://www.linickx.com/adding-dark-mode-to-your-website-is-super-easy</link><description>&lt;p&gt;Whilst tweaking my website at the beginning of the year I was surprised how easy it is to support Light Mode or Dark Mode themes. The implementation below isn't a user toggle Javascript thing, browsers now have a "media preference", that is if your iPhone, Mac or Windows 10 is setup for Light Mode then it'll prefer a lighter style and the opposite is true, if you're setup for Dark Mode then a darker style is displayed.&lt;/p&gt;
&lt;h2&gt;Example 1: Light/White Website with optional Dark Mode.&lt;/h2&gt;
&lt;p&gt;&lt;img alt="Light Example" src="/files/2020/03/light_eg.gif" /&gt;&lt;/p&gt;
&lt;p&gt;To start with, let's take &lt;a href="https://getbootstrap.com/docs/4.4/getting-started/introduction/"&gt;the initial template from bootstrap&lt;/a&gt; and add 8 lines of code (&lt;em&gt;mostly whitespace!&lt;/em&gt;) to include an optional inverted view; this is what we add...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;
    @media (prefers-color-scheme: dark) {
      body {
        background-color: black;
        color: white;
      }
    }
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So the final page looks like this, save it as &lt;a href="/files/2020/03/light_eg.html"&gt;&lt;code&gt;light_eg.html&lt;/code&gt;&lt;/a&gt; on your desktop.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!doctype html&amp;gt;
&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;!-- Required meta tags --&amp;gt;
    &amp;lt;meta charset=&amp;quot;utf-8&amp;quot;&amp;gt;
    &amp;lt;meta name=&amp;quot;viewport&amp;quot; content=&amp;quot;width=device-width, initial-scale=1, shrink-to-fit=no&amp;quot;&amp;gt;

    &amp;lt;!-- Bootstrap CSS --&amp;gt;
    &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css&amp;quot; integrity=&amp;quot;sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh&amp;quot; crossorigin=&amp;quot;anonymous&amp;quot;&amp;gt;

    &amp;lt;title&amp;gt;Hello, world!&amp;lt;/title&amp;gt;

    &amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;
        @media (prefers-color-scheme: dark) {
          body {
            background-color: black;
            color: white;
          }
        }
    &amp;lt;/style&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;Hello, world!&amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;Example HTML from &amp;lt;a href=&amp;quot;https://getbootstrap.com/docs/4.4/getting-started/introduction/&amp;quot;&amp;gt;bootstrap&amp;lt;/a&amp;gt;

  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By default the page will be the &lt;em&gt;normal&lt;/em&gt; bootstrap colours, dark text on a white background but if the user has setup their device in Dark Mode the site will be white text on a black background.&lt;/p&gt;
&lt;h2&gt;Example 2: Dark/Black Website with optional Light Mode.&lt;/h2&gt;
&lt;p&gt;&lt;img alt="Dark Example" src="/files/2020/03/dark_eg.gif" /&gt;&lt;/p&gt;
&lt;p&gt;Ok, so what if your use case was the same as mine; your site is normally dark but you want to provide a brighter version for people who prefer the lighter side of the net.&lt;/p&gt;
&lt;p&gt;This time, lets start with the full HTML example: &lt;a href="/files/2020/03/dark_eg.html"&gt;&lt;code&gt;dark_eg.html&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!doctype html&amp;gt;
&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;!-- Required meta tags --&amp;gt;
    &amp;lt;meta charset=&amp;quot;utf-8&amp;quot;&amp;gt;
    &amp;lt;meta name=&amp;quot;viewport&amp;quot; content=&amp;quot;width=device-width, initial-scale=1, shrink-to-fit=no&amp;quot;&amp;gt;

    &amp;lt;!-- Bootswatch CSS --&amp;gt;

    &amp;lt;link href=&amp;quot;https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/cyborg/bootstrap.min.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; integrity=&amp;quot;sha384-l7xaoY0cJM4h9xh1RfazbgJVUZvdtyLWPueWNtLAphf/UbBgOVzqbOTogxPwYLHM&amp;quot; crossorigin=&amp;quot;anonymous&amp;quot;&amp;gt;

    &amp;lt;title&amp;gt;Hello, world!&amp;lt;/title&amp;gt;

    &amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;
        @media (prefers-color-scheme: light) {
          body, h1, h2, h3 {
            background-color: white;
            color: black;
          }
        }
    &amp;lt;/style&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;Hello, world!&amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;Example HTML from &amp;lt;a href=&amp;quot;https://getbootstrap.com/docs/4.4/getting-started/introduction/&amp;quot;&amp;gt;bootstrap&amp;lt;/a&amp;gt; with dark &amp;lt;a href=&amp;quot;https://bootswatch.com/cyborg/&amp;quot;&amp;gt;Cyborg Theme&amp;lt;/a&amp;gt;

  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this example we're using &lt;a href="https://bootswatch.com/cyborg"&gt;a dark bootstrap theme called cyborg&lt;/a&gt;, again we add in our 8 lines, but notice something a little different:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;
    @media (prefers-color-scheme: light) {
      body, h1, h2, h3 {
        background-color: white;
        color: black;
      }
    }
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the dark example, additional changes are needed for &lt;code&gt;h1&lt;/code&gt;, &lt;code&gt;h2&lt;/code&gt; &amp;amp; &lt;code&gt;h3&lt;/code&gt; so this is the gotcha to look out for when using off-the-shelf themes. In the cyborg theme, the headings do not inherited their colour from body, they are hard set; when the colour scheme is inverted the white on white text disappears. To fix the issue some additional &lt;code&gt;h1&lt;/code&gt;, &lt;code&gt;h2&lt;/code&gt; &amp;amp; &lt;code&gt;h3&lt;/code&gt; colours are needed, so make sure you test your site in each mode to capture any missing options.&lt;/p&gt;
&lt;h3&gt;Footnotes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;This feature isn't dependent on bootstrap, it simply makes a good example as it's a style/css framework that's very common.&lt;/li&gt;
&lt;li&gt;User's cannot &lt;em&gt;choose&lt;/em&gt; a theme, this approach simply honours their system wide preference&lt;/li&gt;
&lt;li&gt;Inspired by Flavio's dark mode post: https://flaviocopes.com/dark-mode/&lt;/li&gt;
&lt;/ul&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nick Bettison</dc:creator><pubDate>Sat, 07 Mar 2020 11:05:00 +0000</pubDate><guid isPermaLink="false">tag:www.linickx.com,2020-03-07:adding-dark-mode-to-your-website-is-super-easy</guid><category>Design</category><category>CSS</category></item><item><title>CSS Styling Nginx Directory Listings</title><link>https://www.linickx.com/css-styling-nginx-directory-listings</link><description>&lt;p&gt;Following the sucess of &lt;a href="https://www.linickx.com/css-styling-apache-directory-listings"&gt;my apache styling post&lt;/a&gt;, I thought I'd share how I've styled &lt;a href="/files"&gt;/files&lt;/a&gt; now that &lt;a href="https://www.linickx.com"&gt;linickx.com&lt;/a&gt; is powerd by &lt;a href="http://nginx.org"&gt;nginx&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A quick google will tell you that &lt;a href="http://wiki.nginx.org/NgxFancyIndex"&gt;fancyindex&lt;/a&gt; is on option however, I'm running &lt;a href="http://www.centos.org"&gt;CentOS&lt;/a&gt; and the &lt;a href="http://wiki.nginx.org/Install"&gt;supplied rpm&lt;/a&gt; doesn't come with that moduel.... and I'm not about to start compiling!&lt;/p&gt;
&lt;p&gt;What I did find is that the rpm comes with is, &lt;a href="http://nginx.org/en/docs/http/ngx_http_addition_module.html"&gt;http_addition_module&lt;/a&gt;. It's not a perfect solution for applying HTML/CSS to &lt;a href="http://nginx.org/en/docs/http/ngx_http_autoindex_module.html"&gt;autoindex&lt;/a&gt; because the output ends up with two lots of html &amp;amp; body tags... anyway onto the example!&lt;/p&gt;
&lt;p&gt;In &lt;a href="https://github.com/linickx/dotcom/tree/master/nginx"&gt;my nginx&lt;/a&gt; config, I've added:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;location /files {
  add_before_body /files/nginx-before.txt;
  add_after_body /files/nginx-after.txt;
  autoindex on;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;autoindex&lt;/code&gt; enables directory listings; the two text files, &lt;code&gt;nginx-before.txt&lt;/code&gt; &amp;amp; &lt;code&gt;nginx-after.txt&lt;/code&gt; apply the style.&lt;/p&gt;
&lt;p&gt;You can view my example files here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="/files/nginx-before.txt"&gt;nginx-before.txt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="/files/nginx-after.txt"&gt;nginx-after.txt&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here's a couple of screenshots:&lt;/p&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="/files/2015/02/df_nginx_autoindex.png"&gt;&lt;img src="/files/2015/02/df_nginx_autoindex-150x150.png" alt="nginx autoindex before" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;a href="/files/2015/02/lnx_nginx_autoindex.png"&gt;&lt;img src="/files/2015/02/lnx_nginx_autoindex-150x150.png" alt="nginx autoindex before" /&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Before&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;After&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nick Bettison</dc:creator><pubDate>Sun, 15 Feb 2015 18:22:00 +0000</pubDate><guid isPermaLink="false">tag:www.linickx.com,2015-02-15:css-styling-nginx-directory-listings</guid><category>CSS</category><category>nginx</category></item><item><title>Twittering with Tools</title><link>https://www.linickx.com/twittering-with-tools</link><description>&lt;p&gt;LINICKX.com is evolving, I'm not sure how yet but I've started by
introducing &lt;a href="http://alexking.org/projects/wordpress/readme?project=twitter-tools"&gt;twitter
tools&lt;/a&gt;,
google has changed the face of websites, according to google analytics
my home page is not longer the top landing page, i.e. most people
visiting my site hit the content they want directly and don't need to
navigate through the site... with this in mind I'm thinking about
turning linickx.com into a &lt;a href="http://www.tumblr.com/"&gt;tumblr&lt;/a&gt; type
thing... twitter tools allows me to post short "thoughts" and "comments"
without having to go through the full WordPress write post thing.&lt;/p&gt;
&lt;p&gt;I started the idea along time ago when photomatt introduced asides, i.e.
I've always had categories and different front page presentation styles
for &lt;a href="https://www.linickx.com/archives/category/blog"&gt;blog posts&lt;/a&gt;,
&lt;a href="https://www.linickx.com/archives/category/firefox"&gt;firefox posts&lt;/a&gt;,
&lt;a href="https://www.linickx.com/archives/category/delicious"&gt;delicious posts&lt;/a&gt;
and then everything else... so I'm thinking about taking the idea
further by creating individual posts,feeds and styles for delicious
links and rss shared items (&lt;em&gt;from google reader&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;Since I want to keep my feed clean (&lt;em&gt;it's imported into many social
networks like mugshot &amp;amp; facebook&lt;/em&gt;) I've used &lt;a href="http://zeo.unic.net.my/notes/exclude-category-in-wordpress/"&gt;this
post&lt;/a&gt; to
filter out my new "sync" category... sync as in I'm synchronising my web
life with my website :) - Oh Yeah before I foget don't add the code to
functions.php as it creates a php warning, create a wordpress plugin.&lt;/p&gt;
&lt;p&gt;My web/work/social life is quite busy - who's isn't!... so I'm a little
worried about how to style the whole thing I found a nice way of &lt;a href="http://www.htmlsource.co.uk/using-css-and-blockquote/"&gt;quote
text with css&lt;/a&gt;,
so the tweets look good, but I'm worried that bookmarks and shared posts
could make the site look cluttered or confusing, I've already had to add
a "twitter reply" link to each post since the 1st thing people have
asked me is what's twitter.. doh must be a UK web-ignorance thing.&lt;/p&gt;
&lt;p&gt;I guess we'll just see how this pan's out, I've just renewed this
domain, so it'd be nice to finish for the domains birthday :D&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nick</dc:creator><pubDate>Sat, 16 Feb 2008 19:12:00 +0000</pubDate><guid isPermaLink="false">tag:www.linickx.com,2008-02-16:twittering-with-tools</guid><category>Blog</category><category>css</category><category>twitter</category><category>webdesign</category><category>WordPress</category></item><item><title>CSS Styling Apache Directory Listings.</title><link>https://www.linickx.com/css-styling-apache-directory-listings</link><description>&lt;div style="float:right"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;a href="https://www.linickx.com/files/2008/05/apachedirlisting_before.png"&gt; &lt;img src="https://www.linickx.com/files/2008/05/apachedirlisting_before-150x150.png" alt="Before I change Apache" /&gt;&lt;/a&gt;
&lt;/td&gt;
&lt;tr&gt;
&lt;td style="text-align:center"&gt;
**Before.**
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;As part of &lt;a href="https://www.linickx.com/archives/336/website-changes"&gt;my website
overhaul&lt;/a&gt;, I've
finally gotten round to styling my
&lt;a href="https://www.linickx.com/files/"&gt;/files/&lt;/a&gt; directory. I was surprised at
how easy it was actually, and the benefits far out way the time taken to
set it up, not only does this part of the site now "fit in", but I can
apply analytics tracking and adsense ;) I'm sure there probably is a
wordpress plugin that can achieve the same thing... probably better, but
I find my list of plugins ever growing and since I don't &lt;em&gt;need&lt;/em&gt; on for
this I figure if Apache can do it, let Apache do it!&lt;/p&gt;
&lt;p&gt;The work can be done in one of two ways either by pasting Apache
directives into a .htaccess file (&lt;em&gt;in the directory you want to apply
conf to&lt;/em&gt;), or in your httpd.conf you can wrap it all up in a&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;Directory&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;tag... something like&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;Directory "/var/www/html/files/"&amp;gt; foobar&amp;gt; &amp;lt;/Directory&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;below is an example of a .htaccess file as that will apply to most
people:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;        RewriteEngine Off
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml
        Options Indexes Includes
        IndexOptions FancyIndexing SuppressHTMLPreamble XHTML IconsAreLinks FoldersFirst SuppressDescription
        HeaderName /files/HEADER.shtml
        ReadmeName /files/README.shtml
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since my site uses wordpress with "pretty permalinks" enabled, the 1st
thing I needed to do is disable mod re-write for the directory where I
wanted listing enabled. Now if you check my
&lt;a href="https://www.linickx.com/files/"&gt;/files/&lt;/a&gt; page you'll notice that the
page title and tag line under "[LINICKX].com" change depending on what
directory you are viewing, this is done with "Server Side Includes"
(&lt;em&gt;SSI&lt;/em&gt;), so the next two options in the above config set that up.&lt;/p&gt;
&lt;p&gt;Now to take a look at the actual directory listing setup, it might be
worth you taking a look at the &lt;a href="http://httpd.apache.org/docs/2.2/mod/mod_autoindex.html"&gt;Apache
documentation&lt;/a&gt;
for a full description, but the important ones to note are&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Options Indexes Includes
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to enable directory listing and switch on SSI, then you need&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;IndexOptions SuppressHTMLPreamble XHTML
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to disable the default headers so that we can setup our style sheet and
favour xHTML over HTML. Apache 2.2 users also have
&lt;a href="http://httpd.apache.org/docs/2.2/mod/mod_autoindex.html#indexstylesheet"&gt;IndexStyleSheet&lt;/a&gt;
available, but since I'm using CentOS4 we'll do it this way. Finally you
need the &lt;strong&gt;HeaderName&lt;/strong&gt;, &lt;strong&gt;ReadmeName&lt;/strong&gt; directives to tell Apache which
file to look for (&lt;em&gt;by default Apache looks for README.html, but that
won't support SSI&lt;/em&gt;)... note how my .shtml files are relative to my web
root, these are not absolute paths on the file system, i.e. /files
actually maps to /var/www/html/files.&lt;/p&gt;
&lt;p&gt;You're now good to go, HEADER.shtml should contain all the xHTML you
want to appear before the directory listing, and README.html is
everything after... make sure you include all the correct \&amp;lt;html&amp;gt;,
\&amp;lt;body&amp;gt; and DOCTYPE tags.&lt;/p&gt;
&lt;p&gt;Now you'll want to get working is some dynamic content, for a simple
"print current directory" you can use&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!--#echo var="REQUEST_URI"--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;in your html, further documentation on getting more magic is available
&lt;a href="http://webmaster.iu.edu/tool_guide_info/ssitutorial.shtml"&gt;here&lt;/a&gt; &amp;amp;
&lt;a href="http://www.georgedillon.com/web/ssivar.shtml"&gt;here&lt;/a&gt;, I was able to
knock up a simple line of code to print the current year at the bottom
of the page....&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;!--#config timefmt="%Y"--&amp;gt;
&amp;lt;small&amp;gt;Nick Bettison 2005 - &amp;lt;!--#echo var="DATE_LOCAL"--&amp;gt; &amp;amp;amp;copy; &amp;lt;/small&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cool eh! The trick to watch out for is spaces in the above code, there
should be no white space between&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;--#echo
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or the trailing&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;--&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style="float:right"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;a href="https://www.linickx.com/files/2008/05/apachedirlisting_after.png"&gt;&lt;img src="https://www.linickx.com/files/2008/05/apachedirlisting_after-150x150.png" atlt="Linickx.com V2 Styled Listing!"&gt;&lt;/a&gt;
&lt;/td&gt;
&lt;tr&gt;
&lt;td style="text-align:center"&gt;
**After.**
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;The final thing you'll want to look at is those horible default icons!
You have a couple of options: You can either simply replace/over-write
the default ones (&lt;em&gt;on my flavour of linux they are in /var/www/icons&lt;/em&gt;),
or you can add&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;AddIcon /icons/tar.png .tar
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to your htaccess file telling apache to look at tar.png rather than the
default tar.gif, I found some &lt;a href="https://gna.org/projects/apache-icons/"&gt;deb
archives&lt;/a&gt; which I extracted with
file-roller (&lt;em&gt;rather than trying to install anything&lt;/em&gt;) and simply
changed the ones I was going to use.... I'm very please with the final
result, I think it makes a big difference.&lt;/p&gt;
&lt;p&gt;Happy Styling One &amp;amp; All!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nick</dc:creator><pubDate>Thu, 11 Oct 2007 08:44:00 +0100</pubDate><guid isPermaLink="false">tag:www.linickx.com,2007-10-11:css-styling-apache-directory-listings</guid><category>apache</category><category>Blog</category><category>css</category><category>how to</category><category>web design</category><category>WordPress</category></item></channel></rss>