nesta 0.9.5 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,34 @@
1
+ = 0.9.7 / (19 August 2011)
2
+
3
+ * No code changes from 0.9.6; version number increased to allow new gem
4
+ to be deployed to rubygems.org.
5
+
6
+ = 0.9.6 / (18 August 2011) [never released due to packaging bug]
7
+
8
+ * Nesta no longer cares whether you write your Sass stylesheets in the
9
+ original indented Sass format or the default SCSS syntax (which is a
10
+ superset of CSS). To use this functionality within your own site or
11
+ theme change change any calls to the existing `sass` or `scss`
12
+ helpers to `stylesheet`. (Isaac Cambron, Graham Ashton)
13
+
14
+ * Add an HTML class ("current") to the menu items whose path matches
15
+ the current page.
16
+
17
+ * Bug fix: Strip trailing # characters from Markdown headings at the
18
+ top of a page.
19
+
20
+ * Bug fix: Don't render the return value of local_stylesheet_link_tag
21
+ directly into the page (haml_tag now writes direct to the output
22
+ buffer).
23
+
24
+ * Bug fix: Removed trailing whitespace inside <a> tags generated by
25
+ the display_breadcrumbs() helper.
26
+
27
+ * Bug fix: Nesta::App.root couldn't be set until after nesta/app was
28
+ required. Odd that, as the only reason to want to change
29
+ Nesta::App.root would be before requiring nesta/app. Fixed by
30
+ creating Nesta::Env and moving root to there instead.
31
+
1
32
  = 0.9.5 / (1 May 2011)
2
33
 
3
34
  * Added --version option to nesta command (Christopher Lindblom).
@@ -13,9 +44,6 @@
13
44
  * Bug fix: Removed trailing whitespace inside <a> tags generated by
14
45
  the display_menu() helper.
15
46
 
16
- * Updated the URL from which Disqus JavaScript is loaded
17
- (Sidharta Surya Kusnanto).
18
-
19
47
  * Bug fix: Made article_summaries render summaries for the pages
20
48
  passed into it (Robert Syme).
21
49
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nesta (0.9.5)
4
+ nesta (0.9.7)
5
5
  RedCloth (~> 4.2)
6
6
  haml (~> 3.1)
7
7
  maruku (>= 0.6.0)
@@ -13,7 +13,7 @@ GEM
13
13
  remote: http://rubygems.org/
14
14
  specs:
15
15
  RedCloth (4.2.7)
16
- haml (3.1.1)
16
+ haml (3.1.2)
17
17
  hoe (2.6.2)
18
18
  rake (>= 0.8.7)
19
19
  rubyforge (>= 2.0.4)
@@ -29,7 +29,7 @@ GEM
29
29
  rspec_hpricot_matchers (1.0)
30
30
  rubyforge (2.0.4)
31
31
  json_pure (>= 1.1.7)
32
- sass (3.1.1)
32
+ sass (3.1.5)
33
33
  shotgun (0.9)
34
34
  rack (>= 1.0)
35
35
  sinatra (1.1.2)
@@ -38,7 +38,7 @@ GEM
38
38
  syntax (1.0.0)
39
39
  test-unit (1.2.3)
40
40
  hoe (>= 1.5.1)
41
- tilt (1.3)
41
+ tilt (1.3.2)
42
42
 
43
43
  PLATFORMS
44
44
  ruby
data/config.ru CHANGED
@@ -4,6 +4,7 @@ require 'bundler/setup'
4
4
  Bundler.require(:default)
5
5
 
6
6
  $LOAD_PATH.unshift(::File.expand_path('lib', ::File.dirname(__FILE__)))
7
+ require 'nesta/env'
7
8
  require 'nesta/app'
8
9
 
9
10
  run Nesta::App
data/lib/nesta/app.rb CHANGED
@@ -83,11 +83,11 @@ module Nesta
83
83
 
84
84
  def local_stylesheet?
85
85
  Nesta.deprecated('local_stylesheet?', 'use local_stylesheet_link_tag')
86
- File.exist?(File.expand_path('views/local.sass', Nesta::App.root))
86
+ File.exist?(File.expand_path('views/local.sass', Nesta::Env.root))
87
87
  end
88
88
 
89
89
  def local_stylesheet_link_tag(name)
90
- pattern = File.expand_path("views/#{name}.s{a,c}ss", Nesta::App.root)
90
+ pattern = File.expand_path("views/#{name}.s{a,c}ss", Nesta::Env.root)
91
91
  if Dir.glob(pattern).size > 0
92
92
  haml_tag :link, :href => "/css/#{name}.css", :rel => "stylesheet"
93
93
  end
@@ -125,7 +125,7 @@ module Nesta
125
125
 
126
126
  get '/css/:sheet.css' do
127
127
  content_type 'text/css', :charset => 'utf-8'
128
- cache sass(params[:sheet].to_sym)
128
+ cache stylesheet(params[:sheet].to_sym)
129
129
  end
130
130
 
131
131
  get %r{/attachments/([\w/.-]+)} do
data/lib/nesta/config.rb CHANGED
@@ -46,7 +46,7 @@ module Nesta
46
46
  end
47
47
 
48
48
  def self.yaml_path
49
- File.expand_path('config/config.yml', Nesta::App.root)
49
+ File.expand_path('config/config.yml', Nesta::Env.root)
50
50
  end
51
51
 
52
52
  def self.from_environment(setting)
data/lib/nesta/env.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Nesta
2
+ class Env
3
+ class << self
4
+ attr_accessor :root
5
+ end
6
+ end
7
+ end
data/lib/nesta/models.rb CHANGED
@@ -170,7 +170,7 @@ module Nesta
170
170
  def heading
171
171
  regex = case @format
172
172
  when :mdown
173
- /^#\s*(.*)/
173
+ /^#\s*(.*?)(\s*#+|$)/
174
174
  when :haml
175
175
  /^\s*%h1\s+(.*)/
176
176
  when :textile
@@ -194,12 +194,12 @@ module Nesta
194
194
 
195
195
  def date(format = nil)
196
196
  @date ||= if metadata("date")
197
- if format == :xmlschema
198
- Time.parse(metadata("date")).xmlschema
199
- else
200
- DateTime.parse(metadata("date"))
201
- end
202
- end
197
+ if format == :xmlschema
198
+ Time.parse(metadata("date")).xmlschema
199
+ else
200
+ DateTime.parse(metadata("date"))
201
+ end
202
+ end
203
203
  end
204
204
 
205
205
  def atom_id
@@ -21,7 +21,8 @@ module Nesta
21
21
  end
22
22
  end
23
23
  else
24
- haml_tag :li do
24
+ html_class = (request.path == item.abspath) ? "current" : nil
25
+ haml_tag :li, :class => html_class do
25
26
  haml_tag :a, :<, :href => item.abspath do
26
27
  haml_concat item.heading
27
28
  end
@@ -43,7 +44,7 @@ module Nesta
43
44
  haml_tag :ul, :class => options[:class] do
44
45
  breadcrumb_ancestors[0...-1].each do |page|
45
46
  haml_tag :li do
46
- haml_tag :a, :href => page.abspath do
47
+ haml_tag :a, :<, :href => page.abspath do
47
48
  haml_concat breadcrumb_label(page)
48
49
  end
49
50
  end
@@ -2,19 +2,25 @@ module Nesta
2
2
  module Overrides
3
3
  module Renderers
4
4
  def haml(template, options = {}, locals = {})
5
- defaults = Overrides.render_options(template, :haml)
5
+ defaults, engine = Overrides.render_options(template, :haml)
6
6
  super(template, defaults.merge(options), locals)
7
7
  end
8
8
 
9
9
  def scss(template, options = {}, locals = {})
10
- defaults = Overrides.render_options(template, :scss)
10
+ defaults, engine = Overrides.render_options(template, :scss)
11
11
  super(template, defaults.merge(options), locals)
12
12
  end
13
13
 
14
14
  def sass(template, options = {}, locals = {})
15
- defaults = Overrides.render_options(template, :sass)
15
+ defaults, engine = Overrides.render_options(template, :sass)
16
16
  super(template, defaults.merge(options), locals)
17
17
  end
18
+
19
+ def stylesheet(template, options = {}, locals = {})
20
+ defaults, engine = Overrides.render_options(template, :sass, :scss)
21
+ renderer = Sinatra::Templates.instance_method(engine)
22
+ renderer.bind(self).call(template, defaults.merge(options), locals)
23
+ end
18
24
  end
19
25
 
20
26
  def self.load_local_app
@@ -34,14 +40,15 @@ module Nesta
34
40
  views && File.exist?(File.join(views, "#{template}.#{engine}"))
35
41
  end
36
42
 
37
- def self.render_options(template, engine)
38
- if template_exists?(engine, local_view_path, template)
39
- { :views => local_view_path }
40
- elsif template_exists?(engine, theme_view_path, template)
41
- { :views => theme_view_path }
42
- else
43
- {}
43
+ def self.render_options(template, *engines)
44
+ [local_view_path, theme_view_path].each do |path|
45
+ engines.each do |engine|
46
+ if template_exists?(engine, path, template)
47
+ return { :views => path }, engine
48
+ end
49
+ end
44
50
  end
51
+ [{}, nil]
45
52
  end
46
53
 
47
54
  def self.local_view_path
data/lib/nesta/path.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  module Nesta
2
2
  class Path
3
3
  def self.local(*args)
4
- File.expand_path(File.join(args), Nesta::App.root)
4
+ File.expand_path(File.join(args), Nesta::Env.root)
5
5
  end
6
6
 
7
7
  def self.themes(*args)
8
- File.expand_path(File.join('themes', *args), Nesta::App.root)
8
+ File.expand_path(File.join('themes', *args), Nesta::Env.root)
9
9
  end
10
10
  end
11
11
  end
data/lib/nesta/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nesta
2
- VERSION = '0.9.5'
2
+ VERSION = '0.9.7'
3
3
  end
@@ -115,7 +115,7 @@ describe "nesta" do
115
115
  FileUtils.mkdir_p(File.dirname(@config_path))
116
116
  Nesta::Config.stub!(:yaml_path).and_return(@config_path)
117
117
  create_config_yaml('content: path/to/content')
118
- Nesta::App.stub!(:root).and_return(@project_path)
118
+ Nesta::Env.stub!(:root).and_return(@project_path)
119
119
  @repo_url = 'git://github.com/gma/nesta-demo-content.git'
120
120
  @demo_path = project_path('content-demo')
121
121
  @command = Nesta::Commands::Demo::Content.new
@@ -265,7 +265,7 @@ describe "nesta" do
265
265
  end
266
266
 
267
267
  before(:each) do
268
- Nesta::App.stub!(:root).and_return(FixtureHelper::FIXTURE_DIR)
268
+ Nesta::Env.stub!(:root).and_return(FixtureHelper::FIXTURE_DIR)
269
269
  @name = 'my-new-theme'
270
270
  Nesta::Commands::Theme::Create.new(@name).execute
271
271
  end
data/spec/models_spec.rb CHANGED
@@ -455,12 +455,14 @@ describe "Markdown page" do
455
455
  it_should_behave_like "Page"
456
456
 
457
457
  it "should set heading from first h1 tag" do
458
- create_page(
459
- :path => "a-page",
460
- :heading => "First heading",
461
- :content => "# Second heading"
462
- )
463
- Nesta::Page.find_by_path("a-page").heading.should == "First heading"
458
+ page = create_page(
459
+ :heading => "First heading", :content => "# Second heading")
460
+ page.heading.should == "First heading"
461
+ end
462
+
463
+ it "should ignore trailing # characters in headings" do
464
+ article = create_article(:heading => 'With trailing #')
465
+ article.heading.should == 'With trailing'
464
466
  end
465
467
  end
466
468
 
@@ -27,8 +27,8 @@ describe "Rendering" do
27
27
  end
28
28
 
29
29
  before(:each) do
30
- @app_root = Nesta::App.root
31
- Nesta::App.root = File.expand_path('fixtures/tmp', File.dirname(__FILE__))
30
+ @app_root = Nesta::Env.root
31
+ Nesta::Env.root = File.expand_path('fixtures/tmp', File.dirname(__FILE__))
32
32
  @theme = 'my-theme'
33
33
  @fixtures = []
34
34
  stub_configuration
@@ -36,9 +36,23 @@ describe "Rendering" do
36
36
 
37
37
  after(:each) do
38
38
  @fixtures.each { |path| FileUtils.rm(path) if File.exist?(path) }
39
- Nesta::App.root = @app_root
39
+ Nesta::Env.root = @app_root
40
40
  end
41
41
 
42
+ describe "when rendering stylesheets" do
43
+ it "should render the SASS stylesheets" do
44
+ create_template(:local, 'master.sass', "body\n width: 10px * 2")
45
+ get "/css/master.css"
46
+ body.should match(/width: 20px;/)
47
+ end
48
+
49
+ it "should render the SCSS stylesheets" do
50
+ create_template(:local, 'master.scss', "body {\n width: 10px * 2;\n}")
51
+ get "/css/master.css"
52
+ body.should match(/width: 20px;/)
53
+ end
54
+ end
55
+
42
56
  describe "when local files exist" do
43
57
  before(:each) do
44
58
  create_template(:local, 'page.haml', '%p Local template')
data/spec/spec_helper.rb CHANGED
@@ -18,6 +18,7 @@ module Nesta
18
18
  end
19
19
  end
20
20
 
21
+ require File.expand_path('../lib/nesta/env', File.dirname(__FILE__))
21
22
  require File.expand_path('../lib/nesta/app', File.dirname(__FILE__))
22
23
 
23
24
  module FixtureHelper
data/templates/config.ru CHANGED
@@ -3,7 +3,8 @@ require 'bundler/setup'
3
3
 
4
4
  Bundler.require(:default)
5
5
 
6
- require 'nesta/app'
6
+ require 'nesta/env'
7
+ Nesta::Env.root = ::File.expand_path('.', ::File.dirname(__FILE__))
7
8
 
8
- Nesta::App.root = ::File.expand_path('.', ::File.dirname(__FILE__))
9
+ require 'nesta/app'
9
10
  run Nesta::App
data/views/layout.haml CHANGED
@@ -14,7 +14,7 @@
14
14
  %link(rel="stylesheet" href="http://universal-ie6-css.googlecode.com/files/ie6.1.1.css" media="screen, projection")
15
15
  /[if lt IE 9]
16
16
  %script(src="//html5shim.googlecode.com/svn/trunk/html5.js")
17
- = local_stylesheet_link_tag('local')
17
+ - local_stylesheet_link_tag('local')
18
18
  %link(href="/articles.xml" rel="alternate" type="application/atom+xml")
19
19
  = haml :analytics, :layout => false
20
20
  %body
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: nesta
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.5
5
+ version: 0.9.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Graham Ashton
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-01 00:00:00 +01:00
13
+ date: 2011-08-19 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -170,6 +170,7 @@ files:
170
170
  - lib/nesta/cache.rb
171
171
  - lib/nesta/commands.rb
172
172
  - lib/nesta/config.rb
173
+ - lib/nesta/env.rb
173
174
  - lib/nesta/models.rb
174
175
  - lib/nesta/navigation.rb
175
176
  - lib/nesta/nesta.rb
@@ -230,7 +231,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
230
231
  requirements:
231
232
  - - ">="
232
233
  - !ruby/object:Gem::Version
233
- hash: -1498426163218200978
234
+ hash: -3003652627560154656
234
235
  segments:
235
236
  - 0
236
237
  version: "0"
@@ -239,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
240
  requirements:
240
241
  - - ">="
241
242
  - !ruby/object:Gem::Version
242
- hash: -1498426163218200978
243
+ hash: -3003652627560154656
243
244
  segments:
244
245
  - 0
245
246
  version: "0"