Commit fd2b4329 authored by Mohammed Sadiq's avatar Mohammed Sadiq
Browse files

Add new website

parent f86627ad
image: alpine:latest
image: iquiw/alpine-emacs
pages:
stage: deploy
only:
- master
script:
- echo 'Nothing to do...'
- emacs --batch -q -l src/htmlize.el -l src/my-web.el -f org-publish-all
- ./src/blog-atom.sh
artifacts:
paths:
- public
only:
- master
#!/bin/sh
# Generate atom feed from org-mode files.
# Written in 2018 by Mohammed Sadiq <sadiq@sadiqpk.org>
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any
# warranty.
# You should have received a copy of the CC0 Public Domain Dedication
# along with this software. If not, see
# <https://creativecommons.org/publicdomain/zero/1.0/>.
AUTHOR="Mohammed Sadiq"
URL="https://www.sadiqpk.org"
DIRECTORY="blog"
files=$(find src/blog/ -iname '*.org')
cat << EOF > ${DIRECTORY}.xml
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>${AUTHOR}'s blog</title>
<link href="$URL/"/>
<updated>$(date -Iseconds)</updated>
<author>
<name>$AUTHOR</name>
</author>
<id>$URL/$DIRECTORY/</id>
EOF
get_updated_date ()
{
file="$1"
UPDATED=$(grep "^#+updated:" -i "$file")
# If the org file contain "#+updated" field, use that.
# Else use the file modification date
if [ "$UPDATED" ]; then
# Remove org specific formatting characters
UPDATED=${UPDATED#*<}
UPDATED=${UPDATED%>}
# Remove Day name like "Mon", "Tue", etc.
UPDATED=$(echo "$UPDATED" | sed 's/[A-Z][a-z]*//')
date -Iseconds -d "$UPDATED"
else
date -Iseconds -r "$file"
fi
}
get_file_content ()
{
html_file="$1"
if [ ! -e "$html_file" ]; then
return
fi
CONTENT=$(awk '/="content/,/="postamble/' "$html_file")
CONTENT=$(echo "$CONTENT" | sed -n '/="title"/!p')
CONTENT=$(echo "$CONTENT" | sed -n '/="postamble"/!p')
echo "$CONTENT"
}
for file in $files
do
TITLE=$(grep "^#+title:" -i "$file")
TITLE=${TITLE#*:}
UPDATED=$(get_updated_date "$file")
FILE_URL="${file#src/}"
FILE_URL="${FILE_URL%.org}.html"
CONTENT=$(get_file_content "public/$FILE_URL")
if [ -z "$CONTENT" ]; then
continue
fi
cat << EOF >> ${DIRECTORY}.xml
<entry>
<title>$TITLE</title>
<link href="${FILE_URL#blog/}"/>
<id>$URL/$FILE_URL</id>
<updated>$UPDATED</updated>
<content type="html"><![CDATA[$CONTENT]]></content>
</entry>
EOF
done
# Close the open feed tag
echo "</feed>" >> ${DIRECTORY}.xml
# Publish the generated xml
mv ${DIRECTORY}.xml public/
#+title: Hello World
#+date: <2018-08-08 Mon>
#+updated: <2018-08-08 Mon>
#+setupfile: ../../../../include/post.org
#+keywords: org-mode, emacs, hello-world
#+description: Hello world blog
{{{info(Note:, This is a demo page to test the features of this blog.
Don’t expect much here.)}}}
In the software world, everything begins with ~Hello World~. This is
the beginning of my blog. Let’s see how this will go. This page stands
to test the features of this blog.
This website has been completely designed using GNU Emacs. The static
web pages are written in Emacs org-mode and exported to HTML.
If you are not yet a [[https://www.gnu.org/software/emacs/][GNU Emacs]] user, give it a try. It’s worth learning.
If you are familiar with vim, see [[http://spacemacs.org][Spacemacs]]. You shall feel home.
To begin with, let’s see how code blocks in different language be handled.
This should be pretty smooth, and cool .
* ~Hello World~
How about showing some real content? Have a look at a few
examples below.
** C Programming
Let’s begin with ~Hello World~ in C Programming.
#+include: "../../../../code/c/hello.c" src c
Save the above code into ~hello.c~, then compile and run.
#+begin_src sh
# Compile and run
gcc hello.c -o hello && ./hello
# An alternate way for the same. If you are
# wondering, no, you don't need any Makefile.
make hello && ./hello
#+end_src
** Emacs lisp
Now let’s try this in elisp. The code below will print “Hello World!”
to the echo area. To run the program, write the code in GNU Emacs,
put the cursor at end of the paren and press {{{key(C-x C-e)}}} .
#+begin_src elisp
(message "Hello World!")
;; Put the cursor here ^
#+end_src
#+title: Archives
#+setupfile: ../include/common.org
#+todo: TODO(t) IN-PROGRESS(i) | DONE(d)
#+startup: overview hidestars
#+options: title:t
#+export_file_name: index
#+options: html-style:nil html-scripts:nil
#+html_head: <link href="../css/site.css" rel="stylesheet">
#+macro:link @@html:<div class="post-title"><div class="date">$3-$4-$5</div><div class="ptitle"><a href="$3/$4/$5/$2.html">$1</a></div></div>@@
# TODO: This should be made simple, but how?
{{{link(Hello World,hello-world,2018,08,08)}}}
#include <stdio.h>
int
main (void)
{
printf ("Hello World!\n");
/* Implicit in c99+ */
return 0;
}
all: site
site: site.scss
sassc --style expanded site.scss ../../public/css/site.css
diary: site diary.scss
sassc --style expanded diary.scss diary.css
clean:
rm -rf site.css diary.css
// -*- mode: scss; indent-tabs-mode: nil; css-indent-offset: 2 -*-
// Written in 2017 by Mohammed Sadiq <www.sadiqpk.org>
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
// You should have received a copy of the CC0 Public Domain Dedication
// along with this software. If not, see
// <http://creativecommons.org/publicdomain/zero/1.0/>.
// check if $var is prefixed with $string.
@function string-prefix-p ($var, $string) {
@if type-of($string) != 'string' {
@return false;
}
$length: str-length($string);
@if str-length($var) < str-length($string) {
@return false;
}
@if str-slice($var, 0, $length) == $string {
@return true;
}
@return false;
}
// -*- mode: scss; indent-tabs-mode: nil; css-indent-offset: 2 -*-
// Written in 2017 by Mohammed Sadiq <www.sadiqpk.org>
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
// You should have received a copy of the CC0 Public Domain Dedication
// along with this software. If not, see
// <http://creativecommons.org/publicdomain/zero/1.0/>.
@mixin new-color($color, $value) {
.#{$color} {
color: $value;
}
.#{$color}-bg {
background-color: $value;
}
}
@mixin font($family, $path, $style, $weight, $alt-name1, $alt-name2: '') {
@font-face {
font: {
family: $family;
style: $style;
weight: $weight;
}
@if $alt-name2== ''{
src: local("#{$alt-name1}");
} @else {
src: local("#{$alt-name1}"), local("#{$alt-name2}");
}
src: url('#{$path}.woff2') format('woff2'),
url('#{$path}.woff') format('woff'),
url('#{$path}.ttf') format('truetype');
}
}
@mixin before($class, $content) {
.#{$class}:before {
content: "#{$content}";
}
}
@mixin vendorize($map, $vendors: webkit moz ms o) {
@each $property, $value in $map {
@each $vendor in $vendors {
#{"-" + $vendor + "-" + $property}: #{$value};
}
#{$property}: #{$value};
}
}
@mixin no-select(){
-webkit-touch-callout: none;
@include vendorize((user-select: none));
}
@mixin box-shadow($value...){
-webkit-box-shadow: $value;
box-shadow: $value;
}
// -*- mode: scss; indent-tabs-mode: nil; css-indent-offset: 2 -*-
// Written in 2017 by Mohammed Sadiq <www.sadiqpk.org>
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
// You should have received a copy of the CC0 Public Domain Dedication
// along with this software. If not, see
// <http://creativecommons.org/publicdomain/zero/1.0/>.
// -*- mode: scss; indent-tabs-mode: nil; css-indent-offset: 2 -*-
// Written in 2017 by Mohammed Sadiq <www.sadiqpk.org>
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
// You should have received a copy of the CC0 Public Domain Dedication
// along with this software. If not, see
// <http://creativecommons.org/publicdomain/zero/1.0/>.
// Media breakpoints
// It is a Programmer error to not set this.
$breakpoints: (
'very-small': 'screen and (max-width: 35em)',
'small': 'screen and (max-width: 49em)',
'medium': 'screen and (max-width: 62.5em)',
'large': 'screen and (min-width: 62.5em)',
) !default;
// Fonts
$font-text: ('Roboto', 'FontAwesome', 'Rachana', 'Arial', sans-serif) !default;
// I may write Malayalam comments
$font-code: ('Ubuntu Mono', 'FontAwesome', 'Monaco', 'Rachana', monospace) !default;
$font-default-weight: 400;
// Colors
$color-blue: #2196f3 !default;
$color-llblue: #e3f2fd !default;
$color-green: #4caf50 !default;
$color-red: #f44336 !default;
$color-orange: #ff9800 !default;
$color-llorange: #fff3e0 !default;
$color-pink: #e91e63 !default;
$color-white: #fff !default;
$color-text-dark: #333 !default;
$color-text-medium: #555 !default;
$color-text-light: #666 !default;
$color-bg-selected: $color-blue !default;
$color-hr-bg: #ccc !default;
$color-head: #333 !default;
$color-h1: #eee !default;
$color-h2: #eee !default;
$color-h3: #eee !default;
$color-h4: #eee !default;
$color-code-bg: #fff !default;
$color-code-text: #333 !default;
$color-code-border: #eee !default;
$color-nav-text: #333 !default;
$color-nav-bg: #fff !default;
$color-nav-bg-secondary: #fff !default;
$color-body-bg: #fff !default;
$color-body-text: #000 !default;
$color-footer-bg: #fff !default;
$color-footer-text: #333 !default;
// -*- mode: scss; indent-tabs-mode: nil; css-indent-offset: 2 -*-
// Written in 2017 by Mohammed Sadiq <www.sadiqpk.org>
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
// You should have received a copy of the CC0 Public Domain Dedication
// along with this software. If not, see
// <http://creativecommons.org/publicdomain/zero/1.0/>.
@include new-color('blue', $color-blue);
@include new-color('green', $color-green);
@include new-color('pink', $color-pink);
@include new-color('red', $color-red);
@include new-color('orange', $color-orange);
// -*- mode: scss; indent-tabs-mode: nil; css-indent-offset: 2 -*-
// http://meyerweb.com/eric/tools/css/reset/
// v2.0 | 20110126
// License: none (public domain)
// XXX: eventually more items will be added. Using only the bare
// minimum.
@mixin reset
{
// html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6,
// p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del,
// dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup,
// tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label,
// legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside,
// canvas, details, embed, figure, figcaption, footer, header, hgroup,
// menu, nav, output, ruby, section, summary, time, mark, audio, video {
// }
html, body, div, span, ol, ul {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
// HTML5 display-role reset for older browsers
// article, aside, details, figcaption, figure, footer, header, hgroup,
// menu, nav, section {
// display: block;
// }
// body {
// line-height: 1;
// }
// ol, ul {
// list-style: none;
// }
// blockquote, q {
// quotes: none;
// }
// blockquote {
// &:before, &:after {
// content: "";
// content: none;
// }
// }
// q {
// &:before, &:after {
// content: "";
// content: none;
// }
// }
// table {
// border-collapse: collapse;
// border-spacing: 0;
// }
}
@include reset;
// -*- mode: scss; indent-tabs-mode: nil; css-indent-offset: 2 -*-
// Written in 2017 by Mohammed Sadiq <www.sadiqpk.org>
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
// You should have received a copy of the CC0 Public Domain Dedication
// along with this software. If not, see
// <http://creativecommons.org/publicdomain/zero/1.0/>.
@include font('Roboto', '../fonts/roboto-italic', italic, 400, 'Roboto Italic', 'Roboto-Italic');
@include font('Roboto', '../fonts/roboto-medium', normal, 500, 'Roboto Medium', 'Roboto-Medium');
@include font('Roboto', '../fonts/roboto-regular', normal, 400, 'Roboto', 'Roboto-Regular');
@include font('Rachana', '../fonts/rachana-regular', normal, 400, 'Rachana');
@include font('FontAwesome', '../fonts/fontawesome', normal, 400, 'FontAwesome');
@include font('Ubuntu Mono', '../fonts/ubuntumono-b', normal, 600, 'Ubuntu Mono Bold', 'UbuntuMono-Bold');
@include font('Ubuntu Mono', '../fonts/ubuntumono-ri', italic, 400, 'Ubuntu Mono Italic', 'UbuntuMono-Italic');
@include font('Ubuntu Mono', '../fonts/ubuntumono-r', normal, 400, 'Ubuntu Mono', 'UbuntuMono-Regular');
body {
font: {
family: $font-text;
size: 1.7em;
}
color: $color-text-dark;
}
// -*- mode: scss; indent-tabs-mode: nil; css-indent-offset: 2 -*-
// Written in 2017 by Mohammed Sadiq <www.sadiqpk.org>
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
// You should have received a copy of the CC0 Public Domain Dedication
// along with this software. If not, see
// <http://creativecommons.org/publicdomain/zero/1.0/>.
#content .post-title {
font-size: 1em;
display: table-row;
.ptitle {
display: table-cell;
padding-bottom: 1em;
}
.date {
display: table-cell;
color: #777;
padding-right: 2.5em;
}
a {@include box-shadow(0 0px $color-blue);}
a:hover {
color: #111;
@include box-shadow(0 5px $color-blue);
}
}
// -*- mode: scss; indent-tabs-mode: nil; css-indent-offset: 2 -*-
// Written in 2017 by Mohammed Sadiq <www.sadiqpk.org>
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
// You should have received a copy of the CC0 Public Domain Dedication
// along with this software. If not, see
// <http://creativecommons.org/publicdomain/zero/1.0/>.
body {
font-size: 1.4em;
}
@mixin body-sm() {
body {
font-size: 1.1em;
}
}
@mixin body-md() {
body {
font-size: 1.4em;
}
}
// -*- mode: scss; indent-tabs-mode: nil; css-indent-offset: 2 -*-
// Written in 2017 by Mohammed Sadiq <www.sadiqpk.org>
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
// You should have received a copy of the CC0 Public Domain Dedication
// along with this software. If not, see
// <http://creativecommons.org/publicdomain/zero/1.0/>.
code {
font-family: $font-code;
color: $color-pink;
font-size: 1.0em;
}
pre {
font-family: $font-code;
color: $color-white;
overflow: auto;
padding: 16px;
line-height: 1.3;
border-radius: 8px;
margin-left: -7%;
margin-right: -7%;