who-needs-wp 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,7 @@ require 'who-needs-wp/twitter.rb'
13
13
  require 'who-needs-wp/delicious.rb'
14
14
  require 'who-needs-wp/templates.rb'
15
15
  require 'who-needs-wp/posts.rb'
16
+ require 'who-needs-wp/pages.rb'
16
17
 
17
18
  module WhoNeedsWP
18
19
  # A list of HTML strings which will be the sidebar
@@ -28,10 +29,13 @@ module WhoNeedsWP
28
29
  @options = options
29
30
  self.load_templates
30
31
  self.load_posts
32
+ self.load_pages
33
+ self.recentposts
34
+ self.page_index
31
35
  self.twitter
32
36
  self.delicious
33
- self.recentposts
34
37
  self.generate_posts
38
+ self.generate_pages
35
39
  self.index
36
40
  self.css
37
41
  end
@@ -44,7 +48,8 @@ module WhoNeedsWP
44
48
  file.puts @template['layout'].render(Object.new, {
45
49
  :content => contents,
46
50
  :options => @options,
47
- :sidebar => @sidebar.join
51
+ :sidebar => @sidebar.join,
52
+ :layout_name => "index"
48
53
  })
49
54
  end
50
55
  end
@@ -0,0 +1,54 @@
1
+
2
+ module WhoNeedsWP
3
+ def self.load_pages
4
+ @pages = []
5
+ Dir.glob('pages/*.markdown').each do |filename|
6
+ @logger.debug "Loading page #{filename}"
7
+ match = filename.match(/.*\/([^\.]*)/)
8
+ @pages << {
9
+ :filename => {
10
+ :original => filename,
11
+ :generated => File.dirname(filename) + "/" + File.basename(filename, ".markdown") + ".html"
12
+ },
13
+ :title => match[1].gsub(/_/, ' ')
14
+ }
15
+ end
16
+ end
17
+
18
+
19
+ def self.page_index
20
+ @sidebar << @template['pageindex'].render(Object.new, {
21
+ :pages => @pages,
22
+ :options => @options
23
+ })
24
+ end
25
+
26
+ def self.generate_pages
27
+ @pages.each do |page|
28
+ File.open(page[:filename][:generated], "w") do |file|
29
+ markdown = File.read(page[:filename][:original])
30
+ page[:author] = @options[:author]
31
+ match = markdown.match(/^[aA]uthor: (.*)$/o)
32
+ if match
33
+ page[:author] = match[1]
34
+ # Remove the author from the post text
35
+ markdown.gsub! /^[aA]uthor: .*$/, ''
36
+ end
37
+ # post[:markdown] = RDiscount.new(markdown, :smart, :generate_toc).to_html
38
+ page[:markdown] = MakersMark.generate(markdown)
39
+ page[:html] = @template['page'].render(Object.new, {
40
+ :page => page,
41
+ :title => page[:title],
42
+ :options => @options
43
+ })
44
+ file.puts @template['layout'].render(Object.new, {
45
+ :content => page[:html],
46
+ :options => @options,
47
+ :title => page[:title],
48
+ :sidebar => @sidebar.join,
49
+ :layout_name => "page"
50
+ })
51
+ end
52
+ end
53
+ end
54
+ end
@@ -28,7 +28,10 @@ module WhoNeedsWP
28
28
  end
29
29
 
30
30
  def self.generate_posts
31
- @POSTS.each do |post|
31
+ @POSTS.each_index do |index|
32
+ post = @POSTS[index]
33
+ previous_post = @POSTS[index + 1] if index + 1 < @POSTS.length
34
+ next_post = @POSTS[index - 1] if index > 1
32
35
  File.open(post[:filename][:generated], "w") do |file|
33
36
  markdown = File.read(post[:filename][:original])
34
37
  post[:author] = @options[:author]
@@ -43,13 +46,16 @@ module WhoNeedsWP
43
46
  post[:html] = @template['post'].render(Object.new, {
44
47
  :post => post,
45
48
  :title => post[:title],
46
- :options => @options
49
+ :options => @options,
50
+ :next_post => next_post,
51
+ :previous_post => previous_post
47
52
  })
48
53
  file.puts @template['layout'].render(Object.new, {
49
54
  :content => post[:html],
50
55
  :options => @options,
51
56
  :title => post[:title],
52
- :sidebar => @sidebar.join
57
+ :sidebar => @sidebar.join,
58
+ :layout_name => "post"
53
59
  })
54
60
  end
55
61
  end
@@ -1,3 +1,6 @@
1
1
  @import reset-fonts-grids.sass
2
2
  @import base.sass
3
3
  @import pygments.sass
4
+
5
+ #content.index .navigation
6
+ display: none
@@ -20,7 +20,7 @@
20
20
  .yui-b
21
21
  .yui-gc
22
22
  .yui-u.first
23
- =content
23
+ #content{:class => "#{layout_name}"}= content
24
24
  .yui-u
25
25
  =sidebar
26
26
  .yui-b
@@ -0,0 +1,9 @@
1
+
2
+ .page
3
+ %h2.title
4
+ %a{:href => "#{options[:url]}/#{page[:filename][:generated]}"}= page[:title]
5
+ .author
6
+ by
7
+ = page[:author]
8
+ .content
9
+ ~ page[:markdown]
@@ -0,0 +1,6 @@
1
+ - if pages.length > 0
2
+ %h2 Pages
3
+ %ul
4
+ - pages.each do |page|
5
+ %li
6
+ %a.title{:href => "#{options[:url]}/#{page[:filename][:generated]}", :title => page[:title]}= page[:title]
@@ -9,3 +9,17 @@
9
9
  = post[:author]
10
10
  .content
11
11
  ~ post[:markdown]
12
+
13
+ - if previous_post or next_post
14
+ .navigation
15
+ %h3 Navigation
16
+ %ul
17
+ - if previous_post
18
+ %li
19
+ Previous:
20
+ %a.next{:href => "#{options[:url]}/#{previous_post[:filename][:generated]}", :title => "#{previous_post[:title]}"}= "#{previous_post[:title]}"
21
+
22
+ - if next_post
23
+ %li
24
+ Next:
25
+ %a.next{:href => "#{options[:url]}/#{next_post[:filename][:generated]}", :title => "#{next_post[:title]}"}= "#{next_post[:title]}"
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Owen Griffin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-16 00:00:00 +00:00
17
+ date: 2010-03-17 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -115,15 +115,17 @@ files:
115
115
  - lib/who-needs-wp.rb
116
116
  - lib/who-needs-wp/css.rb
117
117
  - lib/who-needs-wp/delicious.rb
118
+ - lib/who-needs-wp/pages.rb
118
119
  - lib/who-needs-wp/posts.rb
119
120
  - lib/who-needs-wp/stylesheets/base.sass
120
121
  - lib/who-needs-wp/stylesheets/pygments.sass
121
122
  - lib/who-needs-wp/stylesheets/reset-fonts-grids.sass
122
123
  - lib/who-needs-wp/stylesheets/style.sass
123
124
  - lib/who-needs-wp/templates.rb
124
- - lib/who-needs-wp/templates/#recentposts.haml#
125
125
  - lib/who-needs-wp/templates/delicious.haml
126
126
  - lib/who-needs-wp/templates/layout.haml
127
+ - lib/who-needs-wp/templates/page.haml
128
+ - lib/who-needs-wp/templates/pageindex.haml
127
129
  - lib/who-needs-wp/templates/post.haml
128
130
  - lib/who-needs-wp/templates/recentposts.haml
129
131
  - lib/who-needs-wp/templates/twitter.haml
@@ -1,6 +0,0 @@
1
- %h2 Recent Posts
2
- %ul
3
- - posts.each do |post|
4
- %li
5
- %span.date= post[:created_at].strftime('%Y-%m-%d')
6
- %a.title{:href => "#{options[:url]}/#{post[:filename][:generated]}", :title => post[:title]}= post[:title]