Permalink
Browse files

Initial commit

  • Loading branch information...
arian committed Jan 26, 2013
0 parents commit 8edf1eaf08e1c4318492b0a358f09aaa005c9253
Showing with 2,216 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +3 −0 .gitmodules
  3. +79 −0 _config.yml
  4. +13 −0 package.json
  5. +3 −0 scaffolds/page.md
  6. +5 −0 scaffolds/photo.md
  7. +4 −0 scaffolds/post.md
  8. +51 −0 scripts/_index/_home/lib/GitHub.php
  9. +54 −0 scripts/_index/_home/lib/Template.php
  10. +51 −0 scripts/_index/_home/lib/Tweets.php
  11. +1 −0 scripts/_index/_home/lib/tmhOAuth
  12. +50 −0 scripts/_index/_home/templates/index.php
  13. +8 −0 scripts/_index/_home/twitterAPISecret.example.php
  14. +17 −0 scripts/_index/index.php
  15. +24 −0 scripts/index.js
  16. +38 −0 source/_posts/i-have-a-blog.md
  17. +7 −0 themes/light/LICENSE
  18. +114 −0 themes/light/README.md
  19. +29 −0 themes/light/_config.yml
  20. +11 −0 themes/light/languages/default.yml
  21. +11 −0 themes/light/languages/ru.yml
  22. +11 −0 themes/light/languages/zh-CN.yml
  23. +11 −0 themes/light/languages/zh-TW.yml
  24. +26 −0 themes/light/layout/_partial/after_footer.ejs
  25. +20 −0 themes/light/layout/_partial/archive.ejs
  26. +37 −0 themes/light/layout/_partial/article.ejs
  27. +18 −0 themes/light/layout/_partial/comment.ejs
  28. +7 −0 themes/light/layout/_partial/footer.ejs
  29. +13 −0 themes/light/layout/_partial/google_analytics.ejs
  30. +38 −0 themes/light/layout/_partial/head.ejs
  31. +8 −0 themes/light/layout/_partial/header.ejs
  32. +9 −0 themes/light/layout/_partial/pagination.ejs
  33. +11 −0 themes/light/layout/_partial/post/category.ejs
  34. +15 −0 themes/light/layout/_partial/post/gallery.ejs
  35. +18 −0 themes/light/layout/_partial/post/share.ejs
  36. +12 −0 themes/light/layout/_partial/post/tag.ejs
  37. +25 −0 themes/light/layout/_partial/post/title.ejs
  38. +3 −0 themes/light/layout/_partial/sidebar.ejs
  39. +10 −0 themes/light/layout/_widget/category.ejs
  40. +6 −0 themes/light/layout/_widget/search.ejs
  41. +10 −0 themes/light/layout/_widget/tag.ejs
  42. +8 −0 themes/light/layout/_widget/tagcloud.ejs
  43. +11 −0 themes/light/layout/_widget/twitter.ejs
  44. +5 −0 themes/light/layout/archive.ejs
  45. +5 −0 themes/light/layout/category.ejs
  46. +33 −0 themes/light/layout/default.ejs
  47. +7 −0 themes/light/layout/index.ejs
  48. +5 −0 themes/light/layout/page.ejs
  49. +5 −0 themes/light/layout/post.ejs
  50. +5 −0 themes/light/layout/tag.ejs
  51. +22 −0 themes/light/source/css/FontAwesome/css/font-awesome-ie7.min.css
  52. +540 −0 themes/light/source/css/FontAwesome/css/font-awesome.css
  53. +33 −0 themes/light/source/css/FontAwesome/css/font-awesome.min.css
  54. BIN themes/light/source/css/FontAwesome/font/FontAwesome.otf
  55. BIN themes/light/source/css/FontAwesome/font/fontawesome-webfont.eot
  56. +284 −0 themes/light/source/css/FontAwesome/font/fontawesome-webfont.svg
  57. BIN themes/light/source/css/FontAwesome/font/fontawesome-webfont.ttf
  58. BIN themes/light/source/css/FontAwesome/font/fontawesome-webfont.woff
  59. +38 −0 themes/light/source/css/_base/layout.styl
  60. 0 themes/light/source/css/_base/utils.styl
  61. 0 themes/light/source/css/_base/variable.styl
  62. +9 −0 themes/light/source/css/_partial/archive.styl
  63. +38 −0 themes/light/source/css/_partial/article.styl
  64. +3 −0 themes/light/source/css/_partial/comment.styl
  65. +7 −0 themes/light/source/css/_partial/footer.styl
  66. +39 −0 themes/light/source/css/_partial/header.styl
  67. +61 −0 themes/light/source/css/_partial/index.styl
  68. 0 themes/light/source/css/_partial/sidebar.styl
  69. +143 −0 themes/light/source/css/_partial/syntax.styl
  70. +13 −0 themes/light/source/css/style.styl
  71. +17 −0 watch.js
@@ -0,0 +1,4 @@
+.DS_Store
+node_modules
+.cache
+scripts/_index/_home/twitterAPISecret.php
@@ -0,0 +1,3 @@
+[submodule "scripts/_index/_home/lib/tmhOAuth"]
+ path = scripts/_index/_home/lib/tmhOAuth
+ url = git://github.com/themattharris/tmhOAuth.git
@@ -0,0 +1,79 @@
+# Hexo Configuration
+## Docs: http://zespia.tw/hexo/docs/configure.html
+## Source: https://github.com/tommy351/hexo/
+
+# Site
+title: Arian Stolwijk
+subtitle:
+description:
+author: Arian Stolwijk
+email:
+language: English
+
+# URL
+## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
+url: http://www.aryweb.nl
+root: /
+permalink: :year/:month/:day/:title/
+tag_dir: tags
+archive_dir: archives
+category_dir: categories
+
+# Writing
+new_post_name: :title.md # File name of new posts
+default_layout: post
+auto_spacing: false # Add spaces between asian characters and western characters
+titlecase: false # Transform title into titlecase
+max_open_file: 100
+highlight:
+ enable: true
+ backtick_code_block: true
+ line_number: false
+ tab_replace:
+
+# Category & Tag
+default_category: uncategorized
+category_map:
+tag_map:
+
+# Archives
+## 2: Enable pagination
+## 1: Disable pagination
+## 0: Fully Disable
+archive: 2
+category: 2
+tag: 2
+
+# Server
+## Hexo uses Connect as a server
+## You can customize the logger format as defined in
+## http://www.senchalabs.org/connect/logger.html
+port: 4000
+logger: false
+logger_format:
+
+# Date / Time format
+## Hexo uses Moment.js to parse and display date
+## You can customize the date format as defined in
+## http://momentjs.com/docs/#/displaying/format/
+date_format: MMM D YYYY
+time_format: H:mm:ss
+
+# Pagination
+## Set per_page to 0 to disable pagination
+per_page: 10
+pagination_dir: page
+
+# Disqus
+disqus: true
+
+# Extensions
+## Plugins: https://github.com/tommy351/hexo/wiki/Plugins
+## Themes: https://github.com/tommy351/hexo/wiki/Themes
+theme: light
+exclude_generator:
+
+# Deployment
+## Docs: http://zespia.tw/hexo/docs/deploy.html
+deploy:
+ type:
@@ -0,0 +1,13 @@
+{
+ "name": "hexo",
+ "version": "0.0.1",
+ "private": true,
+ "engines": {
+ "node": ">= 0.6.0",
+ "npm": ">= 1.1.0"
+ },
+ "dependencies": {
+ "node-watch": "0.2",
+ "hexo": "0.5"
+ }
+}
@@ -0,0 +1,3 @@
+title: {{ title }}
+date: {{ date }}
+---
@@ -0,0 +1,5 @@
+layout: {{ layout }}
+title: {{ title }}
+date: {{ date }}
+tags:
+---
@@ -0,0 +1,4 @@
+title: {{ title }}
+date: {{ date }}
+tags:
+---
@@ -0,0 +1,51 @@
+<?php
+
+define('REPOS_CACHE_TIME', 3600 * 6);
+
+class GitHub {
+
+ protected $url;
+ protected $file;
+
+ public function __construct(){
+ $this->url = 'https://api.github.com/users/arian/repos?sort=pushed';
+ $this->file = __DIR__ . '/../tmp/repos.json';
+ }
+
+ public function getRepos(){
+
+ if (!file_exists($this->file) || (time() - @filemtime($this->file) > REPOS_CACHE_TIME)){
+ return $this->fetchFromAPI();
+ }
+
+ return $this->fetchFromCache();
+ }
+
+ protected function fetchFromAPI(){
+
+ $ch = curl_init($this->url);
+ curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
+ $json = curl_exec($ch);
+
+ if (curl_errno($ch)){
+ $json = null;
+ }
+
+ curl_close($ch);
+
+ if ($json){
+ $this->saveToCache($json);
+ return json_decode($json, true);
+ }
+ }
+
+ protected function fetchFromCache(){
+ return json_decode(file_get_contents($this->file), true);
+ }
+
+ protected function saveToCache($json){
+ file_put_contents($this->file, $json);
+ }
+
+}
+
@@ -0,0 +1,54 @@
+<?php
+
+class Template implements Iterator, Countable {
+
+ protected $params = array();
+
+ public function render($tpl_file, $params=array()){
+ $this->params = array_merge($this->params,$params);
+ ob_start();
+ include $tpl_file;
+ return ob_get_clean();
+ }
+
+ public function __set($key,$value){
+ $this->params[$key] = $value;
+ }
+
+ public function __get($key){
+ if (isset($this->params[$key])){
+ return $this->params[$key];
+ }
+ trigger_error("This variable doesn't exist",E_USER_NOTICE);
+ }
+
+ public function __isset($key){
+ return isset($this->params[$key]);
+ }
+
+ public function count(){
+ return count($this->params);
+ }
+
+ public function rewind(){
+ reset($this->params);
+ }
+
+ public function current(){
+ return current($this->params);
+ }
+
+ public function key(){
+ return key($this->params);
+ }
+
+ public function next(){
+ return next($this->params);
+ }
+
+ public function valid(){
+ return $this->current() !== false;
+ }
+
+}
+
@@ -0,0 +1,51 @@
+<?php
+
+require __DIR__ . '/tmhOAuth/tmhOAuth.php';
+require __DIR__ . '/tmhOAuth/tmhUtilities.php';
+
+define('TWEETS_CACHE_TIME', 3600 * 6);
+
+class Tweets {
+
+ protected $file;
+ protected $config;
+
+ public function __construct(array $config){
+ $this->file = __DIR__ . '/../tmp/tweets.json';
+ $this->config = $config;
+ }
+
+ public function getTweets(){
+
+ if (!file_exists($this->file) || time() - @filemtime($this->file) > TWEETS_CACHE_TIME){
+ return $this->fetchFromAPI();
+ }
+
+ return $this->fetchFromCache();
+
+ }
+
+ protected function fetchFromAPI(){
+
+ $tmhOAuth = new tmhOAuth($this->config);
+
+ $code = $tmhOAuth->request('GET', $tmhOAuth->url('1/statuses/user_timeline', 'json'));
+
+ if ($code == 200){
+ $response = $tmhOAuth->response['response'];
+ $this->saveToCache($response);
+ return json_decode($response, true);
+ }
+
+ return array();
+ }
+
+ protected function fetchFromCache(){
+ return json_decode(file_get_contents($this->file), true);
+ }
+
+ protected function saveToCache($json){
+ file_put_contents($this->file, $json);
+ }
+
+}
Submodule tmhOAuth added at 6c4a2a
@@ -0,0 +1,50 @@
+
+<div class="twitter">
+ <h1>
+ <i class="icon-twitter"></i>
+ What I&#39;ve got to say <a href="http://twitter.com/astolwijk">@astolwijk</a>
+ </h1>
+ <div id="twitter">
+ <ul><?php $i = 0; foreach ($this->tweets as $tweet): if ($i++ > 4){ break; } ?>
+
+ <li><a href="http://twitter.com/astolwijk/status/<?php echo $tweet['id_str'] ?>"><?php echo $tweet['text']; ?></a></li><?php
+ endforeach; ?>
+
+ </ul>
+ </div>
+</div>
+
+<div class="about">
+ <h1>
+ <i class="icon-question-sign"></i>
+ About me
+ </h1>
+ <p>
+ I am a Dutch Web and <a href="http://mootools.net/developers">MooTools</a>
+ Developer and I create Websites and WebApps.
+ </p>
+ <p>
+ I&#39;m also an Embedded Systems student at the
+ <a href="http://tudelft.nl">TU Delft</a>.
+ </p>
+ <p>
+ You can find me at other cool places too, like
+ <a href="http://twitter.com/astolwijk">twitter</a> or
+ <a href="http://github.com/arian">github</a>.
+ </p>
+</div>
+
+<div class="github">
+ <h1>
+ <i class="icon-github"></i>
+ <a href="http://github.com/arian">github.com/arian</a>
+ </h1>
+ <div id="github">
+ <ul><?php foreach ($this->repos as $repo): ?>
+
+ <li><a href="<?php echo $repo['html_url'] ?>"><?php echo $repo['name']; ?></a></li><?php
+ endforeach; ?>
+
+ </ul>
+ </div>
+</div>
@@ -0,0 +1,8 @@
+<?php
+
+return array(
+ 'consumer_key' => '',
+ 'consumer_secret' => '',
+ 'user_token' => '',
+ 'user_secret' => '',
+);
@@ -0,0 +1,17 @@
+<?php
+
+include_once '_home/lib/Tweets.php';
+include_once '_home/lib/GitHub.php';
+include_once '_home/lib/Template.php';
+
+$template = new Template;
+
+$tweets = new Tweets(require '_home/twitterAPISecret.php');
+$template->tweets = $tweets->getTweets();
+
+$gh = new GitHub;
+$template->repos = $gh->getRepos();
+
+echo $template->render('_home/templates/index.php');
+
+?>
@@ -0,0 +1,24 @@
+
+var exec = require('child_process').exec;
+var fs = require('fs');
+
+var htmlFile = __dirname + "/../public/index.html";
+var phpFile = __dirname + "/../public/index.php";
+
+hexo.on('generateAfter', function() {
+ exec("cp -R ./_index/* ../public", {
+ cwd: __dirname
+ }, function(err) {
+ if (err) throw err;
+ console.log("done copying PHP");
+
+ var html = fs.readFileSync(htmlFile, "utf-8");
+ var php = fs.readFileSync(phpFile);
+
+ php = html.replace('{{content}}', php);
+
+ fs.writeFileSync(phpFile, php);
+ fs.unlink(htmlFile);
+
+ });
+});
Oops, something went wrong.

0 comments on commit 8edf1ea

Please sign in to comment.