-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeed.xml
More file actions
436 lines (343 loc) · 23.4 KB
/
Copy pathfeed.xml
File metadata and controls
436 lines (343 loc) · 23.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Sharper in Digital</title>
<subtitle>Thoughts and findings of a Front End Developer</subtitle>
<id>http://tgdev.github.io/blog</id>
<link href="http://tgdev.github.io/blog"/>
<link href="http://tgdev.github.io/feed.xml" rel="self"/>
<updated>2014-01-20T13:00:00Z</updated>
<author>
<name>Tom Gillard</name>
</author>
<entry>
<title>Battle of the Sasses</title>
<link rel="alternate" href="http://tgdev.github.io/blog/2014-01-21-ruby-sass-vs-node-sass/"/>
<id>http://tgdev.github.io/blog/2014-01-21-ruby-sass-vs-node-sass/</id>
<published>2014-01-20T13:00:00Z</published>
<updated>2015-04-02T11:59:48+11:00</updated>
<content type="html"><p><a href="http://libsass.org/">Libsass</a> is a C port of the original Sass engine to offer the power of Sass without being tied to Ruby.</p>
<p>Now I work in Windows and Ruby can be a bit of a pain so I’m more than keen to give the new kid on the block a go.</p>
<p>What I’m going to do is create two test projects using the <a href="http://inuitcss.com">inuit css framework</a> with their own gruntfile but each gruntfile will be different.</p>
<p>Project 1 will have the ruby Sass grunt task while Project 2 will use the newer, faster Libsass with Node-sass and Grunt-Sass.</p>
<p>Ben Frain has a great article on <a href="http://benfrain.com/lightning-fast-sass-compiling-with-libsass-node-sass-and-grunt-sass/">getting up and running with libsass, node-sass and grunt-sass</a>.</p>
<h2 id="the-setup">The setup</h2>
<p>Let’s take a look at each project’s <code>package.json</code> file to compare.</p>
<div class="row">
<div class="half">
<p><strong>Project 1</strong></p>
<pre class="code--block">
<code>{
"name": "project-1",
"version": "0.5.0",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.1.1",
"grunt-contrib-watch": "~0.4.3",
"grunt-contrib-sass": "latest"
},
"engines": {
"node": "&gt;=0.8.0"
}
}
</code>
</pre>
</div>
<div class="half">
<p><strong>Project 2</strong></p>
<pre class="code--block">
<code>{
"name": "project-1",
"version": "0.5.0",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.1.1",
"grunt-contrib-watch": "~0.4.3",
"grunt-sass": "0.6.1"
},
"engines": {
"node": "&gt;=0.8.0"
}
}
</code>
</pre>
</div>
</div>
<p>There’s only one main difference between the two projects and that is the grunt package for Sass.</p>
<h2 id="the-test">The test</h2>
<p>After running <code>npm install</code> so as to install all our grunt packages from our <code>package.json</code> file, we’ll run the <code>grunt</code> command which looks like this in <code>gruntfile.js</code>.</p>
<pre class="code--block"><code>grunt.registerTask('default', ['sass', 'watch']);
</code></pre>
<p>This simply compiles our Sass partial files from inuit into style.css and then watches said Sass files for any changes.</p>
<p>Making a quick little change to one of our Sass files (like changing the background colour on the body) and saving that change triggers the grunt watch task to kick in and…</p>
<h2 id="the-results">The results</h2>
<p>As we can see from the image below, the Node Sass task, which uses libsass, is indeed much faster than the native Ruby based Sass task.</p>
<figure>
<img src="/img/posts/2014/sass-test.png" alt="Test results: Ruby Sass - 2.645 seconds. Libsass - 1 second." />
<figcaption>
<small>Top: Ruby Sass completion time. Bottom: Libsass completion time</small>
</figcaption>
</figure>
<h2 id="soooooo">Soooooo…</h2>
<p>I know this is a pretty light on example but imagine you’re working on a large scale site with multiple Sass modules and even styles for various plugins, not to mention running multiple grunt tasks - you’re gonna love the extra time savings.</p>
<p>Plus, with support for sourcemaps being added to Libsass in the last month, there’s not much of a reason to continue waiting around for the native Ruby Sass grunt task to drag it’s knuckles into CSS pre-compilation.</p>
<p>We’re all far too busy for that right?</p>
<p>T</p>
<p><small><em>NOTE: If you use Compass, which Libsass still does not support, checkout the <a href="https://github.com/nDmitry/grunt-autoprefixer">autoprefixer grunt task</a> that uses the <a href="http://caniuse.com/">Can I Use</a> database.</em></small></p>
</content>
</entry>
<entry>
<title>Social media meta</title>
<link rel="alternate" href="http://tgdev.github.io/blog/2014-01-11-social-media-meta-tags/"/>
<id>http://tgdev.github.io/blog/2014-01-11-social-media-meta-tags/</id>
<published>2014-01-10T13:00:00Z</published>
<updated>2015-04-02T11:59:48+11:00</updated>
<content type="html"><p>With so many people using social media these days, it seems only logical to include the snippets below on all of our sites.</p>
<h2 id="facebook-open-graph">Facebook Open Graph</h2>
<p>These are probably the most commonly known and you’ve probably used these once or twice before.</p>
<pre class="code--block"><code>&lt;!-- Facebook Open Graph tags --&gt;
&lt;meta property="og:image" content="" /&gt;
&lt;meta property="og:site_name" content="" /&gt;
&lt;meta property="og:type" content="" /&gt;
&lt;meta property="og:url" content="" /&gt;
&lt;meta property="og:title" content="" /&gt;
</code></pre>
<p>More details of Facebook’s OpenGraph tags/options can be found on <a href="http://davidwalsh.name/facebook-meta-tags">David Walsh’s Blog</a></p>
<h2 id="twitter-cards">Twitter Cards</h2>
<p>These are a little newer and there is a LOT you can include (links to mobile apps, product details, etc) so make sure you check out the docs via the link below.</p>
<pre class="code--block"><code>&lt;!-- Twitter Card --&gt;
&lt;meta name="twitter:card" content="summary" /&gt;
&lt;meta name="twitter:creator" content=""&gt;
&lt;meta name="twitter:url" content="" /&gt;
&lt;meta name="twitter:title" content="" /&gt;
&lt;meta name="twitter:description" content="" /&gt;
&lt;meta name="twitter:image:src" content="" /&gt;
</code></pre>
<p>More details of Twitter’s Card tags/options can be found in their <a href="https://dev.twitter.com/docs/cards">development docs</a></p>
<h2 id="rich-pins">Rich Pins</h2>
<p>Possibly the newest kid on the block launching in 2013, these can also include alot of content when somebody pins something from your site. They type property determines what additional meta data you can share so check out the link to the docs below.</p>
<pre class="code--block"><code>&lt;!-- Pintrest Rich Pins --&gt;
&lt;meta property="og:title" content="" /&gt;
&lt;meta property="og:description" content="" /&gt;
&lt;meta property="og:type" content="" /&gt;
&lt;meta property="og:url" content="" /&gt;
&lt;meta property="og:image" content="" /&gt;
&lt;meta property="og:site_name" content="" /&gt;
</code></pre>
<p>More details of Pinterest’s Rich Pins tags/options can be found in their <a href="http://developers.pinterest.com/rich_pins/">development docs</a></p>
<h2 id="putting-it-all-together">Putting it all together</h2>
<p>An example site for a business selling shoes, with the page template based on a watered down version of the HTML5 boilerplate, could look something like this;</p>
<pre class="code--block"><code>&lt;!DOCTYPE html&gt;
&lt;html class="no-js"&gt;
&lt;head&gt;
&lt;meta charset="utf-8" /&gt;
&lt;title&gt;Social Meta Tag Example&lt;/title&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
&lt;link rel="stylesheet" href="css/style.css"&gt;
&lt;script src="js/vendor/modernizr-2.7.1.min.js"&gt;&lt;/script&gt;
&lt;!-- Facebook Open Graph tags --&gt;
&lt;meta property="og:image" content="http://shop.example.com/images/store/SA-001.jpg" /&gt;
&lt;meta property="og:site_name" content="Example Store" /&gt;
&lt;meta property="og:type" content="product" /&gt;
&lt;meta property="og:url" content="http://shop.example.com/product/SA-001" /&gt;
&lt;meta property="og:title" content="Reebok Shaq Attaq" /&gt;
&lt;!-- Twitter Card --&gt;
&lt;meta name="twitter:card" content="product" /&gt;
&lt;meta name="twitter:creator" content="@exampleStore"&gt;
&lt;meta name="twitter:url" content="http://shop.example.com/product/SA-001" /&gt;
&lt;meta name="twitter:title" content="Reebok Shaq Attaq" /&gt;
&lt;meta name="twitter:description" content="Limited edition Shaquille O'neil basketball shoes." /&gt;
&lt;meta name="twitter:image:src" content="http://shop.example.com/images/store/SA-001.jpg" /&gt;
&lt;!-- Pintrest Rich Pin --&gt;
&lt;meta property="og:title" content="Reebok Shaq Attaq" /&gt;
&lt;meta property="og:description" content="Limited edition Shaquille O'neil basketball shoes." /&gt;
&lt;meta property="og:url" content="http://shop.example.com/product/SA-001" /&gt;
&lt;meta property="og:image" content="http://shop.example.com/images/store/SA-001.jpg" /&gt;
&lt;meta property="og:site_name" content="Example Store" /&gt;
&lt;meta property="og:price:amount" content="119.00" /&gt;
&lt;meta property="og:price:standard_amount" content="159.00" /&gt;
&lt;meta property="og:price:currency" content="USD" /&gt;
&lt;meta property="og:availability" content="instock" /&gt;
&lt;meta property="og:see_also" content="http://shop.example.com/product/SA-001" /&gt;
&lt;meta property="og:rating" content="4.5" /&gt;
&lt;meta property="og:rating_scale" content="5" /&gt;
&lt;meta property="og:rating_count" content="33" /&gt;
&lt;meta property="product:gender" content="Men" /&gt;
&lt;meta property="product:color" content="White and Blue" /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Hello world! This is HTML5 Boilerplate with social sharing meta tags.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>You can also download or copy the bare bones <a href="https://gist.github.com/tgdev/8365308">Gist</a></p>
<p>So get adding and start sharing!</p>
<p>T</p>
</content>
</entry>
<entry>
<title>Resolution &#35;9</title>
<link rel="alternate" href="http://tgdev.github.io/blog/2014-01-01-resolution-9/"/>
<id>http://tgdev.github.io/blog/2014-01-01-resolution-9/</id>
<published>2013-12-31T13:00:00Z</published>
<updated>2015-04-02T11:59:48+11:00</updated>
<content type="html"><p>It’s really quite simple: do more.</p>
<p>I feel the need to participate and put myself out there more than I have in the past.</p>
<p>To quote weezer:</p>
<blockquote>
<p>I don’t wanna be an old man anymore /
It’s been a year or two since I was out on the floor /
Shakin’ booty, makin’ sweet love all the night /
It’s time I got back to the Good Life /
It’s time I got back, it’s time I got back /
And I don’t even know how I got off the track /
I wanna go back…Yeah!</p>
</blockquote>
<p>So that means more;</p>
<ul>
<li>blogging</li>
<li>reading</li>
<li>basketball</li>
<li>travel</li>
<li>time with friends</li>
<li>learning new skills</li>
<li>challenging myself</li>
</ul>
<p>Hopefully this blog will help achieve a lot of the above.</p>
<p>Happy new year!</p>
<p>T</p>
</content>
</entry>
<entry>
<title>Page Alive!</title>
<link rel="alternate" href="http://tgdev.github.io/blog/2013-12-31-page-alive/"/>
<id>http://tgdev.github.io/blog/2013-12-31-page-alive/</id>
<published>2013-12-30T13:00:00Z</published>
<updated>2015-04-02T11:59:48+11:00</updated>
<content type="html"><p>I first stumbled across <a href="http://middlemanapp.com/basics/dynamic-pages/">Middleman’s dynamic pages</a> feature on a freelance project I was working on for a friend of mine. The site was for a local event manager who wanted to showcase several (I think it was about 10) of their most recent events.</p>
<p>Now I’m not a huge fan of manual coding and always look for ways to automate or reuse code so I really didn’t want to have to manually create all those pages.</p>
<p>Unfortunately the Middleman demo is a little basic for what I needed but luckily for me with a bit of digging and some communication back and forth with one of Middleman’s contributors, <a href="http://benhollis.net/about/">Ben Hollis</a>, I discovered the true power of dynamic pages.</p>
<p>Like I mentioned in the intro, all you need is 3 key ingredients; a data file, a template and a couple of lines in your <code>config.rb</code> file.</p>
<p>Here’s how I have implemented it.</p>
<h2 id="data-file">1. Data file</h2>
<p>On the same level as my source (and eventually build) directories I created a <code>data</code> directory. Within my newly created data directory I created a new YAML file called <code>projects.yml</code> (Middleman also supports JSON data).</p>
<p>This YAML file contained all the data properties of a project and was to be used for looping through and outputting each project’s details into a template.</p>
<p>Let’s say each project has a client, title, description and list of event manager’s responsibilities.</p>
<p>Our <code>projects.yml</code> file looks something like this;</p>
<pre class="code--block"><code> - client: client1
title: "First project"
description: "This is a description of the 1st project."
responsibilities:
"&lt;li&gt;catering&lt;/li&gt;
&lt;li&gt;venue management&lt;/li&gt;
&lt;li&gt;event staffing&lt;/li&gt;"
- client: client2
title: "Second project"
description: "This is a description of the 2nd project."
responsibilities:
"&lt;li&gt;catering&lt;/li&gt;"
</code></pre>
<h2 id="template">2. Template</h2>
<p>In my project (within the source directory) I created a new directory called <code>projects</code> (as this is what I was going to be displaying). Inside the projects directory I created <code>template.html.erb</code>. This file is to be referenced in <code>config.rb</code> as the template to use for generating the individual project pages.</p>
<p>The template looks like this;</p>
<pre class="code--block"><code>&lt;% p = locals[:project] %&gt;
&lt;div class="l-wrapper"&gt;
&lt;div class="l-content"&gt;
&lt;h2&gt;&lt;%= p[:title] %&gt;&lt;/h2&gt;
&lt;%= p[:description] %&gt;
&lt;p class="highlight"&gt;Key responsibilities:&lt;/p&gt;
&lt;ul class="itemised-list"&gt;
&lt;%= p[:responsibilities] %&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
</code></pre>
<p>Don’t worry about the <code>&lt;% p = locals[:project] %&gt;</code> at the top of the file, locals[:project] is defined in <code>config.rb</code> and will be explained in the next section.</p>
<p>‘p’ stores the project data object and is then used to access each property of the project such as title, description and the list of responsibilities.</p>
<h2 id="configuration">3. Configuration</h2>
<p>The final piece of the puzzle lies in the <code>config.rb</code> file with this block;</p>
<pre class="code--block"><code>data.projects.each do |pd|
proxy "/projects/#{pd[:client]}.html", "/projects/template.html", :layout =&gt; :popup, :locals =&gt; { :project =&gt; pd }, :ignore =&gt; true
end
</code></pre>
<p>What this block is doing is as follows;</p>
<p><strong>data.projects.each do |pd|</strong> is looping through each project item in <code>projects.yml</code></p>
<p><strong>proxy</strong> is creating a dummy url using the client property of the project item within <code>projects.yml</code> and is being passed the template file in the projects directory. eg: “www.site.com/projects/client1.html”</p>
<p><strong>layout</strong> is pointing to a custom layout which resides in the <code>layouts</code> directory and is different from the standard site layout.</p>
<p><em>You can also set layout to false if your template has all the html in it (rather than using partial includes)</em></p>
<p><strong>locals</strong> is what passes the data in <code>project.yml</code> to the template (remember p = locals[:projects])</p>
<p><strong>ignore</strong> tells middleman not to create a html file for template.html.erb as we only want html files for each of the projects.</p>
<p>So once that’s all setup all you need to do is fire up middleman server and test it out by going to; http://localhost:4567/projects/client1.html</p>
<p>This really is a handy feature and you can get pretty creative with what you store in your data files and how you render that data in the template. Also, remember if you’re not too keen on YAML, Middleman also supports JSON.</p>
<p>So go nuts and start adding dynamic pages to your not-so-static Middleman site!</p>
<p>T</p>
</content>
</entry>
<entry>
<title>Page by numbers</title>
<link rel="alternate" href="http://tgdev.github.io/blog/2013-12-30-page-by-numbers/"/>
<id>http://tgdev.github.io/blog/2013-12-30-page-by-numbers/</id>
<published>2013-12-29T13:00:00Z</published>
<updated>2015-04-02T11:59:48+11:00</updated>
<content type="html"><h2 id="configuration">Configuration.</h2>
<p>Inside the <code>activate:blog do |blog|</code> block of my <code>config.rb</code> file, I added the following pagination settings;</p>
<pre class="code--block"><code>blog.paginate = true
blog.page_link = "page:num"
blog.per_page = 5
</code></pre>
<p>Although they’re pretty straight forward, demos and explainations of the above settings can be found in the <a href="http://middlemanapp.com/basics/blogging/#toc_10">Middleman docs</a>.</p>
<h2 id="template">Template.</h2>
<p>This is where I had a little difficulty.</p>
<p>In order for pagnination to work after setting up pagination in <code>config.rb</code>, I needed to add in a little frontmatter tag to the top of the template I wanted to paginate. This is very important. Forget to include this and the rest of the code is useless.</p>
<pre class="code--block"><code>---
pageable: true
---
</code></pre>
<p>Add this to the top of any template you want to use pagination on. The homepage of my site is the only place I require any pagination for the time being so I added this to top of the <code>index.html.erb</code> file in the root of my site.</p>
<p>This essentially tells middleman that we want to split up the contents of this site into manageable pages. Middleman then uses the settings in your <code>config.rb</code> file to figure out how many items per page.</p>
<h3 id="show-me-the-pages">Show me the pages</h3>
<p>So after configuring and enabling pagination on my site I needed to output the markup. I opted for a fairly simple pagination pattern that shows “Articles X to Y of Z” with next (newer) and previous (older) navigation. To do this I needed to use some of Middleman’s built-in pagination variables;</p>
<ul>
<li>page_start</li>
<li>page_end</li>
<li>prev_page</li>
<li>prev_page.url</li>
<li>next_page</li>
<li>next_page.url</li>
</ul>
<p>The final code snippet looks like this;</p>
<pre class="code--block"><code>&lt;div class="article pagination"&gt;
&lt;p class="pagination__summary"&gt;Articles &lt;%= page_start %&gt; to &lt;%= page_end %&gt; of &lt;%= articles.length %&gt;&lt;/p&gt;
&lt;ul class="list--clean list--pagination"&gt;
&lt;% if prev_page %&gt;
&lt;li class="prev"&gt;
&lt;a href="&lt;%= prev_page.url %&gt;"&gt;Older articles&lt;/a&gt;
&lt;/li&gt;
&lt;% end %&gt;
&lt;% if next_page %&gt;
&lt;li class="next"&gt;
&lt;a href="&lt;%= next_page.url %&gt;"&gt;Newer articles&lt;/a&gt;
&lt;/li&gt;
&lt;% end %&gt;
&lt;/ul&gt;
&lt;/div&gt;
</code></pre>
<p>So there you have it, pagination on a static site thanks to Middleman. Hopefully that helps clear things up for some people looking to achieve the same or a similar result.</p>
<p>T</p>
</content>
</entry>
<entry>
<title>The bells and the whistles</title>
<link rel="alternate" href="http://tgdev.github.io/blog/2013-12-29-the-bells-and-the-whistles/"/>
<id>http://tgdev.github.io/blog/2013-12-29-the-bells-and-the-whistles/</id>
<published>2013-12-28T13:00:00Z</published>
<updated>2015-04-02T11:59:48+11:00</updated>
<content type="html"><p>The <a href="http://middlemanapp.com/basics/blogging/">Middleman docs on blogging</a> have a lot of great info to get you started with building your own blog using middleman but if you want more of a step by step how-to, <a href="http://designbyjoel.com/">Design by Joel</a> has a really great article on <a href="http://designbyjoel.com/blog/2012-10-20-building-a-blog-in-middleman/">building a blog in middleman</a>.</p>
<p>Enjoy!</p>
<p>T</p>
</content>
</entry>
</feed>