nesta 0.9.11 → 0.9.13

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.
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
data/CHANGES CHANGED
@@ -1,3 +1,58 @@
1
+ = 0.9.12 / (3 March 2012)
2
+
3
+ * The nesta script has a new command; edit. You can pass it the path
4
+ to a file within your content/pages folder and it will open the file
5
+ in your default editor (as set by the EDITOR environment variable).
6
+
7
+ * The nesta script has a new option; --bash-completion. Run nesta with
8
+ this option and it will print some Bash that will configure command
9
+ line completion for the nesta command.
10
+
11
+ You can type `nesta edit <TAB>` and Bash will complete the names of
12
+ the files in your content/pages directory. :-)
13
+
14
+ Installation instructions at the top of the Bash script.
15
+
16
+ * Nesta can now be mounted cleanly at a path, rather than at a site's
17
+ root, and assets and links will be served correctly.
18
+ (Max Sadrieh, Graham Ashton)
19
+
20
+ * The default config.ru file that is generated when you create a new
21
+ project now enables Etag HTTP headers. (Max Sadrieh)
22
+
23
+ * Two helper methods have been removed; url_for and base_url. Use
24
+ Sinatra's url helper instead. They would have been deprecated rather
25
+ than removed, but if you try and load Nesta's helpers in a Rails app
26
+ url_for breaks Rails's rendering. (Max Sadrieh, Graham Ashton)
27
+
28
+ * The Page class has a new method; body_markup. It can be overridden by
29
+ a plugin, and is used by the foldable plugin. (Micah Chalmer)
30
+
31
+ * The FileModel class has a new method; parse_metadata. It can be
32
+ overriden by plugins that implement an alternate metadata syntax.
33
+ Used by the yaml-metadata plugin.
34
+
35
+ * Erb templates in your ./views folder, or in a theme's folder, will
36
+ now be found when you call Sinatra's erb helper method.
37
+
38
+ * config.yml can now contain Erb (and therefore inline Ruby), which
39
+ will be interpreted when loaded. (Glenn Gillen)
40
+
41
+ * Extended the `nesta` command to support new commands that could (for
42
+ example) be added by a plugin. The class to be instantiated within
43
+ the Nesta::Commands module is determined from the command line
44
+ argument (e.g. `nesta plugin:create` will instantiate the class
45
+ called Nesta::Commands::Plugin::Create).
46
+
47
+ * Bug fix: Don't crash if a page's metadata only contains the key, with
48
+ no corresponding value. You could argue this wasn't a bug, but the
49
+ error message was difficult to trace. See #77.
50
+
51
+ * Bug fix: Summaries on Haml pages were not marked up as paragraphs.
52
+ See #75.
53
+
54
+ = 0.9.12 / (Released then pulled, due to rubygems [still] being a total mess)
55
+
1
56
  = 0.9.11 / (22 September 2011)
2
57
 
3
58
  * Use Tilt to render the Markdown, Textile and Haml in content/pages.
data/Gemfile CHANGED
@@ -3,4 +3,11 @@ source 'http://rubygems.org'
3
3
  # Specify your gem's dependencies in nesta.gemspec
4
4
  gemspec
5
5
 
6
+ group :development do
7
+ gem 'guard-ctags-bundler'
8
+ gem 'guard-livereload'
9
+ gem 'rb-readline'
10
+ gem 'ZenTest'
11
+ end
12
+
6
13
  # gem (RUBY_VERSION =~ /^1.9/) ? 'ruby-debug19': 'ruby-debug'
@@ -1,46 +1,73 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nesta (0.9.11)
4
+ nesta (0.9.13)
5
5
  RedCloth (~> 4.2)
6
6
  haml (~> 3.1)
7
+ rack (~> 1.1)
7
8
  rdiscount (~> 1.6)
8
9
  sass (~> 3.1)
9
10
  shotgun (>= 0.8)
10
- sinatra (= 1.2.6)
11
+ sinatra (~> 1.3)
11
12
 
12
13
  GEM
13
14
  remote: http://rubygems.org/
14
15
  specs:
15
- RedCloth (4.2.8)
16
- haml (3.1.3)
17
- hoe (2.12.2)
16
+ RedCloth (4.2.9)
17
+ ZenTest (4.6.2)
18
+ addressable (2.2.7)
19
+ em-websocket (0.3.6)
20
+ addressable (>= 2.1.1)
21
+ eventmachine (>= 0.12.9)
22
+ eventmachine (0.12.10)
23
+ ffi (1.0.11)
24
+ guard (1.0.0)
25
+ ffi (>= 0.5.0)
26
+ thor (~> 0.14.6)
27
+ guard-ctags-bundler (0.0.5)
28
+ guard (>= 0.4.0)
29
+ guard-livereload (0.4.2)
30
+ em-websocket (>= 0.2.0)
31
+ guard (>= 0.10.0)
32
+ multi_json (~> 1.0)
33
+ haml (3.1.4)
34
+ hoe (2.15.0)
18
35
  rake (~> 0.8)
19
36
  hpricot (0.8.4)
20
- rack (1.3.2)
37
+ multi_json (1.1.0)
38
+ rack (1.4.1)
39
+ rack-protection (1.2.0)
40
+ rack
21
41
  rack-test (0.6.1)
22
42
  rack (>= 1.0)
23
- rake (0.9.2)
43
+ rake (0.9.2.2)
44
+ rb-readline (0.4.2)
24
45
  rdiscount (1.6.8)
25
46
  rspec (1.3.0)
26
47
  rspec_hpricot_matchers (1.0)
27
- sass (3.1.7)
48
+ sass (3.1.15)
28
49
  shotgun (0.9)
29
50
  rack (>= 1.0)
30
- sinatra (1.2.6)
31
- rack (~> 1.1)
32
- tilt (< 2.0, >= 1.2.2)
51
+ sinatra (1.3.2)
52
+ rack (~> 1.3, >= 1.3.6)
53
+ rack-protection (~> 1.2)
54
+ tilt (~> 1.3, >= 1.3.3)
33
55
  test-unit (1.2.3)
34
56
  hoe (>= 1.5.1)
57
+ thor (0.14.6)
35
58
  tilt (1.3.3)
36
59
 
37
60
  PLATFORMS
38
61
  ruby
39
62
 
40
63
  DEPENDENCIES
64
+ ZenTest
65
+ guard-ctags-bundler
66
+ guard-livereload
41
67
  hpricot (= 0.8.4)
42
68
  nesta!
43
69
  rack-test (= 0.6.1)
70
+ rb-readline
44
71
  rspec (= 1.3.0)
45
72
  rspec_hpricot_matchers (= 1.0)
46
73
  test-unit (= 1.2.3)
@@ -0,0 +1,7 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'ctags-bundler' do
5
+ watch(%r{^(lib)/.*\.rb$}) { 'lib' }
6
+ watch('Gemfile.lock')
7
+ end
data/Rakefile CHANGED
@@ -10,3 +10,5 @@ desc "Run all specs in spec directory"
10
10
  Spec::Rake::SpecTask.new(:spec) do |t|
11
11
  t.spec_files = FileList["spec/*_spec.rb"]
12
12
  end
13
+
14
+ task :default => :spec
data/bin/nesta CHANGED
@@ -13,9 +13,11 @@ USAGE: #{File.basename($0)} [GLOBAL OPTIONS] <command> [COMMAND OPTIONS]
13
13
  GLOBAL OPTIONS
14
14
  --help, -h Display this message.
15
15
  --version, -v Display version number.
16
+ --bash-completion Output command completion setup for Bash.
16
17
 
17
18
  COMMANDS
18
19
  new <path> Create a new Nesta project.
20
+ edit <path> Edit a document (path relative to content/pages).
19
21
  demo:content Install example pages in ./content-demo.
20
22
  plugin:create <name> Create a gem called nesta-plugin-name.
21
23
  theme:install <url> Install a theme from a git repository.
@@ -37,6 +39,7 @@ EOF
37
39
 
38
40
  def self.parse_command_line
39
41
  opts = GetoptLong.new(
42
+ ['--bash-completion', GetoptLong::NO_ARGUMENT],
40
43
  ['--git', GetoptLong::NO_ARGUMENT],
41
44
  ['--help', '-h', GetoptLong::NO_ARGUMENT],
42
45
  ['--version', '-v', GetoptLong::NO_ARGUMENT],
@@ -45,6 +48,8 @@ EOF
45
48
  options = {}
46
49
  opts.each do |opt, arg|
47
50
  case opt
51
+ when '--bash-completion'
52
+ bash_completion
48
53
  when '--help'
49
54
  usage(exitcode=0)
50
55
  when '--version'
@@ -59,21 +64,30 @@ EOF
59
64
  usage
60
65
  end
61
66
 
67
+ def self.require_bundled_gems
68
+ if File.exist?('Gemfile')
69
+ require 'bundler'
70
+ Bundler.setup(:default)
71
+ Bundler.require(:default)
72
+ end
73
+ end
74
+
75
+ def self.class_for_command(command)
76
+ const_names = command.split(':').map { |word| word.capitalize }
77
+ const_names.inject(Nesta::Commands) do |namespace, const|
78
+ namespace.const_get(const)
79
+ end
80
+ end
81
+
62
82
  def self.main(options)
63
83
  command = ARGV.shift
64
84
  command.nil? && usage
65
- case command
66
- when 'new'
67
- Nesta::Commands::New.new(ARGV[0], options).execute
68
- when 'demo:content'
69
- Nesta::Commands::Demo::Content.new.execute
70
- when 'plugin:create'
71
- Nesta::Commands::Plugin::Create.new(ARGV[0]).execute
72
- when /^theme:(create|enable|install)$/
73
- command_cls = Nesta::Commands::Theme.const_get($1.capitalize.to_sym)
74
- command_cls.new(ARGV[0], options).execute
75
- else
76
- usage(exitcode=0)
85
+ begin
86
+ command_cls = class_for_command(command)
87
+ rescue NameError
88
+ usage
89
+ else
90
+ command_cls.new(ARGV[0], options).execute
77
91
  end
78
92
  rescue RuntimeError => e
79
93
  $stderr.puts "ERROR: #{e}"
@@ -82,7 +96,54 @@ EOF
82
96
  $stderr.puts "ERROR: #{e}"
83
97
  usage
84
98
  end
99
+
100
+ def self.bash_completion
101
+ puts <<-EOF
102
+ # Bash completion configuration for the nesta command.
103
+ #
104
+ # Install it with these commands:
105
+ #
106
+ # $ nesta --bash-completion > ~/.nesta-completion.sh
107
+ # $ echo '[ -f ~/.nesta-completion.sh ] && source ~/.nesta-completion.sh' \
108
+ # >> ~/.bash_profile
109
+ # $ source ~/.nesta-completion.sh
110
+
111
+ _nesta() {
112
+ local cur prev opts pages
113
+ COMPREPLY=()
114
+ cur="${COMP_WORDS[COMP_CWORD]}"
115
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
116
+
117
+ opts="new 'demo:content' edit 'plugin:create' 'theme:install' 'theme:enable' 'theme:create'"
118
+
119
+ case "${cur}" in
120
+ theme:*)
121
+ COMPREPLY=( $(compgen -W "enable install" -- ${cur##*:}) )
122
+ return 0
123
+ ;;
124
+ esac
125
+
126
+ case "${prev}" in
127
+ edit)
128
+ local pages_path="content/pages"
129
+ local pages="$(find $pages_path -type f | sed s,$pages_path/,,)"
130
+ COMPREPLY=( $(compgen -W "$pages" -- $cur) )
131
+ return 0
132
+ ;;
133
+ *)
134
+ ;;
135
+ esac
136
+
137
+ COMPREPLY=( $(compgen -W "$opts" -- $cur) )
138
+ return 0
139
+ }
140
+ complete -F _nesta nesta
141
+ EOF
142
+ exit 0
143
+ end
85
144
  end
86
145
  end
87
146
 
147
+ Nesta::Cli.require_bundled_gems
148
+ Nesta::Plugin.initialize_plugins
88
149
  Nesta::Cli.main(Nesta::Cli.parse_command_line)
@@ -1 +1,9 @@
1
+ module Nesta
2
+ def self.deprecated(name, message)
3
+ if Nesta::App.environment != :test
4
+ $stderr.puts "DEPRECATION WARNING: #{name} is deprecated; #{message}"
5
+ end
6
+ end
7
+ end
8
+
1
9
  require "nesta/plugin"
@@ -2,15 +2,15 @@ require 'sinatra/base'
2
2
  require 'haml'
3
3
  require 'sass'
4
4
 
5
+ require File.expand_path('../nesta', File.dirname(__FILE__))
5
6
  require File.expand_path('env', File.dirname(__FILE__))
6
- require File.expand_path('nesta', File.dirname(__FILE__))
7
7
  require File.expand_path('cache', File.dirname(__FILE__))
8
8
  require File.expand_path('config', File.dirname(__FILE__))
9
9
  require File.expand_path('models', File.dirname(__FILE__))
10
+ require File.expand_path('helpers', File.dirname(__FILE__))
10
11
  require File.expand_path('navigation', File.dirname(__FILE__))
11
12
  require File.expand_path('overrides', File.dirname(__FILE__))
12
13
  require File.expand_path('path', File.dirname(__FILE__))
13
- require File.expand_path('plugin', File.dirname(__FILE__))
14
14
 
15
15
  Encoding.default_external = 'utf-8' if RUBY_VERSION =~ /^1.9/
16
16
 
@@ -25,90 +25,11 @@ module Nesta
25
25
 
26
26
  helpers Overrides::Renderers
27
27
  helpers Navigation::Renderers
28
-
29
- helpers do
30
- def set_from_config(*variables)
31
- variables.each do |var|
32
- instance_variable_set("@#{var}", Nesta::Config.send(var))
33
- end
34
- end
35
-
36
- def set_from_page(*variables)
37
- variables.each do |var|
38
- instance_variable_set("@#{var}", @page.send(var))
39
- end
40
- end
41
-
42
- def no_widow(text)
43
- text.split[0...-1].join(" ") + "&nbsp;#{text.split[-1]}"
44
- end
45
-
46
- def set_common_variables
47
- @menu_items = Nesta::Menu.for_path('/')
48
- @site_title = Nesta::Config.title
49
- set_from_config(:title, :subtitle, :google_analytics_code)
50
- @heading = @title
51
- end
52
-
53
- def url_for(page)
54
- File.join(base_url, page.path)
55
- end
56
-
57
- def base_url
58
- url = "http://#{request.host}"
59
- request.port == 80 ? url : url + ":#{request.port}"
60
- end
61
-
62
- def absolute_urls(text)
63
- text.gsub!(/(<a href=['"])\//, '\1' + base_url + '/')
64
- text
65
- end
66
-
67
- def nesta_atom_id_for_page(page)
68
- published = page.date.strftime('%Y-%m-%d')
69
- "tag:#{request.host},#{published}:#{page.abspath}"
70
- end
71
-
72
- def atom_id(page = nil)
73
- if page
74
- page.atom_id || nesta_atom_id_for_page(page)
75
- else
76
- "tag:#{request.host},2009:/"
77
- end
78
- end
79
-
80
- def format_date(date)
81
- date.strftime("%d %B %Y")
82
- end
83
-
84
- def local_stylesheet?
85
- Nesta.deprecated('local_stylesheet?', 'use local_stylesheet_link_tag')
86
- File.exist?(File.expand_path('views/local.sass', Nesta::App.root))
87
- end
88
-
89
- def local_stylesheet_link_tag(name)
90
- pattern = File.expand_path("views/#{name}.s{a,c}ss", Nesta::App.root)
91
- if Dir.glob(pattern).size > 0
92
- haml_tag :link, :href => "/css/#{name}.css", :rel => "stylesheet"
93
- end
94
- end
95
-
96
- def latest_articles(count = 8)
97
- Nesta::Page.find_articles[0..count - 1]
98
- end
99
-
100
- def article_summaries(articles)
101
- haml(:summaries, :layout => false, :locals => { :pages => articles })
102
- end
103
-
104
- def articles_heading
105
- @page.metadata('articles heading') || "Articles on #{@page.heading}"
106
- end
107
- end
28
+ helpers View::Helpers
108
29
 
109
30
  before do
110
- if request.path =~ Regexp.new('./$')
111
- redirect to(request.path.sub(Regexp.new('/$'), ''))
31
+ if request.path_info =~ Regexp.new('./$')
32
+ redirect to(request.path_info.sub(Regexp.new('/$'), ''))
112
33
  end
113
34
  end
114
35
 
@@ -165,7 +86,6 @@ module Nesta
165
86
 
166
87
  get '*' do
167
88
  set_common_variables
168
- @heading = @title
169
89
  parts = params[:splat].map { |p| p.sub(/\/$/, '') }
170
90
  @page = Nesta::Page.find_by_path(File.join(parts))
171
91
  raise Sinatra::NotFound if @page.nil?
@@ -1,5 +1,4 @@
1
1
  require 'fileutils'
2
- # require 'sinatra/base'
3
2
 
4
3
  module Sinatra
5
4
 
@@ -27,7 +26,7 @@ module Sinatra
27
26
  # TODO:: implement the opts={} hash functionality. What other options are needed?
28
27
  #
29
28
  def cache(content, opts={})
30
- return content unless options.cache_enabled
29
+ return content unless settings.cache_enabled
31
30
 
32
31
  unless content.nil?
33
32
  content = "#{content}\n#{page_cached_timestamp}\n"
@@ -51,7 +50,7 @@ module Sinatra
51
50
  #
52
51
  # TODO:: implement the options={} hash functionality. What options are really needed ?
53
52
  def cache_expire(path = nil, opts={})
54
- return unless options.cache_enabled
53
+ return unless settings.cache_enabled
55
54
 
56
55
  path = (path.nil?) ? cache_page_path(request.path_info) : cache_page_path(path)
57
56
  if File.exist?(path)
@@ -72,7 +71,7 @@ module Sinatra
72
71
  # => <!-- page cached: 2009-02-24 12:00:00 -->
73
72
  #
74
73
  def page_cached_timestamp
75
- "<!-- page cached: #{Time.now.strftime("%Y-%d-%m %H:%M:%S")} -->\n" if options.cache_enabled
74
+ "<!-- page cached: #{Time.now.strftime("%Y-%d-%m %H:%M:%S")} -->\n" if settings.cache_enabled
76
75
  end
77
76
 
78
77
 
@@ -84,36 +83,36 @@ module Sinatra
84
83
  #
85
84
  def cache_file_name(path,opts={})
86
85
  name = (path.empty? || path == "/") ? "index" : Rack::Utils.unescape(path.sub(/^(\/)/,'').chomp('/'))
87
- name << options.cache_page_extension unless (name.split('/').last || name).include? '.'
86
+ name << settings.cache_page_extension unless (name.split('/').last || name).include? '.'
88
87
  return name
89
88
  end
90
89
 
91
90
  # Sets the full path to the cached page/file
92
- # Dependent upon Sinatra.options .public and .cache_dir variables being present and set.
91
+ # Dependent upon Sinatra.settings .public and .cache_dir variables being present and set.
93
92
  #
94
93
  def cache_page_path(path,opts={})
95
94
  # test if given a full path rather than relative path, otherwise join the public path to cache_dir
96
95
  # and ensure it is a full path
97
- cache_dir = (options.cache_dir == File.expand_path(options.cache_dir)) ?
98
- options.cache_dir : File.expand_path("#{options.public}/#{options.cache_dir}")
96
+ cache_dir = (settings.cache_dir == File.expand_path(settings.cache_dir)) ?
97
+ settings.cache_dir : File.expand_path("#{settings.public}/#{settings.cache_dir}")
99
98
  cache_dir = cache_dir[0..-2] if cache_dir[-1,1] == '/'
100
99
  "#{cache_dir}/#{cache_file_name(path,opts)}"
101
100
  end
102
101
 
103
102
  # TODO:: this implementation really stinks, how do I incorporate Sinatra's logger??
104
103
  def log(msg,scope=:debug)
105
- if options.cache_logging
106
- "Log: msg=[#{msg}]" if scope == options.cache_logging_level
104
+ if settings.cache_logging
105
+ "Log: msg=[#{msg}]" if scope == settings.cache_logging_level
107
106
  else
108
107
  # just ignore the stuff...
109
- # puts "just ignoring msg=[#{msg}] since cache_logging => [#{options.cache_logging.to_s}]"
108
+ # puts "just ignoring msg=[#{msg}] since cache_logging => [#{settings.cache_logging.to_s}]"
110
109
  end
111
110
  end
112
111
 
113
112
  end #/module Helpers
114
113
 
115
114
 
116
- # Sets the default options:
115
+ # Sets the default settings:
117
116
  #
118
117
  # * +:cache_enabled+ => toggle for the cache functionality. Default is: +true+
119
118
  # * +:cache_page_extension+ => sets the default extension for cached files. Default is: +.html+
@@ -136,4 +135,4 @@ module Sinatra
136
135
 
137
136
  register(Sinatra::Cache)
138
137
 
139
- end #/module Sinatra
138
+ end #/module Sinatra