Commits

Shlomi Fish  committed 0549a37

Intermediate commit in the conversion to TT2.

I don't like Jekyll because I think it's too opaque so I'm converting to
a custom static site generator based on Template Toolkit 2.

  • Participants
  • Parent commits 78ec383
  • Branches convert-to-template-toolkit-2

Comments (0)

Files changed (4)

File vim-begin/jekyll-prototype/Makefile

 SCREENSHOTS_PNGS = src/screenshots/images/romainl-macvim1.png src/screenshots/images/romainl-macvim2.png src/screenshots/images/gvim-perl-256.png
 SCREENSHOTS_PNGS_PREVIEWS = $(patsubst %.png,%-preview.png,$(SCREENSHOTS_PNGS))
 
-all: $(GENERATED_HTMLS) $(GENERATED_CSS)
-
-$(GENERATED_HTMLS) : $(SOURCES) $(SCREENSHOTS_PNGS_PREVIEWS)
-	jekyll
-
 $(SCREENSHOTS_PNGS_PREVIEWS): %-preview.png: %.png
 	convert $< -resize 400 $@
 
-$(GENERATED_CSS) : sass/jqui-override.sass sass/style.sass sass/print.sass sass/vim_syntax_highlighting.sass
-	compass compile
-	mkdir -p _site/css
-	cp -f src/css/*.css _site/css
+D = dest
 
 RSYNC = rsync --progress --verbose --rsh=ssh
 
+RSYNC_EXTRA_OPTS =
+
+DESTS = $(D)/index.html
+HTACCESS_DEST = $(D)/.htaccess
+
+UPLOAD_URL = hostgator:public_html/temp-www.linux.org.il-new-site/
+
+all: $(GENERATED_CSS) $(DESTS) $(HTACCESS_DEST) $(SCREENSHOTS_PNGS_PREVIEWS)
+
+$(DESTS): dest/%.html: src/%.html.tt2 footer.tt2 blocks.tt2
+	perl process.pl
+
+$(HTACCESS_DEST): htaccess.conf
+	cp -f $< $@
+
+$(GENERATED_CSS) : sass/jqui-override.sass sass/style.sass sass/print.sass sass/vim_syntax_highlighting.sass
+	compass compile
+	mkdir -p dest/css
+	cp -f src/css/*.css dest/css
+
 upload: all
-	$(RSYNC) -a ./_site/* ./_site/.htaccess hostgator:domains/vim.begin-site.org/
+	$(RSYNC) --exclude='**~' --exclude='**/.*.swp' $(RSYNC_EXTRA_OPTS) dest/ $(UPLOAD_URL)

File vim-begin/jekyll-prototype/blocks.tt2

+[%- BLOCK block_before -%]
+<table border="0" class="wrap" summary="wrapper table">
+<tr>
+<td>
+[%- END -%]
+
+[%- BLOCK block_after -%]
+</td>
+</tr>
+</table>
+[%- END -%]
+
+[%- BLOCK link_to_top -%]
+<p class="to_top"><a href="http://mikmod.shlomifish.org/">Back to the MikMod Homepage</a></p>
+[%- END -%]
+
+[%- BLOCK start_html -%]
+
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
+<head>
+   <title>[% title %] (Vim Beginners’ Site)</title>
+   <meta charset="UTF-8" />
+   <base href="http://vim.begin-site.org/" />
+   <meta name="author" content="Shlomi Fish" />
+   <link href="http://feeds.feedburner.com/tom-preston-werner" rel="alternate" title="Tom Preston-Werner" type="application/atom+xml" />
+
+   <!-- syntax highlighting CSS -->
+   <link rel="stylesheet" href="css/syntax.css" type="text/css" />
+
+   <!-- Homepage CSS -->
+   <link rel="stylesheet" href="css/style.css" type="text/css" media="screen, projection" />
+
+   <!-- Print CSS -->
+<link rel="stylesheet" href="css/print.css" type="text/css" media="print" />
+<script type="text/javascript" src="js/jq.js"></script>
+<script type="text/javascript" src="js/position_divs.js"></script>
+<!-- Typekit -->
+</head>
+<body>
+
+<a href="http://bitbucket.org/shlomif/vim-begin"><img src="images/fork-me-on-bitbucket.png" class="fork_me" alt="Fork me on BitBucket" /></a>
+
+<!-- HEADER -->
+<!-- Global Navigation -->
+<div id='header'>
+<!-- Sitename and Banner -->
+<div class="site-name" id="js-site-name">
+<h1><a href="">Vim Beginners' Site</a></h1>
+</div>
+<div class="site-slogan" id="js-site-slogan">
+Vim - type less ; edit more.
+</div>
+</div>
+
+<div id="page-container">
+
+<div class="nav-main">
+<h3 class="hide">Breadcrumbs Trail</h3>
+<p class="breadcrumbs">
+<a href="">Vim Beginner’s Site</a>
+→
+<a class="extra" href="">Home</a>
+</p>
+
+<h3 class="hide">Global Navigation</h3>
+
+<ul class="about-links">
+
+<li><a href="about.html">About Us</a></li>
+
+<li><a href="contact/">Contact</a></li>
+
+</ul>
+
+</div>
+
+<h3 class="hide">Main Navigation</h3>
+<div id="left-sidebar">
+
+<a href=""><img class="logo" src="images/vim-begin.png"
+    alt="Vim Begin Logo" /></a>
+
+<div id="main_nav_menu">
+<ul class="navbarmain">
+<li>
+<a href="">Home</a>
+</li>
+<li>
+<a href="about.html">About</a>
+</li>
+<li>
+<a href="news/" title="Previous News Item">News</a>
+</li>
+<li>
+<a href="screenshots/" title="Screenshots of Vim in Action">Screenshots</a>
+</li>
+<li>
+<a href="links/" title="External Links to Other Resources">Links</a>
+</li>
+<li>
+<a href="humour/" title="Vim Humour and Links to Vim Humour resources">Vim Humour</a>
+</li>
+</ul>
+<h2>
+<a href="learn/" title="Why and how to learn Vim?">Learn Vim Now</a>
+</h2>
+<h2>
+<a href="resources/" title="Links to Online and Offline Resources for Learning Vim">Resources</a>
+</h2>
+<ul class="navbarnested">
+<li>
+<a href="tutorials/">Online Tutorials</a>
+</li>
+<li>
+<a href="books/">Books</a>
+</li>
+<li>
+<a href="core-doc/">Core Docs</a>
+</li>
+<li>
+<a href="articles/">Article Collections</a>
+</li>
+<li>
+<a href="training/" title="Take paid courses for learning Vim">Training</a>
+</li>
+<li>
+<a href="FAQs/" title="Lists of Frequently Asked Questions with Answers">FAQs</a>
+</li>
+<li>
+<a href="exercises/" title="Links to Exercises and Challenges for Practice">Exercises and Challenges</a>
+</li>
+<li>
+<a href="games/" title="Games you can play in order to learn Vim">Games</a>
+</li>
+</ul>
+<ul class="navbarmain">
+<li>
+<a href="mailing-lists/" title="Ask questions and receive answers about Vim by E-mail">Mailing Lists</a>
+</li>
+<li>
+<a href="web-forums/" title="Ask questions and receive answers by using a web-browser">Web Forums</a>
+</li>
+<li>
+<a href="irc/" title="Chat online about Vim using the Internet Relay Chat (IRC)">IRC Channels</a>
+</li>
+</ul>
+<ul class="navbarmain">
+<li>
+<a href="reference-resources/" title="Resources for reference about Vim and looking up information.">Reference Resources</a>
+</li>
+<li>
+<a href="wikis/" title="Publicly editable sites with Lots of Useful Information">Wikis</a>
+</li>
+<li>
+<a href="blogs/" title="Links to some Vim-related Blogs (a.k.a &quot;Weblogs&quot; or online journals)">Blogs</a>
+</li>
+</ul>
+<h2>
+<a href="platforms/">Platforms</a>
+</h2>
+<h2>
+<a href="contribute/" title="Contribute new content or corrections to this site">Contribute</a>
+</h2>
+<ul class="navbarmain">
+<li>
+<a href="contribute/list/">Contributors List</a>
+</li>
+<li>
+<a href="source/">Site’s Source Code</a>
+</li>
+</ul>
+
+</div>
+
+
+</div>
+
+<h3 class="hide">Content</h3>
+<div id="content">
+
+<h1>[% title %]</h1>
+
+[%- END -%]
+
+[%-# vim:ft=tt2html:
+-%]

File vim-begin/jekyll-prototype/footer.tt2

+<p class="share_this">
+<a href="http://www.addtoany.com/share_save"><img src="http://static.addtoany.com/buttons/share_save_171_16.png" width="171" height="16" class="bless" alt="Share/Bookmark" /></a>
+</p>
+
+</div>
+
+<h3 class="hide">Sidebar</h3>
+<div id="right-sidebar">
+<div class="testimonials">
+<h2>Testimonials</h2>
+<b>TODO : Add more</b>
+<p>
+<a href="learn/who-is-using/">More…</a>
+</p>
+</div>
+<div class="news-box">
+<h2><a href="news/">News</a></h2>
+<ul>
+<li>
+<a href="news/">More news…</a>
+</li>
+</ul>
+</div>
+</div>
+</div>
+
+
+<!-- FOOTER -->
+<h3 class="hide">Footer</h3>
+<div id="footer">
+<!-- Creative Commons License -->
+Unless noted otherwise, the Vim Beginners’s Site is <b>licensed</b> under
+the <a rel="license"
+href="http://creativecommons.org/licenses/by/3.0/">Creative Commons
+Attribution 3.0 Unported License</a> (or at your option any later
+version).<br />
+<!-- /Creative Commons License -->
+<!--
+<rdf:RDF xmlns="http://web.resource.org/cc/"
+xmlns:dc="http://purl.org/dc/elements/1.1/"
+xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+<Work rdf:about="">
+<dc:title>Better SCM Site Contents</dc:title>
+<dc:date>2004</dc:date>
+<dc:description>A Version Control Systems Information and Advocacy carrying site</dc:description>
+<dc:creator><Agent>
+  <dc:title>Shlomi Fish</dc:title>
+</Agent></dc:creator>
+<dc:rights><Agent>
+  <dc:title>Shlomi Fish</dc:title>
+</Agent></dc:rights>
+<dc:type rdf:resource="http://purl.org/dc/dcmitype/Text" />
+<license rdf:resource="http://creativecommons.org/licenses/by/2.0/" />
+</Work>
+<License rdf:about="http://creativecommons.org/licenses/by/2.0/">
+<permits rdf:resource="http://web.resource.org/cc/Reproduction" />
+<permits rdf:resource="http://web.resource.org/cc/Distribution" />
+<requires rdf:resource="http://web.resource.org/cc/Notice" />
+<requires rdf:resource="http://web.resource.org/cc/Attribution" />
+<permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+</License>
+</rdf:RDF>
+-->
+<b>Webmaster:</b> <a href="http://www.shlomifish.org/">Shlomi Fish</a> (<a href="mailto:shlomif@shlomifish.org">Email - shlomif@shlomifish.org</a>)<br />
+<b>Original Design:</b> <a href="http://www.oswd.org/design/preview/id/2933">GoFlexiblePro</a>
+| Author: <a href="mailto:gw@actamail.com">G. Wolfgang</a>
+| <a href="http://validator.w3.org/check?uri=referer" title="Validate code as W3C XHTML 1.1 Strict Compliant">W3C XHTML 5</a>
+| <a href="http://jigsaw.w3.org/css-validator/" title="Validate Style Sheet as W3C CSS 3.0 Compliant">W3C CSS 3.0</a>
+<br />
+<b>Hosted by:</b> <a href="http://hexten.net/">Hexten.net</a>.
+<script type="text/javascript" src="js/selfl.js"></script>
+</div>
+
+</body>
+</html>

File vim-begin/jekyll-prototype/process.pl

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Template;
+use File::Find::Object;
+
+use File::Path qw( mkpath );
+use File::Spec;
+use File::Copy qw( copy );
+
+my $template = Template->new(
+    {
+        INCLUDE_PATH => ".",
+        POST_CHOMP => 1,
+        RELATIVE => 1,
+        ENCODING => 'utf8',
+    }
+);
+
+my $vars = {};
+
+my $tree = File::Find::Object->new({}, './src');
+
+while (my $result = $tree->next_obj())
+{
+    if ($result->is_dir())
+    {
+        if ($result->path() eq './dest')
+        {
+            $tree->prune();
+        }
+        else
+        {
+            mkpath(File::Spec->catdir(
+                    File::Spec->curdir(), "dest", @{$result->full_components()}
+                )
+            );
+        }
+    }
+    else
+    {
+        my $basename = $result->basename;
+        if ($basename =~ s/\.html\.tt2\z/.html/)
+        {
+            $template->process($result->path(), $vars,
+                File::Spec->catfile(File::Spec->curdir(), "dest",
+                    @{$result->dir_components()}, $basename),
+                binmode => ':utf8',
+            )
+                or die $template->error();
+        }
+        elsif (
+            $basename !~ /~\z/
+            && ( !($basename =~ /\A\./ && $basename =~ /\.swp\z/) )
+            && ($basename ne 'process.pl')
+        )
+        {
+            copy($result->path,
+                File::Spec->catfile(File::Spec->curdir(), "dest",
+                    @{$result->dir_components()}, $basename),
+            );
+        }
+    }
+}