nesta 0.9.11 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -11
  3. data/.gitmodules +6 -0
  4. data/.hound.yml +2 -0
  5. data/{spec/spec.opts → .rspec} +0 -0
  6. data/.travis.yml +11 -0
  7. data/CHANGES +250 -2
  8. data/Gemfile +2 -2
  9. data/Gemfile.lock +89 -33
  10. data/Guardfile +7 -0
  11. data/LICENSE +1 -1
  12. data/README.md +38 -6
  13. data/RELEASING.md +21 -0
  14. data/Rakefile +20 -4
  15. data/bin/nesta +131 -14
  16. data/config.ru +3 -0
  17. data/lib/nesta.rb +9 -1
  18. data/lib/nesta/app.rb +21 -107
  19. data/lib/nesta/commands.rb +5 -256
  20. data/lib/nesta/commands/command.rb +57 -0
  21. data/lib/nesta/commands/demo.rb +1 -0
  22. data/lib/nesta/commands/demo/content.rb +56 -0
  23. data/lib/nesta/commands/edit.rb +21 -0
  24. data/lib/nesta/commands/new.rb +57 -0
  25. data/lib/nesta/commands/plugin.rb +1 -0
  26. data/lib/nesta/commands/plugin/create.rb +82 -0
  27. data/lib/nesta/commands/theme.rb +3 -0
  28. data/lib/nesta/commands/theme/create.rb +36 -0
  29. data/lib/nesta/commands/theme/enable.rb +22 -0
  30. data/lib/nesta/commands/theme/install.rb +31 -0
  31. data/lib/nesta/config.rb +51 -22
  32. data/lib/nesta/helpers.rb +115 -0
  33. data/lib/nesta/models.rb +111 -70
  34. data/lib/nesta/navigation.rb +36 -12
  35. data/lib/nesta/overrides.rb +10 -5
  36. data/lib/nesta/plugin.rb +10 -8
  37. data/lib/nesta/version.rb +1 -1
  38. data/nesta.gemspec +14 -13
  39. data/templates/Gemfile +6 -3
  40. data/templates/config.ru +3 -0
  41. data/templates/config/config.yml +14 -14
  42. data/templates/config/deploy.rb +2 -2
  43. data/templates/index.haml +2 -0
  44. data/templates/plugins/Gemfile +4 -0
  45. data/templates/plugins/README.md +13 -0
  46. data/templates/plugins/Rakefile +58 -0
  47. data/templates/plugins/gitignore +3 -0
  48. data/templates/plugins/lib/init.rb +13 -0
  49. data/templates/plugins/lib/required.rb +3 -0
  50. data/templates/plugins/lib/version.rb +5 -0
  51. data/templates/plugins/plugin.gemspec +28 -0
  52. data/templates/themes/README.md +1 -1
  53. data/templates/themes/app.rb +1 -1
  54. data/templates/themes/views/layout.haml +7 -0
  55. data/templates/themes/views/master.sass +3 -0
  56. data/templates/themes/views/page.haml +1 -0
  57. data/{spec → test}/fixtures/nesta-plugin-test/Gemfile +0 -0
  58. data/{spec → test}/fixtures/nesta-plugin-test/Rakefile +0 -0
  59. data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test.rb +0 -0
  60. data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/init.rb +1 -3
  61. data/{spec → test}/fixtures/nesta-plugin-test/lib/nesta-plugin-test/version.rb +0 -0
  62. data/{spec → test}/fixtures/nesta-plugin-test/nesta-plugin-test.gemspec +0 -0
  63. data/test/integration/atom_feed_test.rb +178 -0
  64. data/test/integration/commands/demo/content_test.rb +31 -0
  65. data/test/integration/commands/edit_test.rb +21 -0
  66. data/test/integration/commands/new_test.rb +120 -0
  67. data/test/integration/commands/plugin/create_test.rb +128 -0
  68. data/test/integration/commands/theme/create_test.rb +35 -0
  69. data/test/integration/commands/theme/enable_test.rb +22 -0
  70. data/test/integration/commands/theme/install_test.rb +62 -0
  71. data/test/integration/default_theme_test.rb +220 -0
  72. data/test/integration/overrides_test.rb +118 -0
  73. data/test/integration/route_handlers_test.rb +96 -0
  74. data/test/integration/sitemap_test.rb +85 -0
  75. data/test/integration_test_helper.rb +61 -0
  76. data/test/support/model_factory.rb +169 -0
  77. data/test/support/silence_commands_during_tests.rb +5 -0
  78. data/test/support/temporary_files.rb +33 -0
  79. data/test/support/test_configuration.rb +19 -0
  80. data/test/test_helper.rb +26 -0
  81. data/test/unit/commands_test.rb +23 -0
  82. data/test/unit/config_test.rb +138 -0
  83. data/test/unit/file_model_test.rb +71 -0
  84. data/test/unit/menu_test.rb +82 -0
  85. data/test/unit/page_test.rb +571 -0
  86. data/test/unit/path_test.rb +41 -0
  87. data/test/unit/plugin_test.rb +47 -0
  88. data/views/analytics.haml +9 -10
  89. data/views/atom.haml +4 -4
  90. data/views/comments.haml +1 -1
  91. data/views/error.haml +1 -1
  92. data/views/feed.haml +1 -1
  93. data/views/layout.haml +6 -3
  94. data/views/master.sass +144 -134
  95. data/views/mixins.sass +53 -28
  96. data/views/normalize.scss +396 -0
  97. data/views/page_meta.haml +2 -2
  98. data/views/sitemap.haml +2 -2
  99. data/views/summaries.haml +2 -2
  100. metadata +258 -232
  101. data/lib/nesta/cache.rb +0 -139
  102. data/lib/nesta/nesta.rb +0 -7
  103. data/spec/atom_spec.rb +0 -138
  104. data/spec/commands_spec.rb +0 -364
  105. data/spec/config_spec.rb +0 -67
  106. data/spec/model_factory.rb +0 -92
  107. data/spec/models_spec.rb +0 -588
  108. data/spec/overrides_spec.rb +0 -132
  109. data/spec/page_spec.rb +0 -498
  110. data/spec/path_spec.rb +0 -28
  111. data/spec/plugin_spec.rb +0 -51
  112. data/spec/sitemap_spec.rb +0 -100
  113. data/spec/spec_helper.rb +0 -76
@@ -2,10 +2,10 @@ module Nesta
2
2
  module Navigation
3
3
  module Renderers
4
4
  def display_menu(menu, options = {})
5
- defaults = { :class => nil, :levels => 2 }
5
+ defaults = { class: nil, levels: 2 }
6
6
  options = defaults.merge(options)
7
7
  if options[:levels] > 0
8
- haml_tag :ul, :class => options[:class] do
8
+ haml_tag :ul, class: options[:class] do
9
9
  menu.each do |item|
10
10
  display_menu_item(item, options)
11
11
  end
@@ -17,14 +17,14 @@ module Nesta
17
17
  if item.respond_to?(:each)
18
18
  if (options[:levels] - 1) > 0
19
19
  haml_tag :li do
20
- display_menu(item, :levels => (options[:levels] - 1))
20
+ display_menu(item, levels: (options[:levels] - 1))
21
21
  end
22
22
  end
23
23
  else
24
- html_class = (request.path == item.abspath) ? "current" : nil
25
- haml_tag :li, :class => html_class do
26
- haml_tag :a, :<, :href => item.abspath do
27
- haml_concat item.heading
24
+ html_class = current_item?(item) ? current_menu_item_class : nil
25
+ haml_tag :li, class: html_class do
26
+ haml_tag :a, :<, href: path_to(item.abspath) do
27
+ haml_concat link_text(item)
28
28
  end
29
29
  end
30
30
  end
@@ -41,20 +41,44 @@ module Nesta
41
41
  end
42
42
 
43
43
  def display_breadcrumbs(options = {})
44
- haml_tag :ul, :class => options[:class] do
44
+ haml_tag :ul, class: options[:class] do
45
45
  breadcrumb_ancestors[0...-1].each do |page|
46
46
  haml_tag :li do
47
- haml_tag :a, :<, :href => page.abspath do
48
- haml_concat breadcrumb_label(page)
47
+ haml_tag :a, :<, href: path_to(page.abspath), itemprop: 'url' do
48
+ haml_tag :span, :<, itemprop: 'title' do
49
+ haml_concat link_text(page)
50
+ end
49
51
  end
50
52
  end
51
53
  end
52
- haml_tag(:li) { haml_concat breadcrumb_label(@page) }
54
+ haml_tag(:li, class: current_breadcrumb_class) do
55
+ haml_concat link_text(@page)
56
+ end
53
57
  end
54
58
  end
55
59
 
60
+ def link_text(page)
61
+ page.link_text
62
+ rescue LinkTextNotSet
63
+ return 'Home' if page.abspath == '/'
64
+ raise
65
+ end
66
+
56
67
  def breadcrumb_label(page)
57
- (page.abspath == '/') ? 'Home' : page.heading
68
+ Nesta.deprecated('breadcrumb_label', 'use link_text')
69
+ link_text(page)
70
+ end
71
+
72
+ def current_item?(item)
73
+ request.path_info == item.abspath
74
+ end
75
+
76
+ def current_menu_item_class
77
+ 'current'
78
+ end
79
+
80
+ def current_breadcrumb_class
81
+ nil
58
82
  end
59
83
  end
60
84
  end
@@ -6,6 +6,11 @@ module Nesta
6
6
  super(template, defaults.merge(options), locals)
7
7
  end
8
8
 
9
+ def erb(template, options = {}, locals = {})
10
+ defaults, engine = Overrides.render_options(template, :erb)
11
+ super(template, defaults.merge(options), locals)
12
+ end
13
+
9
14
  def scss(template, options = {}, locals = {})
10
15
  defaults, engine = Overrides.render_options(template, :scss)
11
16
  super(template, defaults.merge(options), locals)
@@ -24,15 +29,15 @@ module Nesta
24
29
  end
25
30
 
26
31
  def self.load_local_app
27
- require Nesta::Path.local("app")
28
- rescue LoadError
32
+ app_file = Nesta::Path.local('app.rb')
33
+ require app_file if File.exist?(app_file)
29
34
  end
30
35
 
31
36
  def self.load_theme_app
32
37
  if Nesta::Config.theme
33
- require Nesta::Path.themes(Nesta::Config.theme, "app")
38
+ app_file = Nesta::Path.themes(Nesta::Config.theme, 'app.rb')
39
+ require app_file if File.exist?(app_file)
34
40
  end
35
- rescue LoadError
36
41
  end
37
42
 
38
43
  private
@@ -44,7 +49,7 @@ module Nesta
44
49
  [local_view_path, theme_view_path].each do |path|
45
50
  engines.each do |engine|
46
51
  if template_exists?(engine, path, template)
47
- return { :views => path }, engine
52
+ return { views: path }, engine
48
53
  end
49
54
  end
50
55
  end
@@ -17,17 +17,19 @@ module Nesta
17
17
  end
18
18
 
19
19
  def self.load_local_plugins
20
+ # This approach is deprecated; plugins should now be distributed
21
+ # as gems. See http://nestacms.com/docs/plugins/writing-plugins
20
22
  plugins = Dir.glob(File.expand_path('../plugins/*', File.dirname(__FILE__)))
21
23
  plugins.each { |path| require_local_plugin(path) }
22
24
  end
23
25
 
24
- private
25
- def self.require_local_plugin(path)
26
- Nesta.deprecated(
27
- 'loading plugins from ./plugins', "convert #{path} to a gem")
28
- require File.join(path, 'lib', File.basename(path))
29
- rescue LoadError => e
30
- $stderr.write("Couldn't load plugins/#{File.basename(path)}: #{e}\n")
31
- end
26
+ def self.require_local_plugin(path)
27
+ Nesta.deprecated(
28
+ 'loading plugins from ./plugins', "convert #{path} to a gem")
29
+ require File.join(path, 'lib', File.basename(path))
30
+ rescue LoadError => e
31
+ $stderr.write("Couldn't load plugins/#{File.basename(path)}: #{e}\n")
32
+ end
33
+ private_class_method :require_local_plugin
32
34
  end
33
35
  end
@@ -1,3 +1,3 @@
1
1
  module Nesta
2
- VERSION = '0.9.11'
2
+ VERSION = '0.12.0'
3
3
  end
@@ -24,26 +24,27 @@ Implementing your site's design is easy, but Nesta also has a small
24
24
  selection of themes to choose from.
25
25
  EOF
26
26
 
27
- s.rubyforge_project = "nesta"
28
-
29
27
  s.files = `git ls-files`.split("\n")
30
28
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
29
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
32
30
  s.require_paths = ["lib"]
33
31
 
34
- s.add_dependency('haml', '~> 3.1')
35
- s.add_dependency('sass', '~> 3.1')
36
- s.add_dependency('rdiscount', '~> 1.6')
32
+ s.add_dependency('haml', '>= 3.1')
33
+ s.add_dependency('haml-contrib', '>= 1.0')
34
+ s.add_dependency('rack', '~> 2.0')
35
+ s.add_dependency('rdiscount', '~> 2.1')
37
36
  s.add_dependency('RedCloth', '~> 4.2')
38
- s.add_dependency('sinatra', '1.2.6')
39
-
37
+ s.add_dependency('sassc', '>= 2.2')
38
+ s.add_dependency('sinatra', '~> 2.0')
39
+ s.add_dependency('tilt', '~> 2.0')
40
+
40
41
  # Useful in development
41
- s.add_dependency('shotgun', '>= 0.8')
42
+ s.add_development_dependency('mr-sparkle')
42
43
 
43
44
  # Test libraries
44
- s.add_development_dependency('hpricot', '0.8.4')
45
- s.add_development_dependency('rack-test', '0.6.1')
46
- s.add_development_dependency('rspec', '1.3.0')
47
- s.add_development_dependency('rspec_hpricot_matchers', '1.0')
48
- s.add_development_dependency('test-unit', '1.2.3')
45
+ s.add_development_dependency('byebug')
46
+ s.add_development_dependency('capybara', '~> 2.0')
47
+ s.add_development_dependency('minitest', '~> 5.0')
48
+ s.add_development_dependency('minitest-reporters')
49
+ s.add_development_dependency('rake')
49
50
  end
@@ -1,8 +1,11 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'nesta', '<%= Nesta::VERSION %>'
4
- <% if @options['heroku'] %>gem 'heroku'<% end %>
3
+ gem 'nesta'
5
4
  <% if @options['vlad'] %>gem 'vlad', '2.1.0'
6
5
  gem 'vlad-git', '2.2.0'<% end %>
7
6
 
8
- # gem (RUBY_VERSION =~ /^1.9/) ? 'ruby-debug19': 'ruby-debug'
7
+ group :development do
8
+ gem 'mr-sparkle'
9
+ end
10
+
11
+ # gem 'debugger'
@@ -3,6 +3,9 @@ require 'bundler/setup'
3
3
 
4
4
  Bundler.require(:default)
5
5
 
6
+ use Rack::ConditionalGet
7
+ use Rack::ETag
8
+
6
9
  require 'nesta/env'
7
10
  Nesta::Env.root = ::File.expand_path('.', ::File.dirname(__FILE__))
8
11
 
@@ -8,7 +8,7 @@ subtitle: "(change this text in config/config.yml)"
8
8
  # Atom feed. Specify at least one of name, uri or email, and Nesta will
9
9
  # include it in your feed. See the Atom spec for more info:
10
10
  #
11
- # http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.feed
11
+ # https://tools.ietf.org/html/rfc4287#section-4.1.1
12
12
  #
13
13
  # author:
14
14
  # name: Your Name
@@ -28,14 +28,6 @@ subtitle: "(change this text in config/config.yml)"
28
28
  #
29
29
  # disqus_short_name: mysite
30
30
 
31
- # cache
32
- # Set it to true if you'd like Nesta to cache your pages in ./public.
33
- # Useful if you're deploying Nesta with a proxy server such as Nginx,
34
- # but not in the least bit helpful if your pages are dynamic, or you're
35
- # deploying Nesta to Heroku.
36
- #
37
- cache: false
38
-
39
31
  # content
40
32
  # The root directory where nesta will look for your article files.
41
33
  # Should contain "pages" and "attachments" subdirectories that contain
@@ -54,14 +46,22 @@ content: content
54
46
  #
55
47
  # google_analytics_code: "UA-???????-?"
56
48
 
57
- # Overriding "cache" and "content" in production is recommended if you're
58
- # deploying Nesta to your own server (but see the deployment documentation
59
- # on the Nesta site). Setting google_analytics_code in production is
60
- # recommended regardless of how you're deploying (if you have a GA account!).
49
+ # read_more
50
+ # When the summary of an article is displayed on the home page, or
51
+ # on a category page, there is a link underneath the summary that
52
+ # points to the rest of the post. Use this value to customize the
53
+ # default link text. You can still override this value on a per-page
54
+ # basis with the 'Read more' metadata key.
55
+ #
56
+ # read_more: "Continue reading"
57
+
58
+ # Overriding "content" in production is recommended if you're deploying
59
+ # Nesta to your own server (but see the deployment documentation on the
60
+ # Nesta site). Setting google_analytics_code in production is recommended
61
+ # regardless of how you're deploying (if you have a GA # account!).
61
62
  #
62
63
  # Don't forget to uncomment the "production:" line too...
63
64
 
64
65
  # production:
65
- # cache: true
66
66
  # content: /var/apps/nesta/shared/content
67
67
  # google_analytics_code: "UA-???????-?"
@@ -38,10 +38,10 @@ namespace :vlad do
38
38
  # using a different app server in the call to Vlad.load in Rakefile.
39
39
  #
40
40
  desc "Deploy the code and restart the server"
41
- task :deploy => [:update, :start_app]
41
+ task deploy: [:update, :start_app]
42
42
 
43
43
  # If you use bundler to manage the installation of gems on your server
44
44
  # you can use this definition of the deploy task instead:
45
45
  #
46
- # task :deploy => [:update, :bundle, :start_app]
46
+ # task deploy: [:update, :bundle, :start_app]
47
47
  end
@@ -1 +1,3 @@
1
+ Link text: Home
2
+
1
3
  %section.articles= article_summaries(latest_articles)
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in <%= @gem_name %>.gemspec
4
+ gemspec
@@ -0,0 +1,13 @@
1
+ README
2
+ ======
3
+
4
+ TODO: Explain what your plugin is for
5
+
6
+ Installation
7
+ ------------
8
+
9
+ To use this plugin just add it to your Nesta project's `Gemfile` and
10
+ then install it with Bundler:
11
+
12
+ $ echo 'gem "<%= @gem_name %>"' >> Gemfile
13
+ $ bundle
@@ -0,0 +1,58 @@
1
+ def version
2
+ version_file = File.join(File.dirname(__FILE__), "lib", name, "version.rb")
3
+ contents = File.read(version_file)
4
+ contents.match(/VERSION = ['"]([0-9a-z.-]+)['"].*$/)
5
+ $1
6
+ end
7
+
8
+ def name
9
+ "<%= @gem_name %>"
10
+ end
11
+
12
+ def built_gem_path
13
+ gem_packages = File.join(File.dirname(__FILE__), "pkg", "#{name}-*.gem")
14
+ Dir[gem_packages].sort_by { |file| File.mtime(file) }.last
15
+ end
16
+
17
+ def already_tagged?
18
+ `git tag`.split(/\n/).include?("v#{version}")
19
+ end
20
+
21
+ desc "Build #{name}-#{version}.gem into the pkg directory."
22
+ task 'build' do
23
+ `gem build -V #{File.join(File.dirname(__FILE__), "#{name}.gemspec")}`
24
+ FileUtils.mkdir_p(File.join(File.dirname(__FILE__), "pkg"))
25
+ gem = Dir[File.join(File.dirname(__FILE__), "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last
26
+ FileUtils.mv(gem, 'pkg')
27
+ puts "#{name} #{version} built to #{built_gem_path}."
28
+ end
29
+
30
+ desc "Build and install #{name}-#{version}.gem into system gems."
31
+ task 'install' => 'build' do
32
+ `gem install '#{built_gem_path}' --local`
33
+ end
34
+
35
+ desc "Create tag v#{version} and build and push #{name}-#{version}.gem to Rubygems\n" \
36
+ "To prevent publishing in Rubygems use `gem_push=no rake release`"
37
+ task 'release' => ['build', 'release:guard_clean',
38
+ 'release:source_control_push', 'release:rubygem_push'] do
39
+ end
40
+
41
+ task 'release:guard_clean' do
42
+ if !system("git diff --exit-code") || !system("git diff-index --quiet --cached HEAD")
43
+ puts "There are files that need to be committed first."
44
+ exit(1)
45
+ end
46
+ end
47
+
48
+ task 'release:source_control_push' do
49
+ unless already_tagged?
50
+ system "git tag -a -m 'Version #{version}' v#{version}"
51
+ system 'git push'
52
+ system 'git push --tags'
53
+ end
54
+ end
55
+
56
+ task 'release:rubygem_push' do
57
+ system "gem push #{built_gem_path}"
58
+ end
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ pkg/*
@@ -0,0 +1,13 @@
1
+ module Nesta
2
+ module Plugin
3
+ module <%= module_name %>
4
+ module Helpers
5
+ # If your plugin needs any helper methods, add them here...
6
+ end
7
+ end
8
+ end
9
+
10
+ class App
11
+ helpers Nesta::Plugin::<%= module_name %>::Helpers
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ require "<%= @gem_name %>/version"
2
+
3
+ Nesta::Plugin.register(__FILE__)
@@ -0,0 +1,5 @@
1
+ module Nesta
2
+ module Plugin
3
+ <%= nested_module_definition_with_version -%>
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "<%= @gem_name %>/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "<%= @gem_name %>"
8
+ spec.version = Nesta::Plugin::<%= module_name %>::VERSION
9
+ spec.authors = ["TODO: Your name"]
10
+ spec.email = ["TODO: Your email address"]
11
+ spec.homepage = ""
12
+ spec.summary = %q{TODO: Write a gem summary}
13
+ spec.description = %q{TODO: Write a gem description}
14
+ spec.license = "MIT"
15
+
16
+ spec.rubyforge_project = "<%= @gem_name %>"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ # specify any dependencies here; for example:
24
+ # spec.add_development_dependency "rspec"
25
+ # spec.add_runtime_dependency "rest-client"
26
+ spec.add_dependency("nesta", ">= 0.9.11")
27
+ spec.add_development_dependency("rake")
28
+ end
@@ -4,4 +4,4 @@
4
4
  <%= @name %> is a theme for Nesta, a [Ruby CMS](nesta), designed by
5
5
  <insert your name here>.
6
6
 
7
- [nesta]: http://effectif.com/nesta
7
+ [nesta]: http://nestacms.com
@@ -8,7 +8,7 @@ module Nesta
8
8
  #
9
9
  # Put your assets in themes/<%= @name %>/public/<%= @name %>.
10
10
  #
11
- # use Rack::Static, :urls => ["/<%= @name %>"], :root => "themes/<%= @name %>/public"
11
+ # use Rack::Static, urls: ["/<%= @name %>"], root: "themes/<%= @name %>/public"
12
12
 
13
13
  helpers do
14
14
  # Add new helpers here.