mars-nesta 0.9.4

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.
Files changed (61) hide show
  1. data/.gitignore +13 -0
  2. data/CHANGES +97 -0
  3. data/Gemfile +6 -0
  4. data/Gemfile.lock +44 -0
  5. data/LICENSE +19 -0
  6. data/README.md +42 -0
  7. data/Rakefile +12 -0
  8. data/bin/nesta +79 -0
  9. data/config.ru +9 -0
  10. data/config/deploy.rb.sample +62 -0
  11. data/lib/nesta/app.rb +167 -0
  12. data/lib/nesta/cache.rb +139 -0
  13. data/lib/nesta/commands.rb +188 -0
  14. data/lib/nesta/config.rb +86 -0
  15. data/lib/nesta/models.rb +364 -0
  16. data/lib/nesta/navigation.rb +60 -0
  17. data/lib/nesta/nesta.rb +7 -0
  18. data/lib/nesta/overrides.rb +59 -0
  19. data/lib/nesta/path.rb +11 -0
  20. data/lib/nesta/plugins.rb +15 -0
  21. data/lib/nesta/version.rb +3 -0
  22. data/nesta.gemspec +48 -0
  23. data/scripts/import-from-mephisto +207 -0
  24. data/spec/atom_spec.rb +138 -0
  25. data/spec/commands_spec.rb +292 -0
  26. data/spec/config_spec.rb +69 -0
  27. data/spec/model_factory.rb +94 -0
  28. data/spec/models_spec.rb +554 -0
  29. data/spec/overrides_spec.rb +114 -0
  30. data/spec/page_spec.rb +458 -0
  31. data/spec/path_spec.rb +28 -0
  32. data/spec/sitemap_spec.rb +102 -0
  33. data/spec/spec.opts +1 -0
  34. data/spec/spec_helper.rb +70 -0
  35. data/templates/Gemfile +8 -0
  36. data/templates/Rakefile +11 -0
  37. data/templates/config.ru +9 -0
  38. data/templates/config/config.yml +67 -0
  39. data/templates/config/deploy.rb +47 -0
  40. data/templates/index.haml +1 -0
  41. data/templates/themes/README.md +7 -0
  42. data/templates/themes/app.rb +19 -0
  43. data/views/analytics.haml +12 -0
  44. data/views/atom.haml +28 -0
  45. data/views/categories.haml +4 -0
  46. data/views/colors.sass +10 -0
  47. data/views/comments.haml +8 -0
  48. data/views/error.haml +12 -0
  49. data/views/feed.haml +3 -0
  50. data/views/footer.haml +5 -0
  51. data/views/header.haml +4 -0
  52. data/views/layout.haml +24 -0
  53. data/views/master.sass +246 -0
  54. data/views/mixins.sass +39 -0
  55. data/views/not_found.haml +12 -0
  56. data/views/page.haml +21 -0
  57. data/views/page_meta.haml +16 -0
  58. data/views/sidebar.haml +3 -0
  59. data/views/sitemap.haml +11 -0
  60. data/views/summaries.haml +15 -0
  61. metadata +235 -0
data/spec/path_spec.rb ADDED
@@ -0,0 +1,28 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+
3
+ describe 'Nesta::Path' do
4
+ before(:each) do
5
+ @root = File.expand_path('..', File.dirname(__FILE__))
6
+ @local_foo_bar = File.join(@root, 'foo/bar')
7
+ end
8
+
9
+ it 'should return local path' do
10
+ Nesta::Path.local.should == @root
11
+ end
12
+
13
+ it 'should return path for file within local directory' do
14
+ Nesta::Path.local('foo/bar').should == @local_foo_bar
15
+ end
16
+
17
+ it 'should combine path components' do
18
+ Nesta::Path.local('foo', 'bar').should == @local_foo_bar
19
+ end
20
+
21
+ it 'should return themes path' do
22
+ Nesta::Path.themes.should == File.expand_path('themes', @root)
23
+ end
24
+
25
+ it 'should return path for file within themes directory' do
26
+ Nesta::Path.themes('foo/bar').should == File.join(@root, 'themes/foo/bar')
27
+ end
28
+ end
@@ -0,0 +1,102 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+ require File.expand_path('model_factory', File.dirname(__FILE__))
3
+
4
+ describe "sitemap XML" do
5
+ include ConfigSpecHelper
6
+ include RequestSpecHelper
7
+ include ModelFactory
8
+
9
+ before(:each) do
10
+ stub_configuration
11
+ @category = create_category do |path|
12
+ mock_file_stat(:stub!, path, "3 Jan 2009, 15:07")
13
+ end
14
+ @article = create_article do |path|
15
+ mock_file_stat(:stub!, path, "3 Jan 2009, 15:10")
16
+ end
17
+ get "/sitemap.xml"
18
+ end
19
+
20
+ after(:each) do
21
+ Nesta::FileModel.purge_cache
22
+ remove_fixtures
23
+ end
24
+
25
+ it "should render successfully" do
26
+ last_response.should be_ok
27
+ end
28
+
29
+ it "should have a urlset tag" do
30
+ namespace = "http://www.sitemaps.org/schemas/sitemap/0.9"
31
+ body.should have_tag("/urlset[@xmlns=#{namespace}]")
32
+ end
33
+
34
+ it "should reference the home page" do
35
+ body.should have_tag("/urlset/url/loc", "http://example.org")
36
+ end
37
+
38
+ it "should configure home page to be checked frequently" do
39
+ body.should have_tag("/urlset/url") do |url|
40
+ url.should have_tag("loc", "http://example.org")
41
+ url.should have_tag("changefreq", "daily")
42
+ url.should have_tag("priority", "1.0")
43
+ end
44
+ end
45
+
46
+ it "should set the homepage lastmod from latest article" do
47
+ body.should have_tag("/urlset/url") do |url|
48
+ url.should have_tag("loc", "http://example.org")
49
+ url.should have_tag("lastmod", /^2009-01-03T15:10:00/)
50
+ end
51
+ end
52
+
53
+ it "should reference category pages" do
54
+ body.should have_tag(
55
+ "/urlset/url/loc", "http://example.org/#{@category.path}")
56
+ end
57
+
58
+ it "should reference article pages" do
59
+ body.should have_tag(
60
+ "/urlset/url/loc", "http://example.org/#{@article.path}")
61
+ end
62
+ end
63
+
64
+ describe "sitemap XML lastmod" do
65
+ include ConfigSpecHelper
66
+ include ModelFactory
67
+ include RequestSpecHelper
68
+
69
+ before(:each) do
70
+ stub_configuration
71
+ end
72
+
73
+ after(:each) do
74
+ remove_fixtures
75
+ Nesta::FileModel.purge_cache
76
+ end
77
+
78
+ it "should be set for file based page" do
79
+ create_article do |path|
80
+ mock_file_stat(:stub!, path, "3 January 2009, 15:37:01")
81
+ end
82
+ get "/sitemap.xml"
83
+ body.should have_tag("url") do |url|
84
+ url.should have_tag("loc", /my-article$/)
85
+ url.should have_tag("lastmod", /^2009-01-03T15:37:01/)
86
+ end
87
+ end
88
+
89
+ it "should be set to latest page for home page" do
90
+ create_article(:path => "article-1") do |path|
91
+ mock_file_stat(:stub!, path, "4 January 2009")
92
+ end
93
+ create_article(:path => "article-2") do |path|
94
+ mock_file_stat(:stub!, path, "3 January 2009")
95
+ end
96
+ get "/sitemap.xml"
97
+ body.should have_tag("url") do |url|
98
+ url.should have_tag("loc", "http://example.org")
99
+ url.should have_tag("lastmod", /^2009-01-04/)
100
+ end
101
+ end
102
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,70 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require 'spec/interop/test'
4
+ require 'rack/test'
5
+ require 'rspec_hpricot_matchers'
6
+ require 'sinatra'
7
+
8
+ Test::Unit::TestCase.send :include, Rack::Test::Methods
9
+
10
+ Spec::Runner.configure do |config|
11
+ config.include(RspecHpricotMatchers)
12
+ end
13
+
14
+ module Nesta
15
+ class App < Sinatra::Base
16
+ set :environment, :test
17
+ set :reload_templates, true
18
+ end
19
+ end
20
+
21
+ require File.expand_path('../lib/nesta/app', File.dirname(__FILE__))
22
+
23
+ module FixtureHelper
24
+ FIXTURE_DIR = File.expand_path('fixtures', File.dirname(__FILE__))
25
+
26
+ def create_fixtures_directory
27
+ FileUtils.mkdir_p(FixtureHelper::FIXTURE_DIR)
28
+ end
29
+
30
+ def remove_fixtures
31
+ FileUtils.rm_r(FixtureHelper::FIXTURE_DIR, :force => true)
32
+ end
33
+ end
34
+
35
+ module RequestSpecHelper
36
+ def app
37
+ Nesta::App
38
+ end
39
+
40
+ def body
41
+ last_response.body
42
+ end
43
+ end
44
+
45
+ module ConfigSpecHelper
46
+ include FixtureHelper
47
+
48
+ def stub_yaml_config
49
+ @config = {}
50
+ Nesta::Config.stub!(:yaml_exists?).and_return(true)
51
+ Nesta::Config.stub!(:yaml_conf).and_return(@config)
52
+ end
53
+
54
+ def stub_config_key(key, value, options = {})
55
+ stub_yaml_config unless @config
56
+ if options[:rack_env]
57
+ @config['test'] ||= {}
58
+ @config['test'][key] = value
59
+ else
60
+ @config[key] = value
61
+ end
62
+ end
63
+
64
+ def stub_configuration(options = {})
65
+ stub_config_key('title', 'My blog', options)
66
+ stub_config_key('subtitle', 'about stuff', options)
67
+ content_path = File.join(FixtureHelper::FIXTURE_DIR, 'content')
68
+ stub_config_key('content', content_path, options.merge(:rack_env => true))
69
+ end
70
+ end
data/templates/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'mars-nesta', '<%= Nesta::VERSION %>'
4
+ <% if @options['heroku'] %>gem 'heroku'<% end %>
5
+ <% if @options['vlad'] %>gem 'vlad', '2.1.0'
6
+ gem 'vlad-git', '2.2.0'<% end %>
7
+
8
+ # gem (RUBY_VERSION =~ /^1.9/) ? 'ruby-debug19': 'ruby-debug'
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ Bundler.require(:default, :test)
5
+ <% if @options['vlad'] %>
6
+ begin
7
+ require 'vlad'
8
+ # Set :app to :passenger if you're using Phusion Passenger.
9
+ Vlad.load(:scm => :git, :app => nil, :web => nil)
10
+ rescue LoadError
11
+ end<% end %>
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ Bundler.require(:default)
5
+
6
+ require 'nesta/app'
7
+
8
+ Nesta::App.root = ::File.expand_path('.', ::File.dirname(__FILE__))
9
+ run Nesta::App
@@ -0,0 +1,67 @@
1
+ # Title and subheading for your site. Used on the home page and in page
2
+ # titles.
3
+ #
4
+ title: "My Site"
5
+ subtitle: "(change this text in config/config.yml)"
6
+
7
+ # You should really specify your content's author when generating an
8
+ # Atom feed. Specify at least one of name, uri or email, and Nesta will
9
+ # include it in your feed. See the Atom spec for more info:
10
+ #
11
+ # http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.feed
12
+ #
13
+ # author:
14
+ # name: Your Name
15
+ # uri: http://yourhomepage.com
16
+ # email: you@yourdomain.com
17
+
18
+ # You can stick with the default look and feel, or use a theme. Themes are
19
+ # easy to create or install, and live inside the themes directory. You
20
+ # can also use scripts/theme to install them.
21
+ #
22
+ # theme: name-of-theme
23
+
24
+ # If you want to use the Disqus service (http://disqus.com) to display
25
+ # comments on your site, register a Disqus account and then specify your
26
+ # site's short name here. A comment form will automatically be added to
27
+ # the bottom of your pages.
28
+ #
29
+ # disqus_short_name: mysite
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
+ # content
40
+ # The root directory where nesta will look for your article files.
41
+ # Should contain "pages" and "attachments" subdirectories that contain
42
+ # your actual content and the (optional) menu.txt file that links to your
43
+ # main category pages.
44
+ #
45
+ content: content
46
+
47
+ # google_analytics_code
48
+ # Set this if you want Google Analytics to track traffic on your site.
49
+ # Probably best not to set a default value, but to set it in production.
50
+ #
51
+ # The production settings are used if you're deploying to Heroku, so
52
+ # scroll down a bit to set it in production even if you're not deploying
53
+ # to your own server.
54
+ #
55
+ # google_analytics_code: "UA-???????-?"
56
+
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!).
61
+ #
62
+ # Don't forget to uncomment the "production:" line too...
63
+
64
+ # production:
65
+ # cache: true
66
+ # content: /var/apps/nesta/shared/content
67
+ # google_analytics_code: "UA-???????-?"
@@ -0,0 +1,47 @@
1
+ set :application, '<%= File.basename(@path) %>'
2
+ set :repository, "set this to URL of your site's repo"
3
+
4
+ # Set :user if you want to connect (via ssh) to your server using a
5
+ # different username. You will also need to include the user in :domain
6
+ # (see below).
7
+ #
8
+ #set :user, "deploy"
9
+ #set :domain, "#{user}@example.com"
10
+ set :domain, "example.com"
11
+
12
+ set :deploy_to, "/var/apps/#{application}"
13
+
14
+ # ============================================================================
15
+ # You probably don't need to worry about anything beneath this point...
16
+ # ============================================================================
17
+
18
+ require "tempfile"
19
+ require "vlad"
20
+
21
+ namespace :vlad do
22
+ remote_task :symlink_attachments do
23
+ run "ln -s #{shared_path}/content/attachments #{current_path}/public/attachments"
24
+ end
25
+
26
+ task :update do
27
+ Rake::Task["vlad:symlink_attachments"].invoke
28
+ end
29
+
30
+ remote_task :bundle do
31
+ run "cd #{current_path} && sudo bundle install --without development test"
32
+ end
33
+
34
+ # Depending on how you host Nesta, you might want to swap :start_app
35
+ # with :start below. The :start_app task will tell your application
36
+ # server (e.g. Passenger) to restart once your new code is deployed by
37
+ # :update. Passenger is the default app server; tell Vlad that you're
38
+ # using a different app server in the call to Vlad.load in Rakefile.
39
+ #
40
+ desc "Deploy the code and restart the server"
41
+ task :deploy => [:update, :start_app]
42
+
43
+ # If you use bundler to manage the installation of gems on your server
44
+ # you can use this definition of the deploy task instead:
45
+ #
46
+ # task :deploy => [:update, :bundle, :start_app]
47
+ end
@@ -0,0 +1 @@
1
+ %section.articles= article_summaries(latest_articles)
@@ -0,0 +1,7 @@
1
+ <%= @name.capitalize.gsub(/[_-]/, ' ') %> Nesta theme
2
+ <%= '=' * @name.length %>============
3
+
4
+ <%= @name %> is a theme for Nesta, a [Ruby CMS](nesta), designed by
5
+ <insert your name here>.
6
+
7
+ [nesta]: http://effectif.com/nesta
@@ -0,0 +1,19 @@
1
+ # Use the app.rb file to load Ruby code, modify or extend the models, or
2
+ # do whatever else you fancy when the theme is loaded.
3
+
4
+ module Nesta
5
+ class App
6
+ # Uncomment the Rack::Static line below if your theme has assets
7
+ # (i.e images or JavaScript).
8
+ #
9
+ # Put your assets in themes/<%= @name %>/public/<%= @name %>.
10
+ #
11
+ # use Rack::Static, :urls => ["/<%= @name %>"], :root => "themes/<%= @name %>/public"
12
+
13
+ helpers do
14
+ # Add new helpers here.
15
+ end
16
+
17
+ # Add new routes here.
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ - if @google_analytics_code
2
+ :plain
3
+ <script type="text/javascript">
4
+ var _gaq = _gaq || [];
5
+ _gaq.push(['_setAccount', '#{@google_analytics_code}']);
6
+ _gaq.push(['_trackPageview']);
7
+ (function() {
8
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
9
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
10
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
11
+ })();
12
+ </script>
data/views/atom.haml ADDED
@@ -0,0 +1,28 @@
1
+ !!! XML
2
+ %feed(xmlns='http://www.w3.org/2005/Atom')
3
+ %title(type='text')= @title
4
+ %generator(uri='http://effectif.com/nesta') Nesta
5
+ %id= atom_id
6
+ %link(href="#{base_url}/articles.xml" rel='self')
7
+ %link(href=base_url rel='alternate')
8
+ %subtitle(type='text')= @subtitle
9
+ - if @articles[0]
10
+ %updated= @articles[0].date(:xmlschema)
11
+ - if @author
12
+ %author
13
+ - if @author['name']
14
+ %name= @author['name']
15
+ - if @author['uri']
16
+ %uri= @author['uri']
17
+ - if @author['email']
18
+ %email= @author['email']
19
+ - @articles.each do |article|
20
+ %entry
21
+ %title= article.heading
22
+ %link{ :href => url_for(article), :type => 'text/html', :rel => 'alternate' }
23
+ %id= atom_id(article)
24
+ %content(type='html')&= find_and_preserve(absolute_urls(article.body))
25
+ %published= article.date(:xmlschema)
26
+ %updated= article.date(:xmlschema)
27
+ - article.categories.each do |category|
28
+ %category{ :term => category.permalink }
@@ -0,0 +1,4 @@
1
+ - if ! @menu_items.empty?
2
+ %nav.categories
3
+ %h1 Articles by category
4
+ - display_menu(@menu_items, :class => "menu")
data/views/colors.sass ADDED
@@ -0,0 +1,10 @@
1
+ $base-color: #262631
2
+ $background-color: #fff
3
+ $tint: #EAF4F7
4
+ $border-color: #71ADCE
5
+ $link-color: #006DD1
6
+ $visited-link-color: darken($link-color, 5%)
7
+ $hover-link-color: lighten($link-color, 15%)
8
+ $active-link-color: darken($link-color, 20%)
9
+ $nav-link-color: desaturate(lighten($link-color, 25%), 35%)
10
+ $meta-color: #87877D