xonecas.io
1361
Xc

xonecas.com / commit 411e93c

Added coderwall.com badges as a footer for now

sean2011-08-09 411e93cd811ba76f36c6a29d91a6cfc62d13b800 parent c60a629

5 files changed

.nodemonignore+4−0
@@ -0,0 +1,4 @@
1+# ignore static assets
2+
3+./libs/all.js
4+.swp$
css/style.css+51−2
@@ -124,11 +124,12 @@ body {
124124 #brand {
125125 background: url("/imgs/me.png") no-repeat scroll left 50% transparent;
126126 padding: 0 0 10px 58px;
127- font-size: 48px;
127+ font-size: 40px;
128128 }
129129
130130 #latestTweet {
131- margin: 2em 0;
131+ text-align: center;
132+ margin: 2em 0 6em;
132133 }
133134
134135 h1, h2, h3, h4, h5, h6 {
@@ -166,9 +167,57 @@ pre, code {
166167 pre code { border: none; }
167168 code { padding: 3px 5px; }
168169
170+
171+
172+.badge {
173+ width: 46%;
174+ float: right;
175+ margin: 0 2% 40px;
176+}
177+
178+.badgeImage {
179+ width: 64px;
180+ height: 64px;
181+ float: left;
182+ margin: 0 20px 0 0;
183+}
184+
185+.badgeTitle {
186+ position: relative;
187+ bottom: 12px;
188+}
189+
190+.badgeText {
191+ margin: 0 0 0 84px;
192+}
193+
169194 /* Helpers (from h5bp)
170195 */
171196 .hidden { display: none; }
172197 .clearfix:before, .clearfix:after { content: ""; display: table; }
173198 .clearfix:after { clear: both; }
174199 .clearfix { zoom: 1; }
200+
201+
202+
203+
204+/* Media style changes
205+ * For mobile and shit
206+ */
207+@media only screen and (max-width: 480px) {
208+ /* Style adjustments for viewports 480px and over go here */
209+ body {
210+ margin: 0 auto;
211+ width: 460px;
212+ font-size: 13px;
213+ }
214+
215+ h2 { font-size: 30px; }
216+ h3 { font-size: 20px; }
217+}
218+
219+@media only screen and (max-width: 768px) {
220+ /* Style adjustments for viewports 768px and over go here */
221+
222+}
223+
index.html+14−1
@@ -28,7 +28,9 @@
2828 <img class="loader" src="imgs/ajax-loader.gif" alt="Loading...">
2929 </section>
3030
31-
31+ <section id="coderwall" class="clearfix">
32+ <img class="loader" src="imgs/ajax-loader.gif" alt="Loading...">
33+ </section>
3234
3335
3436
@@ -42,6 +44,8 @@
4244 <span><%= text %></span>
4345 <em><%= relTime %></em>
4446 </script>
47+
48+
4549 <script id="_tumblr" type="text/template">
4650 <li id="<%= id %>" class="post clearfix">
4751 <span class="relTime"><%= relTime %></span>
@@ -53,6 +57,15 @@
5357 </div>
5458 </li>
5559 </script>
60+
61+
62+ <script id="_coderwall" type="text/template">
63+ <div class="badge">
64+ <img class="badgeImage" src="<%= badge %>" alt="<%= name %>">
65+ <h3 class="badgeTitle"><%= name %></h3>
66+ <p class="badgeText"><%= description %></p>
67+ </div>
68+ </script>
5669 </div>
5770
5871 <!--
js/script.js+43−1
@@ -47,7 +47,6 @@ $(function () {
4747 }
4848 // }}}
4949
50-
5150 // Tumblr client
5251 // -------------
5352 // {{{ 8<
@@ -179,6 +178,48 @@ $(function () {
179178 });
180179 // }}}
181180
181+ // Coderwall client
182+ // ----------------
183+ // {{{ 8<
184+ x.Badges = Backbone.Collection.extend({
185+ url: "http://coderwall.com/xonecas.json",
186+
187+ parse: function (res, xhr) {
188+ return res.data.badges;
189+ },
190+
191+ sync: function (model, method, options) {
192+ var params = _.extend(options, {
193+ "url": this.url,
194+ "dataType": "jsonp"
195+ });
196+
197+ return $.ajax(params);
198+ }
199+ });
200+
201+ x.BadgesView = Backbone.View.extend({
202+ collection: new x.Badges(),
203+ el: $("#coderwall"),
204+ template: $('#_coderwall').html(),
205+
206+ initialize: function () {
207+ _.bindAll(this, 'render');
208+ this.collection.bind('reset', this.render);
209+ this.collection.fetch();
210+ },
211+
212+ render: function () {
213+ var that = this;
214+
215+ this.el.empty();
216+ this.collection.each(function (badge) {
217+ that.el.append(_.template(that.template, badge.toJSON()));
218+ });
219+ }
220+ });
221+ // }}}
222+
182223 x.IndexView = Backbone.View.extend({
183224 el: $(document),
184225
@@ -189,6 +230,7 @@ $(function () {
189230 initialize: function () {
190231 this.blog = new x.BlogView();
191232 this.tweet = new x.TweetsView();
233+ this.badges = new x.BadgesView();
192234 },
193235
194236 keypressRouter: function (ev) {
server.js+1−3
@@ -27,8 +27,7 @@ var paths = [
2727
2828 console.log("Wrote libs/all.js");
2929 });
30- }
31- else {
30+ } else {
3231 fs.readFile(paths.shift(), 'utf8', function (err, out) {
3332 if (err) throw err;
3433
@@ -83,4 +82,3 @@ console.log('Node up!\nPort: '+port+'\nhtdocs: '+htdocs);
8382 process.on('uncaughtException', function (err) {
8483 console.log('Caught exception: ' + err);
8584 });
86-