]> khamidou — GitHub mirrors - grid.git/commitdiff
source dump
authorkarim hamidou <khamidou@gmail.com>
Mon, 25 Feb 2013 18:52:02 +0000 (19:52 +0100)
committerkarim hamidou <khamidou@gmail.com>
Mon, 25 Feb 2013 18:52:02 +0000 (19:52 +0100)
12 files changed:
README.md
blog.yaml [new file with mode: 0644]
grid.py [new file with mode: 0644]
posts/first.yaml [new file with mode: 0644]
static/css/gridiculous.css [new file with mode: 0644]
static/css/ie.css [new file with mode: 0644]
static/css/reset.css [new file with mode: 0644]
static/css/responsive-gs-16col.css [new file with mode: 0644]
static/css/style.css [new file with mode: 0644]
templates/base.html [new file with mode: 0644]
templates/index.html [new file with mode: 0644]
templates/post.html [new file with mode: 0644]

index b4747c08e4052238e68f7d94d6d2ab3735e34655..27cf9996879f87ce4532ba868cbfe53a3184413d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,4 +1,20 @@
 grid
 ====
 
-A small static website generator (because the world needs more of those)
\ No newline at end of file
+A small static website generator (because the world needs more of those).
+
+requirements
+============
+
+To run this, you'll need to have:
+- python 2.x
+- pyyaml
+- jinja2
+
+usage
+=====
+
+This is the layout of a blog :
+posts/ holds your posts
+static/ contains your static files
+templates/ holds the templates used
diff --git a/blog.yaml b/blog.yaml
new file mode 100644 (file)
index 0000000..7fcc237
--- /dev/null
+++ b/blog.yaml
@@ -0,0 +1 @@
+title: "Sample blog"
diff --git a/grid.py b/grid.py
new file mode 100644 (file)
index 0000000..5a9002e
--- /dev/null
+++ b/grid.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+import os
+import yaml
+import jinja2
+import distutils.dir_util
+
+def process_post(blog_config, file):
+    template = env.get_template('post.html')
+    
+    with open("posts/" + file) as fd:
+        fname = os.path.splitext(file)[0]
+        post = yaml.safe_load_all(fd)
+        metadata = post.next()
+        post_contents = post.next()
+        with open("output/" + fname + ".html", "w+") as out:
+            out.write(template.render(blog_config=blog_config, metadata=metadata, post_contents=post_contents))
+
+    return metadata
+
+
+def create_index(blog_config, metadata_list):
+    template = env.get_template('index.html')
+
+    with open("output/index.html", "w+") as out:
+        out.write(template.render(blog_config = blog_config, posts_metadata = metadata_list))
+
+env = jinja2.Environment(loader=jinja2.PackageLoader('grid', 'templates'))
+
+if __name__ == "__main__":
+    blog_config = None
+
+    try:
+        with open("blog.yaml") as fd:
+            blog_config = yaml.safe_load_all(fd)
+    except IOError:
+        print "unable to open blog config file 'blog.yaml'."
+        os.exit(-1)
+
+
+    metadata_list = []
+
+    if not os.path.exists("output") and os.path.isdir("output"):
+        print "output/ directory doesn't exists"
+        os.exit(-1)
+    
+    print "Copying static files"
+    distutils.dir_util.copy_tree("static", "output/")
+
+    print "Generating post pages"
+    for file in os.listdir('posts/'):
+        ext = os.path.splitext(file)[1]
+        if ext in [".yaml"] and file[0] != ".":
+            metadata_list.append(process_post(blog_config, file))
+
+    print "Creating index.html"
+    create_index(blog_config, metadata_list)
diff --git a/posts/first.yaml b/posts/first.yaml
new file mode 100644 (file)
index 0000000..f6993d6
--- /dev/null
@@ -0,0 +1,5 @@
+title: "stuff"
+type: "post"
+date: 2002-12-12
+---
+ceci est du texte
diff --git a/static/css/gridiculous.css b/static/css/gridiculous.css
new file mode 100644 (file)
index 0000000..f53cb61
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Gridiculous
+ *
+ * A responsive grid boilerplate that takes you all the way from 1200px on down to 320px.
+ *
+ * created by c.bavota
+ * released under GPL v2 & MIT License (http://en.wikipedia.org/wiki/MIT_License)
+ *
+ * September 24th, 2012
+ */
+ 
+/* =Normalize.css v2.0.1 by Nicolas Gallagher - http://necolas.github.com/normalize.css/
+-------------------------------------------------------------- */
+article,aside,details,figcaption,figure,footer,header,hgroup,nav,section,summary{display:block}
+audio,canvas,video{display:inline-block}
+audio:not([controls]){display:none;height:0}
+[hidden]{display:none}
+html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}
+a:focus{outline:thin dotted}
+a:active,a:hover{outline:0}
+h1{font-size:2em}
+abbr[title]{border-bottom:1px dotted}
+b,strong{font-weight:bold}
+dfn{font-style:italic}
+mark{background:#ff0;color:#000}
+code,kbd,pre,samp{font-family:monospace, serif;font-size:1em}
+pre{white-space:pre-wrap;word-wrap:break-word}
+q{quotes:\201C \201D \2018 \2019}
+small{font-size:80%}
+sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
+sup{top:-.5em}
+sub{bottom:-.25em}
+img{border:0}
+svg:not(:root){overflow:hidden}
+fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:.35em .625em .75em}
+button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
+button,input{line-height:normal}
+button,html input[type=button],/* 1 */
+input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}
+button[disabled],input[disabled]{cursor:default}
+input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}
+input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}
+input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}
+textarea{overflow:auto;vertical-align:top}
+table{border-collapse:collapse;border-spacing:0}
+body,figure{margin:0}
+legend,button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
+
+/* =Clearfix by Nicolas Gallagher
+-------------------------------------------------------------- */
+.row:before,.row:after,.clearfix:before,.clearfix:after{content:'';display:table}
+.row:after,.clearfix:after{clear:both}
+.row,.clearfix{zoom:1}
+
+/* =Gridiculous
+-------------------------------------------------------------- */
+*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}
+body{font-size:100%;line-height:1.6875}
+.grid{margin:0 auto;max-width:1200px;width:100%}
+img{max-width:100%;height:auto;display:block;margin-left:auto;margin-right:auto}
+.wfull{width:100%;max-width:100%}
+.w320{max-width:320px}
+.w640{max-width:640px}
+.w960{max-width:960px}
+.row{width:100%;margin-bottom:20px}
+.row .row{width:auto;margin:0 -20px}
+.c1{width:8.33%}
+.c2{width:16.66%}
+.c3{width:25%}
+.c4{width:33.33%}
+.c5{width:41.66%}
+.c6{width:50%}
+.c7{width:58.33%}
+.c8{width:66.66%}
+.c9{width:75%}
+.c10{width:83.33%}
+.c11{width:91.66%}
+.c12{width:100%}
+.c1,.c2,.c3,.c4,.c5,.c6,.c7,.c8,.c9,.c10,.c11,.c12{min-height:1px;float:left;padding-left:20px;padding-right:20px;position:relative}
+.s1{margin-left:8.33%}
+.s2{margin-left:16.66%}
+.s3{margin-left:25%}
+.s4{margin-left:33.33%}
+.s5{margin-left:41.66%}
+.s6{margin-left:50%}
+.s7{margin-left:58.33%}
+.s8{margin-left:66.66%}
+.s9{margin-left:75%}
+.s10{margin-left:83.33%}
+.s11{margin-left:91.66%}
+.end{float:right!important}
+
+/* =Media query for 960 Screens - sets nested grids to 100%
+-------------------------------------------------------------- */
+@media only screen and (max-width:960px){
+.row .row .c1,.row .row .c2,.row .row .c3,.row .row .c4,.row .row .c5,.row .row .c6,.row .row .c7,.row .row .c8,.row .row .c9,.row .row .c10,.row .row .c11,.row .row .c12{width:100%;margin-bottom:20px}
+.row .row > div:last-child{margin-bottom:0 !important}
+}
+
+/* =Media query for iPad and tablets
+-------------------------------------------------------------- */
+@media handheld, only screen and (max-width: 768px), only screen and (max-device-width: 768px) and (orientation:portrait){
+body{font-size:90%}
+.row{margin-bottom:0!important}
+.c1,.c2,.c3,.c4,.c5,.c6,.c7,.c8,.c9,.c10,.c11,.c12{width:100%;margin-right:0;margin-left:0;margin-bottom:20px}
+}
\ No newline at end of file
diff --git a/static/css/ie.css b/static/css/ie.css
new file mode 100644 (file)
index 0000000..7d4b505
--- /dev/null
@@ -0,0 +1,8 @@
+/* CLEARFIX HACK */
+.row,
+.clr,
+.group                                                 { zoom: 1; } /* IE6 */
+
+*:first-child+html .row,
+*:first-child+html .clr,
+*:first-child+html .group              { zoom: 1; } /* IE7 */
\ No newline at end of file
diff --git a/static/css/reset.css b/static/css/reset.css
new file mode 100644 (file)
index 0000000..30046e4
--- /dev/null
@@ -0,0 +1,35 @@
+/* 
+       RESET - ADAPTED FROM MEYER RESET
+       URL - http://meyerweb.com/eric/tools/css/reset/
+       LICENSE - PUBLIC DOMAIN
+*/
+
+/* RESET
+----------------------------------------------------------------------------------------------------*/
+a, abbr, acronym, address, applet, article, aside, audio, b, big, blockquote, body, caption, canvas, center, cite, code,
+dd, del, details, dfn, dialog, div, dl, dt, em, embed, fieldset, figcaption, figure, form, footer, header, hgroup, h1, h2, h3, h4, h5, h6, html, i, iframe, img, ins, kbd, label, legend, li, mark, menu, nav,object, ol, output, p, pre, q, ruby, s, samp, section, small, span, strike, strong, sub, summary, sup, tt, table, tbody, textarea, tfoot, thead, time, tr, th, td, u, ul, var, video  { 
+       font-family: inherit; 
+       font-size: 100%; 
+       font-weight: inherit; 
+       font-style: inherit; 
+       vertical-align: baseline; 
+       white-space: normal;
+       text-align: left; 
+       margin: 0; 
+       padding: 0; 
+       border: 0; 
+       outline: 0;
+       background: transparent; }
+
+article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { 
+       display: block; }
+                                                                 
+ol, ul { list-style: none; }
+
+blockquote, q { quotes: none; }
+
+:focus { outline: 0; }
+
+table { 
+       border-collapse: collapse; 
+       border-spacing: 0; }
\ No newline at end of file
diff --git a/static/css/responsive-gs-16col.css b/static/css/responsive-gs-16col.css
new file mode 100644 (file)
index 0000000..629d367
--- /dev/null
@@ -0,0 +1,72 @@
+/* 
+       16 COLUMN - RESPONSIVE GRID SYSTEM
+       DEVELOPED BY DENIS LEBLANC
+       URL - http://responsive.gs
+       VERSION - 2.0
+       LICENSED UNDER GPL & MIT
+*/
+
+
+/*     SET ALL ELEMENTS BOX-SIZING TO BORDER-BOX
+       If you need support for IE7 and lower use polyfill: https://github.com/Schepp/box-sizing-polyfill */
+* { -webkit-box-sizing: border-box;
+       -moz-box-sizing: border-box;
+       box-sizing: border-box; }
+
+
+/* MAIN CONTAINER */
+.container { 
+       max-width: 95%;
+       margin: 0 auto; }
+
+
+/* SELF CLEARING FLOATS - CLEARFIX METHOD */
+.row:after, .col:after, .clr:after, .group:after { 
+       content: ""; 
+       display: block; 
+       height: 0; 
+       clear: both; 
+       visibility: hidden; }
+
+
+/* DEFAULT ROW STYLES */
+.row { margin-bottom: 1.5em; } /* set according to preference*/
+       
+                                                                 
+/* DEFAULT COLUMN STYLES */
+.col { 
+       display: block;
+       float:left;
+       width: 100%;
+}
+
+@media ( min-width : 768px ) {
+       .col {
+               margin-left: 2%;
+       }
+}
+
+
+/* RESET MARGINS */
+.col:first-child { margin-left: 0; } /* all browsers except IE6 and lower */
+
+
+/* COLUMN WIDTH ON DISPLAYS +768px */
+@media ( min-width : 768px ) {
+       .span_1 { width: 4.375%; }
+       .span_2 { width: 10.75%; }
+       .span_3 { width: 17.125%; }
+       .span_4 { width: 23.5%; }
+       .span_5 { width: 29.875%; }
+       .span_6 { width: 36.25%; }
+       .span_7 { width: 42.625%; }
+       .span_8 { width: 49.0%; }
+       .span_9 { width: 55.375%; }
+       .span_10 { width: 61.75%; }
+       .span_11 { width: 68.125%; }
+       .span_12 { width: 74.5%; }
+       .span_13 { width: 80.875%; }
+       .span_14 { width: 87.25%; }
+       .span_15 { width: 93.625%; }
+       .span_16 { width: 100%; }
+}
\ No newline at end of file
diff --git a/static/css/style.css b/static/css/style.css
new file mode 100644 (file)
index 0000000..8b1908e
--- /dev/null
@@ -0,0 +1,24 @@
+body {
+    max-width: 960px;
+    margin: 0 auto;
+    margin-top: 10px;
+}
+
+.first_tile {
+    height: 310px;
+    max-width: 300px;
+    background-color: red;
+    margin-left: 20px;
+    float: left;
+    margin-bottom: 10px;
+}
+
+.tile {
+    background-color: lightblue;
+    margin-left: 20px;
+    height: 150px;
+    overflow: auto;
+    float: left;
+    max-width: 150px;
+    margin-bottom: 10px;
+}
\ No newline at end of file
diff --git a/templates/base.html b/templates/base.html
new file mode 100644 (file)
index 0000000..b2a8800
--- /dev/null
@@ -0,0 +1,24 @@
+<!doctype html>
+<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
+<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
+<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
+<!-- Consider adding a manifest.appcache: h5bp.com/d/Offline -->
+<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
+<head>
+       <meta charset="utf-8">
+       <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+       <title>{% block title %}{{ blog_config.title }}{% endblock title %}</title>
+       <meta name="description" content="">
+       <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> 
+
+       <!-- <link rel="stylesheet" href="css/gridiculous.css"> -->
+       
+       <!-- <link rel="stylesheet" href="css/reset.css"> -->
+       <link rel="stylesheet" href="css/style.css">
+</head>
+<body>
+       <div id="site-container" class="">
+               {% block content %}{% endblock %}
+       </div>
+</body>
+</html>
diff --git a/templates/index.html b/templates/index.html
new file mode 100644 (file)
index 0000000..62e5d8e
--- /dev/null
@@ -0,0 +1,213 @@
+{% extends "base.html" %}
+
+{% block title %}
+       {{ blog_config.title }}
+{% endblock title %}
+
+{% block content %}
+<div class="" style="overflow: auto;">
+  <div class="first_tile">
+    FEATURED CONTENT
+    {{ posts_metadata[0].title }}
+  </div>
+  <div class="tile">
+    <p>
+    mlkkkkkkkkkkkkkkkkkkkkkk<br>
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+   <div class="tile">
+    <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+  <div class="tile">
+    <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+  <div class="tile">
+    <p>
+    mlkkkkkkkkkkkkkkkkkkkkkk<br>
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+   <div class="tile">
+    <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+  <div class="tile">
+    <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+  <div class="tile">
+    <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+  <div class="tile">
+    <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+  <div class="tile">
+    <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+  <div class="tile">
+    <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+  <div class="tile">
+    <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+   <div class="tile">
+     <p>
+    mlkkkkkkkkkkkkkkkkkkkkkki
+    kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+    </p>
+  </div>
+
+
+
+</div>
+
+{% for post in posts_metadata[1:] %}
+
+{% if post.type != 'post' %}
+Image ?
+{% else %}
+       {{ post.title }}
+{% endif %}
+
+{% endfor %}
+{% endblock %}
diff --git a/templates/post.html b/templates/post.html
new file mode 100644 (file)
index 0000000..9ddd6a6
--- /dev/null
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+{{ metadata.title }}
+{{ metadata.date }}
+{{ post_contents }}
+
+{% endblock %}