tumblargh 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,6 +8,14 @@ module Tumblargh
8
8
  super(attrs)
9
9
  end
10
10
 
11
+ def type
12
+ if @attributes[:type] == 'photo'
13
+ photos.size > 1 ? 'photoset' : 'photo'
14
+ else
15
+ @attributes[:type]
16
+ end
17
+ end
18
+
11
19
  # Override method_missing so this does not propagate
12
20
  def title
13
21
  @attributes[:title]
@@ -19,15 +27,7 @@ module Tumblargh
19
27
 
20
28
  def photo_url(size=500)
21
29
  return nil if (photos.nil? || photos.empty?)
22
-
23
- size = size.to_i
24
-
25
- orig = photos.first[:original_size]
26
- res = photos.first[:alt_sizes].select do |p|
27
- p[:width] == size
28
- end
29
-
30
- res.empty? ? orig[:url] : res.first[:url]
30
+ photos.first.photo_url size
31
31
  end
32
32
 
33
33
  def video(size=500)
@@ -57,6 +57,14 @@ module Tumblargh
57
57
  @notes = ary.map { |n| Note.new(n) }
58
58
  end
59
59
 
60
+ def dialogue
61
+ @dialogue ||= (@attributes[:dialogue] || []).map { |t| Dialogue.new(t) }
62
+ end
63
+
64
+ def photos
65
+ @photos ||= (@attributes[:photos] || []).map { |p| Photo.new(p) }
66
+ end
67
+
60
68
  end
61
69
 
62
70
  end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ describe Tumblargh::Renderer::Blocks do
5
+
6
+ before do
7
+ @parser = Tumblargh::Parser.new
8
+ end
9
+
10
+ describe "{block:PermalinkPage}" do
11
+ before do
12
+ @parser.html = <<-eos
13
+ {block:PermalinkPage}
14
+ ERMAGERD PERMERLINK
15
+ {/block:PermalinkPage}
16
+ eos
17
+ end
18
+
19
+ it "should render its content when it is a permalink page" do
20
+ @document = Tumblargh::Renderer::Document.new(@parser.tree, nil, :permalink => true)
21
+ @output = @document.render
22
+ @output.should match(/ERMAGERD PERMERLINK/)
23
+ end
24
+
25
+ it "should NOT render its content when it is a permalink page" do
26
+ @document = Tumblargh::Renderer::Document.new(@parser.tree, nil, :permalink => false)
27
+ @output = @document.render
28
+ @output.should_not match(/ERMAGERD PERMERLINK/)
29
+ end
30
+
31
+ end
32
+
33
+ describe "boolean blocks" do
34
+
35
+ before do
36
+ @parser.html = <<-eos
37
+ {block:IfSomethingOnByDefault}
38
+ PASS_ON
39
+ {/block:IfSomethingOnByDefault}
40
+
41
+ {block:IfSomethingOffByDefault}
42
+ FAIL_OFF
43
+ {/block:IfSomethingOffByDefault}
44
+
45
+ {block:IfNotSomethingOnByDefault}
46
+ FAIL_INVERSE_ON
47
+ {/block:IfNotSomethingOnByDefault}
48
+
49
+ {block:IfNotSomethingOffByDefault}
50
+ PASS_INVERSE_OFF
51
+ {/block:IfNotSomethingOffByDefault}
52
+ eos
53
+
54
+ options = {
55
+ "if" => {
56
+ "somethingonbydefault" => true,
57
+ "somethingoffbydefault" => false
58
+ }
59
+ }
60
+
61
+ @document = Tumblargh::Renderer::Document.new(@parser.tree, nil, options)
62
+ @output = @document.render
63
+ end
64
+
65
+ it "should respect the default settings" do
66
+ @output.should match(/PASS_ON/)
67
+ @output.should_not match(/FAIL_OFF/)
68
+ end
69
+
70
+
71
+ it "inverse (IfNot) blocks should work" do
72
+ @output.should_not match(/FAIL_INVERSE_ON/)
73
+ @output.should match(/PASS_INVERSE_OFF/)
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -3,53 +3,17 @@ require 'spec_helper'
3
3
 
4
4
  describe Tumblargh::Renderer::Document do
5
5
 
6
- before do
7
- @parser = Tumblargh::Parser.new
8
- end
9
-
10
- describe "boolean blocks" do
6
+ describe "permalink pages" do
11
7
 
12
8
  before do
13
- @parser.html = <<-eos
14
- {block:IfSomethingOnByDefault}
15
- PASS_ON
16
- {/block:IfSomethingOnByDefault}
17
-
18
- {block:IfSomethingOffByDefault}
19
- FAIL_OFF
20
- {/block:IfSomethingOffByDefault}
21
-
22
- {block:IfNotSomethingOnByDefault}
23
- FAIL_INVERSE_ON
24
- {/block:IfNotSomethingOnByDefault}
25
-
26
- {block:IfNotSomethingOffByDefault}
27
- PASS_INVERSE_OFF
28
- {/block:IfNotSomethingOffByDefault}
29
-
9
+ @parser = Tumblargh::Parser.new
10
+ @parser.html = ""
30
11
 
31
- eos
32
-
33
- options = {
34
- "if" => {
35
- "somethingonbydefault" => true,
36
- "somethingoffbydefault" => false
37
- }
38
- }
39
-
40
- @document = Tumblargh::Renderer::Document.new(@parser.tree, nil, options)
41
- @output = @document.render
12
+ @document = Tumblargh::Renderer::Document.new(@parser.tree, nil, :permalink => true)
42
13
  end
43
14
 
44
- it "should respect the default settings" do
45
- @output.should match /PASS_ON/
46
- @output.should_not match /FAIL_OFF/
47
- end
48
-
49
-
50
- it "inverse (IfNot) blocks should work" do
51
- @output.should_not match /FAIL_INVERSE_ON/
52
- @output.should match /PASS_INVERSE_OFF/
15
+ it "the document should know this is a permalink page" do
16
+ @document.permalink?.should be_true
53
17
  end
54
18
 
55
19
  end
data/tumblargh.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "tumblargh"
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jason Webster"]
12
- s.date = "2012-05-06"
13
- s.description = "# Tumblargh\n## Groan-less Tumblr theme development\n\n### What is this thing, and why should I care?\n\nIf you've ever had to build a Tumblr theme, you've probably cried out in pain \nwhile tweaking locally, copying, pasting into the theme editor, saving, switching\ntabs and finally refreshing and waiting for your tesing blog to reload.\n\nTumblargh aims to reduce suffering involved with building a theme by offering \na way to fully develop, lint and test Tumblr themes locally, with real posts \nfrom any existing Tumblog.\n\n### Getting Started\n\nYou'll need to get an OAuth consumer key for the Tumblr v2 API to use remote data\nwith Tumblargh. Registration is simple enough, just go to http://www.tumblr.com/oauth/apps\nand fill out the form. Any time Tumblargh asks for your API key, it'll be the \nOAuth Consumer key provided there.\n\n#### Middleman\n\nThe recommended way to use tumblargh is in conjuction with \n[Middleman](http://middlemanapp.com/).\n\n> Middleman is a static site generator based on Sinatra. Providing dozens of \ntemplating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more).\n\nTumblargh includes a simple Middleman extension that turns any Middleman project\ninto a local Tumblr theme building machine.\n\nTumblargh will automatically parse any html files served by Middleman, and \npopulate them with content from the Tumblr of your choosing. It will not\nparse any HTML during Middleman's build process. The output of`middleman build` \nis ready for use on your blog, or submission to the Tumblr theme store.\n\nTo get up an running with Middleman, first create a new Middleman project:\n\n```\n$ middleman init MY_PROJECT_NAME\n```\n\nIf one does not already exist, create a Gemfile and add the following as needed:\n\n```ruby\nsource \"http://rubygems.org\"\n\ngem 'middleman'\ngem 'tumblargh', :git => 'git://github.com/jasonwebster/tumblargh.git'\n```\n\nNote that there has not yet been an official release of tumblargh to RubyGems,\nso currently, specifying the gem via git is necessary.\n\nRun `bundle install`.\n\nThe bare minimum setup in your Middleman config.rb is:\n\n```ruby\nrequire 'tumblargh'\nrequire 'middleman/features/tumblargh'\n\nactivate :tumblargh\n\nset_tumblr_api_key 'API KEY' # This is your OAuth consumer key\nset_tumblr_blog 'staff.tumblr.com'\n```\n\nIt is highly recommended to run the Middleman server via `bundle exec`.\n\n#### Rack\n\nSee `examples/config.ru` for a minimal Rack setup, ready to go with `rackup` or\nyour Ruby server of choice.\n\n### Known issues & planned features\n\n- Source attribution `{block:ContentSource}`\n- Your likes `{block:Likes}`\n- Twitter integration `{block:Twitter}`\n- Custom page support\n\n\n\n"
12
+ s.date = "2012-09-16"
13
+ s.description = "If you've ever had to build a Tumblr theme, you've probably cried out in pain while tweaking locally, copying, pasting into the theme editor, saving, switching tabs and finally refreshing and waiting for your tesing blog to reload. Tumblargh aims to reduce suffering involved with building a theme by offering a way to fully develop, lint and test Tumblr themes locally, with real posts from any existing Tumblog."
14
14
  s.email = "jason@metalabdesign.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "examples/confg.ru",
29
29
  "examples/middleman_config.rb",
30
- "lib/middleman/features/tumblargh.rb",
30
+ "lib/middleman/extensions/tumblargh.rb",
31
31
  "lib/rack/tumblargh.rb",
32
32
  "lib/tumblargh.rb",
33
33
  "lib/tumblargh/api.rb",
@@ -44,12 +44,15 @@ Gem::Specification.new do |s|
44
44
  "lib/tumblargh/parser.rb",
45
45
  "lib/tumblargh/renderer.rb",
46
46
  "lib/tumblargh/renderer/base.rb",
47
+ "lib/tumblargh/renderer/blocks.rb",
47
48
  "lib/tumblargh/renderer/blocks/answer.rb",
48
49
  "lib/tumblargh/renderer/blocks/audio.rb",
49
50
  "lib/tumblargh/renderer/blocks/base.rb",
51
+ "lib/tumblargh/renderer/blocks/chat.rb",
50
52
  "lib/tumblargh/renderer/blocks/dates.rb",
51
53
  "lib/tumblargh/renderer/blocks/navigation.rb",
52
54
  "lib/tumblargh/renderer/blocks/notes.rb",
55
+ "lib/tumblargh/renderer/blocks/photoset.rb",
53
56
  "lib/tumblargh/renderer/blocks/posts.rb",
54
57
  "lib/tumblargh/renderer/blocks/reblogs.rb",
55
58
  "lib/tumblargh/renderer/blocks/tags.rb",
@@ -59,7 +62,9 @@ Gem::Specification.new do |s|
59
62
  "lib/tumblargh/resource.rb",
60
63
  "lib/tumblargh/resource/base.rb",
61
64
  "lib/tumblargh/resource/blog.rb",
65
+ "lib/tumblargh/resource/dialogue.rb",
62
66
  "lib/tumblargh/resource/note.rb",
67
+ "lib/tumblargh/resource/photo.rb",
63
68
  "lib/tumblargh/resource/post.rb",
64
69
  "lib/tumblargh/resource/tag.rb",
65
70
  "lib/tumblargh/resource/user.rb",
@@ -69,6 +74,7 @@ Gem::Specification.new do |s|
69
74
  "spec/fixtures/themes/solstice.html",
70
75
  "spec/parser_spec.rb",
71
76
  "spec/renderer/blocks/posts_spec.rb",
77
+ "spec/renderer/blocks_spec.rb",
72
78
  "spec/renderer/document_spec.rb",
73
79
  "spec/resource/post_spec.rb",
74
80
  "spec/resource_spec.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tumblargh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-06 00:00:00.000000000 Z
12
+ date: 2012-09-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70185562167220 !ruby/object:Gem::Requirement
16
+ requirement: &70144567210580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70185562167220
24
+ version_requirements: *70144567210580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: treetop
27
- requirement: &70185562166660 !ruby/object:Gem::Requirement
27
+ requirement: &70144567503240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70185562166660
35
+ version_requirements: *70144567503240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: nokogiri
38
- requirement: &70185562166060 !ruby/object:Gem::Requirement
38
+ requirement: &70144567499120 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70185562166060
46
+ version_requirements: *70144567499120
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: api_cache
49
- requirement: &70185562165540 !ruby/object:Gem::Requirement
49
+ requirement: &70144567672000 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70185562165540
57
+ version_requirements: *70144567672000
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: autotest-standalone
60
- requirement: &70185562165020 !ruby/object:Gem::Requirement
60
+ requirement: &70144567666780 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70185562165020
68
+ version_requirements: *70144567666780
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &70185562164520 !ruby/object:Gem::Requirement
71
+ requirement: &70144567681040 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70185562164520
79
+ version_requirements: *70144567681040
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rake
82
- requirement: &70185562163940 !ruby/object:Gem::Requirement
82
+ requirement: &70144567679680 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70185562163940
90
+ version_requirements: *70144567679680
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
- requirement: &70185562163140 !ruby/object:Gem::Requirement
93
+ requirement: &70144567676360 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70185562163140
101
+ version_requirements: *70144567676360
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: simplecov
104
- requirement: &70185562162340 !ruby/object:Gem::Requirement
104
+ requirement: &70144567685980 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,39 +109,13 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70185562162340
113
- description: ! "# Tumblargh\n## Groan-less Tumblr theme development\n\n### What is
114
- this thing, and why should I care?\n\nIf you've ever had to build a Tumblr theme,
115
- you've probably cried out in pain \nwhile tweaking locally, copying, pasting into
116
- the theme editor, saving, switching\ntabs and finally refreshing and waiting for
117
- your tesing blog to reload.\n\nTumblargh aims to reduce suffering involved with
118
- building a theme by offering \na way to fully develop, lint and test Tumblr themes
119
- locally, with real posts \nfrom any existing Tumblog.\n\n### Getting Started\n\nYou'll
120
- need to get an OAuth consumer key for the Tumblr v2 API to use remote data\nwith
121
- Tumblargh. Registration is simple enough, just go to http://www.tumblr.com/oauth/apps\nand
122
- fill out the form. Any time Tumblargh asks for your API key, it'll be the \nOAuth
123
- Consumer key provided there.\n\n#### Middleman\n\nThe recommended way to use tumblargh
124
- is in conjuction with \n[Middleman](http://middlemanapp.com/).\n\n> Middleman is
125
- a static site generator based on Sinatra. Providing dozens of \ntemplating languages
126
- (Haml, Sass, Compass, Slim, CoffeeScript, and more).\n\nTumblargh includes a simple
127
- Middleman extension that turns any Middleman project\ninto a local Tumblr theme
128
- building machine.\n\nTumblargh will automatically parse any html files served by
129
- Middleman, and \npopulate them with content from the Tumblr of your choosing. It
130
- will not\nparse any HTML during Middleman's build process. The output of`middleman
131
- build` \nis ready for use on your blog, or submission to the Tumblr theme store.\n\nTo
132
- get up an running with Middleman, first create a new Middleman project:\n\n```\n$
133
- middleman init MY_PROJECT_NAME\n```\n\nIf one does not already exist, create a Gemfile
134
- and add the following as needed:\n\n```ruby\nsource \"http://rubygems.org\"\n\ngem
135
- 'middleman'\ngem 'tumblargh', :git => 'git://github.com/jasonwebster/tumblargh.git'\n```\n\nNote
136
- that there has not yet been an official release of tumblargh to RubyGems,\nso currently,
137
- specifying the gem via git is necessary.\n\nRun `bundle install`.\n\nThe bare minimum
138
- setup in your Middleman config.rb is:\n\n```ruby\nrequire 'tumblargh'\nrequire 'middleman/features/tumblargh'\n\nactivate
139
- :tumblargh\n\nset_tumblr_api_key 'API KEY' # This is your OAuth consumer key\nset_tumblr_blog
140
- 'staff.tumblr.com'\n```\n\nIt is highly recommended to run the Middleman server
141
- via `bundle exec`.\n\n#### Rack\n\nSee `examples/config.ru` for a minimal Rack setup,
142
- ready to go with `rackup` or\nyour Ruby server of choice.\n\n### Known issues &
143
- planned features\n\n- Source attribution `{block:ContentSource}`\n- Your likes `{block:Likes}`\n-
144
- Twitter integration `{block:Twitter}`\n- Custom page support\n\n\n\n"
112
+ version_requirements: *70144567685980
113
+ description: If you've ever had to build a Tumblr theme, you've probably cried out
114
+ in pain while tweaking locally, copying, pasting into the theme editor, saving,
115
+ switching tabs and finally refreshing and waiting for your tesing blog to reload.
116
+ Tumblargh aims to reduce suffering involved with building a theme by offering a
117
+ way to fully develop, lint and test Tumblr themes locally, with real posts from
118
+ any existing Tumblog.
145
119
  email: jason@metalabdesign.com
146
120
  executables: []
147
121
  extensions: []
@@ -159,7 +133,7 @@ files:
159
133
  - VERSION
160
134
  - examples/confg.ru
161
135
  - examples/middleman_config.rb
162
- - lib/middleman/features/tumblargh.rb
136
+ - lib/middleman/extensions/tumblargh.rb
163
137
  - lib/rack/tumblargh.rb
164
138
  - lib/tumblargh.rb
165
139
  - lib/tumblargh/api.rb
@@ -176,12 +150,15 @@ files:
176
150
  - lib/tumblargh/parser.rb
177
151
  - lib/tumblargh/renderer.rb
178
152
  - lib/tumblargh/renderer/base.rb
153
+ - lib/tumblargh/renderer/blocks.rb
179
154
  - lib/tumblargh/renderer/blocks/answer.rb
180
155
  - lib/tumblargh/renderer/blocks/audio.rb
181
156
  - lib/tumblargh/renderer/blocks/base.rb
157
+ - lib/tumblargh/renderer/blocks/chat.rb
182
158
  - lib/tumblargh/renderer/blocks/dates.rb
183
159
  - lib/tumblargh/renderer/blocks/navigation.rb
184
160
  - lib/tumblargh/renderer/blocks/notes.rb
161
+ - lib/tumblargh/renderer/blocks/photoset.rb
185
162
  - lib/tumblargh/renderer/blocks/posts.rb
186
163
  - lib/tumblargh/renderer/blocks/reblogs.rb
187
164
  - lib/tumblargh/renderer/blocks/tags.rb
@@ -191,7 +168,9 @@ files:
191
168
  - lib/tumblargh/resource.rb
192
169
  - lib/tumblargh/resource/base.rb
193
170
  - lib/tumblargh/resource/blog.rb
171
+ - lib/tumblargh/resource/dialogue.rb
194
172
  - lib/tumblargh/resource/note.rb
173
+ - lib/tumblargh/resource/photo.rb
195
174
  - lib/tumblargh/resource/post.rb
196
175
  - lib/tumblargh/resource/tag.rb
197
176
  - lib/tumblargh/resource/user.rb
@@ -201,6 +180,7 @@ files:
201
180
  - spec/fixtures/themes/solstice.html
202
181
  - spec/parser_spec.rb
203
182
  - spec/renderer/blocks/posts_spec.rb
183
+ - spec/renderer/blocks_spec.rb
204
184
  - spec/renderer/document_spec.rb
205
185
  - spec/resource/post_spec.rb
206
186
  - spec/resource_spec.rb
@@ -221,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
221
201
  version: '0'
222
202
  segments:
223
203
  - 0
224
- hash: 3569421539013978115
204
+ hash: -3297129215557666570
225
205
  required_rubygems_version: !ruby/object:Gem::Requirement
226
206
  none: false
227
207
  requirements: