diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2014-10-26 18:22:18 +0100 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2014-10-26 19:28:39 +0100 |
| commit | 860b6b1dbe5a28b39b1f7ec56c3754b7b48d699a (patch) | |
| tree | bf4c3945fd5f4dc54173b6f4ce51acb28371694d | |
| parent | 1f037600f3bbc2e358134136ac6b0d24136adbd7 (diff) | |
| download | brentj.es-860b6b1dbe5a28b39b1f7ec56c3754b7b48d699a.tar.gz brentj.es-860b6b1dbe5a28b39b1f7ec56c3754b7b48d699a.tar.bz2 brentj.es-860b6b1dbe5a28b39b1f7ec56c3754b7b48d699a.zip | |
Finalizes the project page, and creates a post about it.develop
| -rw-r--r-- | Projects/hssb.markdown | 7 | ||||
| -rw-r--r-- | Projects/leakindexer.markdown | 3 | ||||
| -rw-r--r-- | _config.yml | 6 | ||||
| -rw-r--r-- | _posts/2014-10-14-Project-progress.markdown (renamed from _posts/2014-10-14-DMP-progress.markdown) | 0 | ||||
| -rw-r--r-- | _posts/2014-10-26-learning-how-to-jekyll.markdown | 83 |
5 files changed, 95 insertions, 4 deletions
diff --git a/Projects/hssb.markdown b/Projects/hssb.markdown index e69de29..cb5c11c 100644 --- a/Projects/hssb.markdown +++ b/Projects/hssb.markdown @@ -0,0 +1,7 @@ + +Small toy project that has all the sounds of the first generation cards of the digital collectible card game "Hearthstone: Heroes of Warcraft". I Scraped the [hearthhead][] site that hosts all the sounds on their page and extracted all the sound file links. I even built in caching and a download delay as not the overwhelm Hearthhead with requests when trying to download all the html and sound files. + +So here is the [soundboard][]. + +[soundboard]: http://brentj.es/dump/hsboard/board.php +[hearthhead]: http://www.hearthhead.com/ diff --git a/Projects/leakindexer.markdown b/Projects/leakindexer.markdown index 4f65cb7..da2b2fc 100644 --- a/Projects/leakindexer.markdown +++ b/Projects/leakindexer.markdown @@ -7,7 +7,7 @@ The security teacher was befriended with a research Journalist Huub Jasper. He wanted an easy way to search trough the Wikileaks documents that just got leaked at the time. So he asked our Security professor if he knew some students that might be interested. The following lecture he asked the whole lecture room who was interested and 5 people raised their hands. -Erik Boss, [Sjors Gielen], Rik Harink, Nick Overdijk and Dennis Brentjes (me). +Erik Boss, [Sjors Gielen][], Rik Harink, [Nick Overdijk][] and Dennis Brentjes (me). The project was pretty time intensive and I had to learn a lot and be quick on my feet as I was the least knowledgeable member of the group at the time. But in the long run this project was a fun and wonderful experience. @@ -41,5 +41,6 @@ Something we didn't find when looking for standard solution when we begun with t The logo was created by Erik Boss [Sjors Gielen]: http://sjorsgielen.nl/ +[Nick Overdijk]: http://astrant.net/ [VVOJ]: http://www.vvoj.nl/ [Legebeke Legaat 2011]: http://www.vvoj.nl/2011/10/24/programma-legebeke-legaat-2011/ diff --git a/_config.yml b/_config.yml index 976cfc4..40694e4 100644 --- a/_config.yml +++ b/_config.yml @@ -12,6 +12,6 @@ projects: - name: DMP file: dmp.markdown thumbnail: /assets/dmp.png - # - name: HS Soundboard - # file: hssb.markdown - # thumbnail: /assets/hssb.png + - name: HS Soundboard + file: hssb.markdown + thumbnail: /assets/hssb.png diff --git a/_posts/2014-10-14-DMP-progress.markdown b/_posts/2014-10-14-Project-progress.markdown index 5c9d8f9..5c9d8f9 100644 --- a/_posts/2014-10-14-DMP-progress.markdown +++ b/_posts/2014-10-14-Project-progress.markdown diff --git a/_posts/2014-10-26-learning-how-to-jekyll.markdown b/_posts/2014-10-26-learning-how-to-jekyll.markdown new file mode 100644 index 0000000..a76cb0e --- /dev/null +++ b/_posts/2014-10-26-learning-how-to-jekyll.markdown @@ -0,0 +1,83 @@ +--- +layout: post +title: "Learning how to Jekyll: the projects page." +date: "2014-10-26" +--- + +So I wanted to create a better projects page. One that generates itself and generates every project page from some kind of input. Enter the world of Jekyll generators. + +I first was a bit put off by the prospect of diving into ruby. But I really wanted a way to generate new project pages based on content and not handcraft each page. I also wanted to use markdown for this because It would then be similar to the posts. + +So first I define a list of associative arrays in my main config that define my projects. These associative arrays contain a name, a markdown file and a thumbnail to be used on the main projects page. This is all information I need to add in the config. + +But then I need to generate the project page itself. This is where the Jekyll plug-in system comes into play. This is my project page generator. + +``` +module Jekyll + + class ProjectPage < Page + def initialize(site, base, dir, project) + @site = site + @base = base + @dir = dir + @name = project['name'] + '.html' + + self.process(@name) + self.read_yaml(File.join(base, '_layouts'), 'project.html') + self.data['project_name'] = project['name'] + + self.data['file'] = project['file'] + end + end + + class ProjectGenerator < Generator + safe true + + def generate(site) + dir = site.config['projects_dir'] || 'Projects' + site.config['projects'].each do |project| + site.pages << ProjectPage.new(site, site.source, dir, project) + end + end + end +end +``` + +This creates the necessary html pages, but now I still need to be able to "include" files from my custom Project folder. So I created an liquid tag that does that. + +``` +module Jekyll + class InputProjectTag < Liquid::Tag + + def initialize(tag_name, text, tokens) + super + @text = text; + end + + def render(context) + site = context.environments.first['site'] + + #set your project dir. + dir = 'Projects' + if defined? site.projects_dir + dir = site.projects_dir + end + source = site['source'] + + #render the variable to the markdown filename + content = Liquid::Template.parse(@text).render(context.environments.first) + path = File.join(File.join(source, dir), content); + + input = IO.read(path.strip()) + + #render the markdown file with the variables of the project. + return Liquid::Template.parse(input).render(context) + + end + end +end + +Liquid::Template.register_tag('include_project', Jekyll::InputProjectTag) +``` + +The only downside of this is that with jekyll --watch new projects will not appear on the webpage, It seems the global config file is not watched, or maybe its something entirely different. I will look into this later down the line but for now I just wanted to share these modules. |
