xonecas.io
1361
Xc

xonecas.com / commit 6833677

New layout using Twitter bootstrap.

sean2011-09-21 6833677c40662ed1b23824e8b9ea3ea8e5ae57bd parent cd833a6

10 files changed

.gitmodules+3−0
@@ -7,3 +7,6 @@
77 [submodule "2d-particle-experiements"]
88 path = 2d-particle-experiements
99 url = git@github.com:xonecas/2d-particle-experiements.git
10+[submodule "bootstrap"]
11+ path = bootstrap
12+ url = https://github.com/twitter/bootstrap.git
bootstrap+1−0
@@ -0,0 +1 @@
1+Subproject commit 323de40e80a6a00cf1931f17c3d3c1f608bab7a6
css/style.css+0−197
@@ -1,197 +0,0 @@
1-/* Google font api
2- Walter turncoat
3-*/
4-
5-@import url(http://fonts.googleapis.com/css?family=Walter+Turncoat);
6-
7-
8-/* http://meyerweb.com/eric/tools/css/reset/
9- v2.0 | 20110126
10- License: none (public domain)
11-*/
12-
13-html, body, div, span, applet, object, iframe,
14-h1, h2, h3, h4, h5, h6, p, blockquote, pre,
15-a, abbr, acronym, address, big, cite, code,
16-del, dfn, em, img, ins, kbd, q, s, samp,
17-small, strike, strong, sub, sup, tt, var,
18-b, u, i, center,
19-dl, dt, dd, ol, ul, li,
20-fieldset, form, label, legend,
21-table, caption, tbody, tfoot, thead, tr, th, td,
22-article, aside, canvas, details, embed,
23-figure, figcaption, footer, header, hgroup,
24-menu, nav, output, ruby, section, summary,
25-time, mark, audio, video {
26- margin: 0;
27- padding: 0;
28- border: 0;
29- font-size: 100%;
30- font: inherit;
31- vertical-align: baseline;
32-}
33-/* HTML5 display-role reset for older browsers */
34-article, aside, details, figcaption, figure,
35-footer, header, hgroup, menu, nav, section {
36- display: block;
37-}
38-body {
39- line-height: 1;
40-}
41-ol, ul {
42- list-style: none;
43-}
44-blockquote, q {
45- quotes: none;
46-}
47-blockquote:before, blockquote:after,
48-q:before, q:after {
49- content: '';
50- content: none;
51-}
52-table {
53- border-collapse: collapse;
54- border-spacing: 0;
55-}
56-
57-/* From the html5boilerplate
58- h5bp.com
59-*/
60-a {
61- color: hsl(200, 100%, 50%);
62- text-decoration: none;
63- border-bottom: 1px solid hsl(200, 100%, 50%);
64-}
65-a:visited {
66- color: hsl(195, 100%, 50%);
67- border-bottom: hsl(195, 100%, 50%);
68-}
69-a:focus { outline: thin dotted; }
70-a:hover, a:active {
71- outline: 0;
72- background-color: #eee;
73-}
74-pre {
75- white-space: pre;
76- white-space: pre-wrap;
77- word-wrap: break-word;
78-}
79-
80-/* Main styles
81- by @xonecas
82-*/
83-body {
84- width: 720px;
85- margin: 0 auto;
86- padding: 40px 0;
87- font-family: sans-serif;
88- font-size: 13px;
89- line-height: 16px;
90- position: relative;
91-}
92-
93-h1, h2, h3, h4, h5, h6 {
94- font-family: "Walter Turncoat";
95- margin: 0 0 1em 0;
96- font-weight: bold;
97- line-height: 1.1em;
98-}
99-h1 { font-size: 48px; }
100-h2 { font-size: 36px; }
101-h3 { font-size: 24px; }
102-
103-em { font-style: italic; }
104-strong { font-weight: bold; }
105-
106-pre {
107- margin: 1em 0;
108- padding: 10px;
109-}
110-pre, code {
111- background: #eee;
112- border-left: 5px solid #999;
113-}
114-pre code { border: none; }
115-code { padding: 3px 5px; }
116-
117-header {
118- border-bottom: 1px solid hsl(200, 100%, 50%);
119-}
120-
121-.loader {
122- display: block;
123- width: 16px;
124- height: 16px;
125- margin: 40px auto;
126-}
127-
128-#brand {
129- vertical-align: middle;
130- margin: -5px 10px 0 0;
131-}
132-
133-#latestTweet {
134- position: fixed;
135- bottom: 0;
136- background: #FFF;
137- width: 720px;
138- border-top: 1px solid hsl(200, 100%, 50%);
139- padding: 10px 0;
140-}
141-
142-#coderwall {
143- padding: 20px 0;
144- border-top: 1px solid hsl(200, 100%, 50%);
145-}
146-
147-.relTime {
148- position: absolute;
149- top: 5px;
150- right: 0;
151- color: #aeaeae;
152-}
153-
154-.post {
155- padding: 25px 0 0 0;
156- margin: 0 0 20px 0;
157- position: relative;
158-}
159-.post ul, .post ol {
160- list-style: disc;
161- margin: 0 0 0 20px;
162-}
163-
164-.badge {
165- margin: 0 0 20px 0;
166-}
167-
168-.badgeImage {
169- float: left;
170- width: 64px;
171- height: 64px;
172- margin: 0 20px 0 0;
173-}
174-
175-
176-/* Helpers (from h5bp)
177-*/
178-.hidden { display: none; }
179-.clearfix:before, .clearfix:after { content: ""; display: table; }
180-.clearfix:after { clear: both; }
181-.clearfix { zoom: 1; }
182-
183-
184-
185-
186-/* Media style changes
187- * For mobile and shit
188- */
189-@media only screen and (max-width: 480px) {
190- /* Style adjustments for viewports 480px and over go here */
191-}
192-
193-@media only screen and (max-width: 768px) {
194- /* Style adjustments for viewports 768px and over go here */
195-
196-}
197-
index.html+15−4
@@ -8,14 +8,12 @@
88
99 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1010
11-
12-
13- <link rel="stylesheet/less" type="text/css" href="less/style.less?v=0.0.3">
11+ <link rel="stylesheet/less" type="text/css" href="bootstrap/lib/bootstrap.less?v=0.0.3">
12+ <link rel="stylesheet/less" type="text/css" href="styles/base.less?v=0.0.3">
1413 <script src="vendor/less.js?v=0.0.3"></script>
1514 <script src="vendor/modernizr.js?v=0.0.3"></script>
1615 </head>
1716 <body>
18-
1917 <!--
2018 Templates go in this magic div that no one sees
2119 -->
@@ -30,6 +28,18 @@
3028 </aside>
3129 </script>
3230
31+ <script id="header_tmpl" type="text/template">
32+ <div class="topbar-inner">
33+ <div class="container">
34+ <h3><a href="/">xonecas</a></h3>
35+ <ul class="nav">
36+ <li><a id="prev-post" href="#">Previous</a></li>
37+ <li><a id="next-post" href="#">Next</a></li>
38+ </ul>
39+ </div>
40+ </div>
41+ </script>
42+
3343 <script id="error_tmpl" type="text/template">
3444 An error has occured: {{error}}. <small>Leaving in 5 secs</small>
3545 </script>
@@ -43,6 +53,7 @@
4353 <script src="vendor/handlebars.js?v=0.0.3"></script>
4454 <script src="vendor/underscore.js?v=0.0.3"></script>
4555 <script src="vendor/backbone.js?v=0.0.3"></script>
56+ <script src="vendor/hijs.js?v=0.0.3"></script>
4657
4758 <!-- app -->
4859 <script src="js/script.js?v=0.0.3"></script>
js/script.js+48−22
@@ -36,10 +36,17 @@ $(function () {
3636
3737 next: function () {
3838 this.idx++;
39+ if (this.idx + (this.count * this.page) === this.total) {
40+ console.log('no more :-(');
41+ this.idx--;
42+ return;
43+ }
44+
3945 var model = this.at(this.idx);
4046
4147 if (model) {
4248 this.current = model;
49+ this.trigger('change');
4350 } else {
4451 this.page++;
4552 this.idx = 0;
@@ -53,12 +60,14 @@ $(function () {
5360
5461 if (model) {
5562 this.current = model;
63+ this.trigger('change');
5664 } else {
5765 if (this.page > 0) {
5866 this.page--;
5967 this.idx = this.count -1;
6068 this.fetch();
6169 } else {
70+ this.idx++;
6271 this.trigger('error', 'At most recent post');
6372 }
6473 }
@@ -66,36 +75,29 @@ $(function () {
6675 }
6776 });
6877
69- ErrorReport = Backbone.View.extend({
70- id: 'error',
71- className: 'container',
72- template: Handlebars.compile($('#error_tmpl').html()),
73-
74- initialize: function () {
75- _.bindAll(this, "remove");
76- this.render();
77- },
78-
79- render: function () {
80- $('#main').append(this.template(this.error));
81- setTimeout(this.remove, 5000);
82- return this;
83- }
84- });
85-
8678 HomePage = Backbone.View.extend({
8779 id: 'main',
8880 className: 'container',
81+ tagName: 'section',
8982 template: Handlebars.compile($('#post_tmpl').html()),
9083 collection: new Tumblr(),
9184
9285 initialize: function () {
86+ this.header = new Header({
87+ 'collection': this.collection
88+ });
89+ this.header.render();
9390 _.bindAll(this, "render", "report");
9491 this.collection.bind('reset', this.render);
9592 this.collection.bind('error', this.report);
93+ this.collection.bind('change', this.render);
9694 this.collection.fetch();
9795
98- $(this.el).appendTo('body');
96+ $('body').append(this.el);
97+ },
98+
99+ report: function (err) {
100+ console.log(err);
99101 },
100102
101103 render: function () {
@@ -104,12 +106,36 @@ $(function () {
104106 .css('display', 'none')
105107 .html(this.template(model.toJSON()))
106108 .fadeIn(1000);
107-
109+ hijs('code');
110+ }
111+ });
112+
113+ Header = Backbone.View.extend({
114+ className: 'topbar',
115+ tagName: 'div',
116+ template: $('#header_tmpl').html(),
117+
118+ render: function () {
119+ $(this.el)
120+ .html(this.template)
121+ .appendTo('body');
122+ },
123+
124+ events: {
125+ "click #prev-post": "previous",
126+ "click #next-post": "next"
127+ },
128+
129+ previous: function (ev) {
130+ ev.preventDefault();
131+ this.collection.previous();
132+ return false;
108133 },
109134
110- report: function (error) {
111- this.errors = this.errors || [];
112- this.errors.push(new ErrorReport().render());
135+ next: function (ev) {
136+ ev.preventDefault();
137+ this.collection.next();
138+ return false;
113139 }
114140 });
115141
less/mixins.less+0−27
@@ -1,27 +0,0 @@
1-// From https://github.com/twitter/bootstrap/blob/master/lib/preboot.less
2-
3-// ERIC MEYER RESET
4-// --------------------------------------------------
5-
6-html, body { margin: 0; padding: 0; }
7-h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, cite, code, del, dfn, em, img, q, s, samp, small, strike, strong, sub, sup, tt, var, dd, dl, dt, li, ol, ul, fieldset, form, label, legend, button, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; font-weight: normal; font-style: normal; font-size: 100%; line-height: 1; font-family: inherit; }
8-table { border-collapse: collapse; border-spacing: 0; }
9-ol, ul { list-style: none; }
10-q:before, q:after, blockquote:before, blockquote:after { content: ""; }
11-
12-// clearfix
13-.clearfix {
14- zoom: 1;
15- &:before, &:after {
16- display: table;
17- content: "";
18- }
19- &:after {
20- clear: both;
21- }
22-}
23-
24-.sans {
25- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
26-}
27-
less/style.less+0−42
@@ -1,42 +0,0 @@
1-@import "mixins";
2-
3-// config
4-@siteWidth: 720px;
5-@siteMargin: 20px 20px 20px 40px;
6-@lineHeight: 24px;
7-@fontSize: 16px;
8-
9-// colors from http://www.colourlovers.com/palette/444487/Curiosity_Killed
10-@bg: #2E2633; //eveningcloud
11-@fg: #EFFFCD; //vichy
12-@visited: #555152; //dirt
13-@link: #DCE9BE; //hex
14-@highlight: #99173C; //helio
15-
16-
17-body {
18- width: @siteWidth;
19- margin: @siteMargin;
20- background-color: @bg;
21- color: @fg;
22- font-size: @fontSize;
23- line-height: @lineHeight;
24- .sans();
25- .clearfix();
26-}
27-
28-a {
29- color: @link;
30- text-decoration: none;
31- font-size: @fontSize;
32- line-height: @lineHeight;
33- &:visited, &:hover {
34- color: @visited;
35- text-decoration: underline;
36- }
37-}
38-
39-small {
40- font-size: @fontSize -3;
41- line-height: @lineHeight -3;
42-}
server.js+0−25
@@ -13,31 +13,6 @@ var connect = require('connect'),
1313 // inspect tool, I use it all the time.
1414 inspect = require('util').inspect;
1515
16-var paths = [
17- "libs/json2.js",
18- "libs/jquery.js",
19- "libs/underscore.js",
20- "libs/backbone.js",
21-], len = paths.length, code = [];
22-
23-(function loop (i) {
24- if (i === len) {
25- fs.writeFile("libs/all.js", code.join('\n'), function (err) {
26- if (err) throw err;
27-
28- console.log("Wrote libs/all.js");
29- });
30- } else {
31- fs.readFile(paths.shift(), 'utf8', function (err, out) {
32- if (err) throw err;
33-
34- code.push(out);
35- loop(i+1);
36- });
37- }
38-}) (0);
39-
40-
4116 var routes = function (app) {
4217
4318
styles/base.less+9−0
@@ -0,0 +1,9 @@
1+body {
2+ margin-top: 50px;
3+}
4+code .keyword { font-weight: bold }
5+code .string, code .regexp { color: red }
6+code .class, code .special { color: blue }
7+code .number { color: red }
8+code .comment { color: grey }
9+
vendor/hijs.js+94−0
@@ -0,0 +1,94 @@
1+window.hijs = function (selector) {
2+ //
3+ // hijs - JavaScript Syntax Highlighter
4+ //
5+ // Copyright (c) 2010 Alexis Sellier
6+ //
7+
8+ // All elements which match this will be syntax highlighted.
9+ var selector = selector || 'code';
10+
11+ var keywords = ('var function if else for while break switch case do new null in with void '
12+ +'continue delete return this true false throw catch typeof with instanceof').split(' '),
13+ special = ('eval window document undefined NaN Infinity parseInt parseFloat '
14+ +'encodeURI decodeURI encodeURIComponent decodeURIComponent').split(' ');
15+
16+ // Syntax definition
17+ // The key becomes the class name of the <span>
18+ // around the matched block of code.
19+ var syntax = [
20+ ['comment', /(\/\*(?:[^*\n]|\*+[^\/*])*\*+\/)/g],
21+ ['comment', /(\/\/[^\n]*)/g],
22+ ['string' , /("(?:(?!")[^\\\n]|\\.)*"|'(?:(?!')[^\\\n]|\\.)*')/g],
23+ ['regexp' , /(\/.+\/[mgi]*)(?!\s*\w)/g],
24+ ['class' , /\b([A-Z][a-zA-Z]+)\b/g],
25+ ['number' , /\b([0-9]+(?:\.[0-9]+)?)\b/g],
26+ ['keyword', new(RegExp)('\\b(' + keywords.join('|') + ')\\b', 'g')],
27+ ['special', new(RegExp)('\\b(' + special.join('|') + ')\\b', 'g')]
28+ ];
29+ var nodes, table = {};
30+
31+ if (/^[a-z]+$/.test(selector)) {
32+ nodes = document.getElementsByTagName(selector);
33+ } else if (/^\.[\w-]+$/.test(selector)) {
34+ nodes = document.getElementsByClassName(selector.slice(1));
35+ } else if (document.querySelectorAll) {
36+ nodes = document.querySelectorAll(selector);
37+ } else {
38+ nodes = [];
39+ }
40+
41+ for (var i = 0, children; i < nodes.length; i++) {
42+ children = nodes[i].childNodes;
43+
44+ for (var j = 0, str; j < children.length; j++) {
45+ code = children[j];
46+
47+ if (code.length >= 0) { // It's a text node
48+ // Don't highlight command-line snippets
49+ if (! /^\$\s/.test(code.nodeValue.trim())) {
50+ syntax.forEach(function (s) {
51+ var k = s[0], v = s[1];
52+ code.nodeValue = code.nodeValue.replace(v, function (_, m) {
53+ return '\u00ab' + encode(k) + '\u00b7'
54+ + encode(m) +
55+ '\u00b7' + encode(k) + '\u00bb';
56+ });
57+ });
58+ }
59+ }
60+ }
61+ }
62+ for (var i = 0; i < nodes.length; i++) {
63+ nodes[i].innerHTML =
64+ nodes[i].innerHTML.replace(/\u00ab(.+?)\u00b7(.+?)\u00b7\1\u00bb/g, function (_, name, value) {
65+ value = value.replace(/\u00ab[^\u00b7]+\u00b7/g, '').replace(/\u00b7[^\u00bb]+\u00bb/g, '');
66+ return '<span class="' + decode(name) + '">' + escape(decode(value)) + '</span>';
67+ });
68+ }
69+
70+ function escape(str) {
71+ return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
72+ }
73+
74+ // Encode ASCII characters to, and from Braille
75+ function encode (str, encoded) {
76+ table[encoded = str.split('').map(function (s) {
77+ if (s.charCodeAt(0) > 127) { return s }
78+ return String.fromCharCode(s.charCodeAt(0) + 0x2800);
79+ }).join('')] = str;
80+ return encoded;
81+ }
82+ function decode (str) {
83+ if (str in table) {
84+ return table[str];
85+ } else {
86+ return str.trim().split('').map(function (s) {
87+ if (s.charCodeAt(0) - 0x2800 > 127) { return s }
88+ return String.fromCharCode(s.charCodeAt(0) - 0x2800);
89+ }).join('');
90+ }
91+ }
92+
93+}
94+