Skip to content

Commit

Permalink
fix css minimization
Browse files Browse the repository at this point in the history
  • Loading branch information
serianox committed Sep 17, 2017
1 parent 7c72275 commit 6e4e3ed
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
**.frag
**.frag.html
**.plain.html
**.css
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,30 @@ styl = $(shell find . -type f -name '*.styl')

all: $(html) ## Build all the files

%.html: %.html.frag %.css template.slim html-minifier.conf
slimrb template.slim /dev/stdout <$< $(word 2, $^) |\
%.html: %.frag.html %.css template.slim html-minifier.conf
slimrb $(word 3, $^) /dev/stdout <$< $(word 2, $^) |\
html-minifier --config-file html-minifier.conf >$@

%.css: %.html.plain style.css.frag
purifycss $(word 2, $^) $< --min --out=$@
%.css: %.plain.html style.css
purifycss -r $(word 2, $^) $< --min --out=$@

%.html.plain: %.html.frag template.slim
slimrb $(word 2, $^) /dev/stdout <$< /dev/null >$@
%.plain.html: %.frag.html /dev/null template.slim
slimrb $(word 3, $^) /dev/stdout <$< $(word 2, $^) >$@

%.html.frag: %.md
%.frag.html: %.md
pandoc $< -f markdown -t html5 -o $@

index.md: $(filter-out ./index.md, $(md))
./tocify.sh $@

style.css.frag: $(styl)
style.css: $(styl)
cat $^ |\
stylus |\
cleancss -O2 >$@

.PHONY: help
.PRECIOUS: %.plain.html %.frag.html %.css
.DEFAULT_GOAL := all

.PHONY: help
help: ## Show the list of targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2 changes: 1 addition & 1 deletion android-kotlin-migration.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><meta charset=utf-8><title>make index.html</title><meta content="" name=description><meta content="" name=author><meta content="" name=keywords><meta content="width=device-width,initial-scale=1" name=viewport><h1 id=manually-migrating-an-android-project-to-kotlin>Manually migrating an Android project to Kotlin</h1><p>Kotlin is now officialy <a href=https://developer.android.com/kotlin/index.html>Kotlin and Android</a>, and as such I wanted to give it another try. There are of course tutorials <a href=https://kotlinlang.org/docs/tutorials/kotlin-android.html>out there</a>, but they all aim users of Android Studio. Let's see how we can do without.<p>First things first, let's add Kotlin to our build script. We need to add to the <code>build.gradle</code> of our application three things:<ul><li>the repository where Kotlin is found,<li>the dependency to the build tools for Kotlin,<li>the runtime dependencies for our project.</ul><div class=sourceCode><pre class="sourceCode diff"><code class="sourceCode diff">buildscript {
<!DOCTYPE html><meta charset=utf-8><title>make index.html</title><meta content="" name=description><meta content="" name=author><meta content="" name=keywords><meta content="width=device-width,initial-scale=1" name=viewport><style>h1,h2,h3,h4,h5,h6{color:#494e6b}a,html{color:#98878f}html{color:#bbb;background:html;text-align:justify;hyphens:auto;font-family:Georgia,serif;hyphens:auto;text-rendering:optimizeLegibility}h1,h2,h3,h4,h5,h6{text-align:left;font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif}p{text-indent:1em}code,h1+p,h2+p,h3+p{text-indent:0}ul>li{list-style:none}ul>li:before{content:'– '}li:before{display:inline-block;content:counter(listitem) '. ';counter-increment:listitem}code>span.do{color:#999}code,pre{font-family:"Lucida Console",Monaco,courier,monospace}</style><h1 id=manually-migrating-an-android-project-to-kotlin>Manually migrating an Android project to Kotlin</h1><p>Kotlin is now officialy <a href=https://developer.android.com/kotlin/index.html>Kotlin and Android</a>, and as such I wanted to give it another try. There are of course tutorials <a href=https://kotlinlang.org/docs/tutorials/kotlin-android.html>out there</a>, but they all aim users of Android Studio. Let's see how we can do without.<p>First things first, let's add Kotlin to our build script. We need to add to the <code>build.gradle</code> of our application three things:<ul><li>the repository where Kotlin is found,<li>the dependency to the build tools for Kotlin,<li>the runtime dependencies for our project.</ul><div class=sourceCode><pre class="sourceCode diff"><code class="sourceCode diff">buildscript {
<span class=va>+ repositories {</span>
<span class=va>+ jcenter()</span>
<span class=va>+ mavenCentral()</span>
Expand Down
2 changes: 1 addition & 1 deletion android-sdk-install.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!DOCTYPE html><meta charset=utf-8><title>make index.html</title><meta content="" name=description><meta content="" name=author><meta content="" name=keywords><meta content="width=device-width,initial-scale=1" name=viewport><h1 id=android-headless-sdk-installation>Android <em>headless</em> SDK installation</h1><p>I wanted to install <em>Android SDK</em> without installing this ugly IDE. The main goal was to rebuild existing projects, so I didn't need something as heavy. The main difficulty came when I downloaded the actual sdk, and receive the following message from Google.<blockquote><p>Because you've downloaded the command line tools (not Android Studio), there are no install instructions.</blockquote><p>First things first. The SDK can be easily found on the download page of the Android developer website. Hidden at the end of the page in a section named <em><a href=https://developer.android.com/studio/index.html#command-tools>Get just the command line tools</a></em>.<p>We download a <code>.zip</code> file, because it's to complicated to provide a tarball, and unzip it somewhere, preferably <code>~/.android</code>.<p>Then we update your <code>~/.profile</code>, or wherever we put your env to include the following lines <em>mutatis mutandis</em> and reload our session.<div class=sourceCode><pre class="sourceCode bash"><code class="sourceCode bash"><span class=bu>export</span> <span class=va>ANDROID_HOME=</span><span class=st>"</span><span class=va>$HOME</span><span class=st>/.android"</span>
<!DOCTYPE html><meta charset=utf-8><title>make index.html</title><meta content="" name=description><meta content="" name=author><meta content="" name=keywords><meta content="width=device-width,initial-scale=1" name=viewport><style>h1,h2,h3,h4,h5,h6{color:#494e6b}a,html{color:#98878f}html{color:#bbb;background:html;text-align:justify;hyphens:auto;font-family:Georgia,serif;hyphens:auto;text-rendering:optimizeLegibility}h1,h2,h3,h4,h5,h6{text-align:left;font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif}p{text-indent:1em}code,h1+p,h2+p,h3+p{text-indent:0}blockquote>p{text-indent:-.5em}blockquote>p:before{content:'“'}blockquote>p:after{content:'”'}code>span.st{color:#b1d631}code,pre{font-family:"Lucida Console",Monaco,courier,monospace}blockquote{font-style:italic}</style><h1 id=android-headless-sdk-installation>Android <em>headless</em> SDK installation</h1><p>I wanted to install <em>Android SDK</em> without installing this ugly IDE. The main goal was to rebuild existing projects, so I didn't need something as heavy. The main difficulty came when I downloaded the actual sdk, and receive the following message from Google.<blockquote><p>Because you've downloaded the command line tools (not Android Studio), there are no install instructions.</blockquote><p>First things first. The SDK can be easily found on the download page of the Android developer website. Hidden at the end of the page in a section named <em><a href=https://developer.android.com/studio/index.html#command-tools>Get just the command line tools</a></em>.<p>We download a <code>.zip</code> file, because it's to complicated to provide a tarball, and unzip it somewhere, preferably <code>~/.android</code>.<p>Then we update your <code>~/.profile</code>, or wherever we put your env to include the following lines <em>mutatis mutandis</em> and reload our session.<div class=sourceCode><pre class="sourceCode bash"><code class="sourceCode bash"><span class=bu>export</span> <span class=va>ANDROID_HOME=</span><span class=st>"</span><span class=va>$HOME</span><span class=st>/.android"</span>
<span class=bu>export</span> <span class=va>PATH=</span><span class=st>"</span><span class=va>$ANDROID_HOME</span><span class=st>/tools:</span><span class=va>$ANDROID_HOME</span><span class=st>/tools/bin:</span><span class=va>$ANDROID_HOME</span><span class=st>/platform-tools:</span><span class=va>$PATH</span><span class=st>"</span></code></pre></div><p>Once we're here, the installation is straightforward once we now which command to run.<div class=sourceCode><pre class="sourceCode bash"><code class="sourceCode bash"><span class=ex>android</span> update sdk</code></pre></div><p>Then we must install some build tools.<div class=sourceCode><pre class="sourceCode bash"><code class="sourceCode bash"><span class=ex>sdkmanager</span> <span class=st>"platforms;android-23"</span>
<span class=ex>sdkmanager</span> <span class=st>"build-tools;23.0.1"</span></code></pre></div><p>And also we must not forget to install all those <code>compat</code> libraries.<div class=sourceCode><pre class="sourceCode bash"><code class="sourceCode bash"><span class=ex>sdkmanager</span> <span class=st>"extras;android;m2repository"</span></code></pre></div><p>And <em>voilà</em>!
2 changes: 1 addition & 1 deletion gadgetfs-ubuntu.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><meta charset=utf-8><title>make index.html</title><meta content="" name=description><meta content="" name=author><meta content="" name=keywords><meta content="width=device-width,initial-scale=1" name=viewport><h1 id=using-gadget-filesystem-under-ubuntu>Using <em>Gadget Filesystem</em> under <em>Ubuntu</em></h1><p>I wanted to emulate a USB device in Linux for testing purpose. This can be done easily using the <a href=http://www.linux-usb.org/gadget/ >Gadget API</a>. However I quickly discovered that this feature was <a href=https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1073089>not present in Ubuntu</a>, even in the form of a kernel module in <em>linux-extra</em>. The only solution remaining was to rebuild the missing kernel module manually.<p>The main issue with a Linux kernel is that both the API and the ABI are not stable, meaning:<ul><li>You can't use any source version of the module. The kernel API is evolving and you are likely to miss new or deprecated API. The current version of the <em>dummy_hcd</em> module does not compile due to newly introduced APIs. The matching kernel source is available in the <em>linux-extra</em> package.<li>You can't keep a module you built for one version to another version. You must always rebuilt your module to match the current kernel ABI. Ideally the module must be known from <em>modprobe</em> to be correctly loaded along its dependencies. This is solved by using <em><a href=https://github.com/dell/dkms>DKMS</a></em>.</ul><p>Now the proces was fairly simple.<ol type=1><li>Install the package <code>linux-source</code> to have the kernel sources matching the currently installed kernel.</ol><p>This part is fairly easy.<div class=sourceCode><pre class="sourceCode sh"><code class="sourceCode bash"><span class=fu>sudo</span> aptitude install linux-source</code></pre></div><ol type=1 start=2><li>Setup a build process that would extract the source of the <code>dummy_hcd</code> kmod from these sources and,</ol><p>For a Makefile, you can retrieve the current version of the kernel from <code>uname</code> plus some <code>grep</code>.<div class=sourceCode><pre class="sourceCode makefile"><code class="sourceCode makefile"><span class=dt>SVERSION </span><span class=ch>:=</span><span class=st> </span><span class=ch>$(</span><span class=kw>shell</span><span class=st> uname -r | grep -o "^[^-]*"</span><span class=ch>)</span></code></pre></div><p>Then extract and move the <code>dummy_hcd.c</code> file from the current kernel source to the current folder.<div class=sourceCode><pre class="sourceCode makefile"><code class="sourceCode makefile"><span class=dv>dummy_hcd.c:</span><span class=dt> /usr/src/linux-source-</span><span class=ch>$(</span><span class=dt>SVERSION</span><span class=ch>)</span><span class=dt>/linux-source-</span><span class=ch>$(</span><span class=dt>SVERSION</span><span class=ch>)</span><span class=dt>.tar.bz2</span>
<!DOCTYPE html><meta charset=utf-8><title>make index.html</title><meta content="" name=description><meta content="" name=author><meta content="" name=keywords><meta content="width=device-width,initial-scale=1" name=viewport><style>h1,h2,h3,h4,h5,h6{color:#494e6b}a,html{color:#98878f}html{color:#bbb;background:html;text-align:justify;hyphens:auto;font-family:Georgia,serif;hyphens:auto;text-rendering:optimizeLegibility}h1,h2,h3,h4,h5,h6{text-align:left;font-family:"Lucida Sans Unicode","Lucida Grande",sans-serif}p{text-indent:1em}code,h1+p,h2+p,h3+p{text-indent:0}ul>li{list-style:none}ul>li:before{content:'– '}ol{list-style-type:none}ol:first-of-type{counter-reset:listitem}li:before{display:inline-block;content:counter(listitem) '. ';counter-increment:listitem}ol ol:first-of-type{counter-reset:sublistitem}ol ol li:before{content:counter(listitem) '.' counter(sublistitem) '. ';counter-increment:true;display:block;background:#000;color:#eee;line-height:1.5;border-radius:5px;padding:5px;white-space:pre;overflow-x:auto}code>span.dv{color:#9fd3e6}code>span.ch,code>span.st{color:#b1d631}code>span.dt,code>span.kw{color:#bfa}code,pre{font-family:"Lucida Console",Monaco,courier,monospace}</style><h1 id=using-gadget-filesystem-under-ubuntu>Using <em>Gadget Filesystem</em> under <em>Ubuntu</em></h1><p>I wanted to emulate a USB device in Linux for testing purpose. This can be done easily using the <a href=http://www.linux-usb.org/gadget/ >Gadget API</a>. However I quickly discovered that this feature was <a href=https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1073089>not present in Ubuntu</a>, even in the form of a kernel module in <em>linux-extra</em>. The only solution remaining was to rebuild the missing kernel module manually.<p>The main issue with a Linux kernel is that both the API and the ABI are not stable, meaning:<ul><li>You can't use any source version of the module. The kernel API is evolving and you are likely to miss new or deprecated API. The current version of the <em>dummy_hcd</em> module does not compile due to newly introduced APIs. The matching kernel source is available in the <em>linux-extra</em> package.<li>You can't keep a module you built for one version to another version. You must always rebuilt your module to match the current kernel ABI. Ideally the module must be known from <em>modprobe</em> to be correctly loaded along its dependencies. This is solved by using <em><a href=https://github.com/dell/dkms>DKMS</a></em>.</ul><p>Now the proces was fairly simple.<ol type=1><li>Install the package <code>linux-source</code> to have the kernel sources matching the currently installed kernel.</ol><p>This part is fairly easy.<div class=sourceCode><pre class="sourceCode sh"><code class="sourceCode bash"><span class=fu>sudo</span> aptitude install linux-source</code></pre></div><ol type=1 start=2><li>Setup a build process that would extract the source of the <code>dummy_hcd</code> kmod from these sources and,</ol><p>For a Makefile, you can retrieve the current version of the kernel from <code>uname</code> plus some <code>grep</code>.<div class=sourceCode><pre class="sourceCode makefile"><code class="sourceCode makefile"><span class=dt>SVERSION </span><span class=ch>:=</span><span class=st> </span><span class=ch>$(</span><span class=kw>shell</span><span class=st> uname -r | grep -o "^[^-]*"</span><span class=ch>)</span></code></pre></div><p>Then extract and move the <code>dummy_hcd.c</code> file from the current kernel source to the current folder.<div class=sourceCode><pre class="sourceCode makefile"><code class="sourceCode makefile"><span class=dv>dummy_hcd.c:</span><span class=dt> /usr/src/linux-source-</span><span class=ch>$(</span><span class=dt>SVERSION</span><span class=ch>)</span><span class=dt>/linux-source-</span><span class=ch>$(</span><span class=dt>SVERSION</span><span class=ch>)</span><span class=dt>.tar.bz2</span>
tar -xjvf <span class=ch>$^</span> linux-source-<span class=ch>$(</span><span class=dt>SVERSION</span><span class=ch>)</span>/drivers/usb/gadget/udc/dummy_hcd.c &&\
cp linux-source-<span class=ch>$(</span><span class=dt>SVERSION</span><span class=ch>)</span>/drivers/usb/gadget/udc/dummy_hcd.c <span class=ch>$@</span></code></pre></div><ol type=1 start=3><li>Build the kmod using the kernel Makefile.</ol><p>Following the basic example found in the documentation.<div class=sourceCode><pre class="sourceCode makefile"><code class="sourceCode makefile"><span class=dt>obj-m </span><span class=ch>:=</span><span class=st> dummy_hcd.o</span>
<span class=dt>KVERSION </span><span class=ch>:=</span><span class=st> </span><span class=ch>$(</span><span class=kw>shell</span><span class=st> uname -r</span><span class=ch>)</span>
Expand Down
Loading

0 comments on commit 6e4e3ed

Please sign in to comment.