nesta-plugin-foldable 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ require "spec/rake/spectask"
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ desc "Run all specs in spec directory"
7
+ Spec::Rake::SpecTask.new(:spec) do |t|
8
+ t.spec_files = FileList["spec/*_spec.rb"]
9
+ end
10
+
11
+ task :default => :spec
@@ -16,21 +16,11 @@ module Nesta
16
16
  def summary
17
17
  result = pre_fold_summary
18
18
  return result if result && !result.empty?
19
-
20
- # Sigh...it's a shame I had to copy-paste this
21
- # from nesta's models.rb just to get rid of the
22
- # heading.
23
- body_text = case @format
24
- when :mdown
25
- markup.sub(/^#[^#].*$\r?\n(\r?\n)?/, '')
26
- when :haml
27
- markup.sub(/^\s*%h1\s+.*$\r?\n(\r?\n)?/, '')
28
- when :textile
29
- markup.sub(/^\s*h1\.\s+.*$\r?\n(\r?\n)?/, '')
30
- end
31
19
 
32
- if body_text.include? '~~fold~~'
33
- summary_text = body_text.sub(/^[^\n]*~~fold~~.*\Z/m, '');
20
+ body_markup_text = body_markup
21
+
22
+ if body_markup_text.include? '~~fold~~'
23
+ summary_text = body_markup_text.sub(/^[^\n]*~~fold~~.*\Z/m, '');
34
24
  convert_to_html(@format, nil, summary_text)
35
25
  else
36
26
  nil
@@ -1,7 +1,7 @@
1
1
  module Nesta
2
2
  module Plugin
3
3
  module Foldable
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
6
6
  end
7
7
  end
@@ -18,9 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- # specify any dependencies here; for example:
22
- # s.add_development_dependency "rspec"
23
- # s.add_runtime_dependency "rest-client"
24
- s.add_dependency("nesta", ">= 0.9.11")
21
+ s.add_development_dependency "rspec", '1.3.0'
22
+ s.add_development_dependency "ruby-debug"
23
+ s.add_dependency("nesta", ">= 0.9.13")
25
24
  s.add_development_dependency("rake")
25
+ s.add_development_dependency('test-unit', '1.2.3')
26
26
  end
@@ -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,10 @@
1
+ Date: 2012-02-28
2
+ Summary: "Meta summary"
3
+
4
+ # Test Page Heading
5
+
6
+ Not in the summary
7
+
8
+ <!-- ~~fold~~ -->
9
+
10
+ Out of the summary
@@ -0,0 +1,8 @@
1
+ Date: 2012-02-28
2
+ Summary: "Meta summary"
3
+
4
+ # Test Page Heading
5
+
6
+ In the body
7
+
8
+ Not in the summary
@@ -0,0 +1,7 @@
1
+ Date: 2012-02-28
2
+
3
+ # Test Page Heading
4
+
5
+ In the summary
6
+
7
+ Still in the summary
@@ -0,0 +1,9 @@
1
+ Date: 2012-02-28
2
+
3
+ # Test Page Heading
4
+
5
+ In the summary
6
+
7
+ <!-- ~~fold~~ -->
8
+
9
+ Out of the summary
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'sinatra'
4
+ require 'nesta/env'
5
+ require 'ruby-debug'
6
+ Nesta::Env.root = File.expand_path('./foldable-plugin-test-nesta-site', File.dirname(__FILE__))
7
+
8
+ # Nesta requires the current dir to be the root
9
+ Dir.chdir(Nesta::Env.root)
10
+
11
+ require 'nesta/plugin'
12
+ require 'nesta-plugin-foldable'
13
+ require 'nesta/app'
14
+
15
+ describe "Foldable plugin" do
16
+ it "should have no summary if there is neither fold nor meta" do
17
+ page = Nesta::Page.find_by_path("testnofoldnometa")
18
+ page.summary.should be_nil
19
+ end
20
+
21
+ it "should use the fold if it's there" do
22
+ page = Nesta::Page.find_by_path("testwithfold")
23
+ page.summary.should include("In the summary")
24
+ page.summary.should_not include("Out of the summary")
25
+ end
26
+
27
+ it "should not use the fold if the summary is defined in metadata" do
28
+ page = Nesta::Page.find_by_path("testfoldandmeta")
29
+ page.summary.should include("Meta summary")
30
+ page.summary.should_not include("Not in the summary")
31
+ end
32
+
33
+ it "should should still pickup a summary defined in metadata with no fold" do
34
+ page = Nesta::Page.find_by_path("testnofoldmeta")
35
+ page.summary.should include("Meta summary")
36
+ page.summary.should_not include("In the body")
37
+ end
38
+
39
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nesta-plugin-foldable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Micah Chalmer
@@ -15,28 +15,58 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-22 00:00:00 Z
18
+ date: 2012-03-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: nesta
21
+ name: rspec
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - "="
27
+ - !ruby/object:Gem::Version
28
+ hash: 27
29
+ segments:
30
+ - 1
31
+ - 3
32
+ - 0
33
+ version: 1.3.0
34
+ type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: ruby-debug
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: nesta
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
24
54
  none: false
25
55
  requirements:
26
56
  - - ">="
27
57
  - !ruby/object:Gem::Version
28
- hash: 45
58
+ hash: 33
29
59
  segments:
30
60
  - 0
31
61
  - 9
32
- - 11
33
- version: 0.9.11
62
+ - 13
63
+ version: 0.9.13
34
64
  type: :runtime
35
- version_requirements: *id001
65
+ version_requirements: *id003
36
66
  - !ruby/object:Gem::Dependency
37
67
  name: rake
38
68
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
69
+ requirement: &id004 !ruby/object:Gem::Requirement
40
70
  none: false
41
71
  requirements:
42
72
  - - ">="
@@ -46,7 +76,23 @@ dependencies:
46
76
  - 0
47
77
  version: "0"
48
78
  type: :development
49
- version_requirements: *id002
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: test-unit
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - "="
87
+ - !ruby/object:Gem::Version
88
+ hash: 25
89
+ segments:
90
+ - 1
91
+ - 2
92
+ - 3
93
+ version: 1.2.3
94
+ type: :development
95
+ version_requirements: *id005
50
96
  description: Place a "fold" in a Nesta article and have the summary automatically set to the part of the body content that comes before it.
51
97
  email:
52
98
  - micah@micahchalmer.net
@@ -65,6 +111,12 @@ files:
65
111
  - lib/nesta-plugin-foldable/init.rb
66
112
  - lib/nesta-plugin-foldable/version.rb
67
113
  - nesta-plugin-foldable.gemspec
114
+ - spec/foldable-plugin-test-nesta-site/config/config.yml
115
+ - spec/foldable-plugin-test-nesta-site/content/pages/testfoldandmeta.mdown
116
+ - spec/foldable-plugin-test-nesta-site/content/pages/testnofoldmeta.mdown
117
+ - spec/foldable-plugin-test-nesta-site/content/pages/testnofoldnometa.mdown
118
+ - spec/foldable-plugin-test-nesta-site/content/pages/testwithfold.mdown
119
+ - spec/foldable_spec.rb
68
120
  homepage: https://github.com/MicahChalmer/nesta-plugin-foldable
69
121
  licenses: []
70
122