nesta-plugin-foldable 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in nesta-plugin-foldable.gemspec
4
+ gemspec
data/README.mdown ADDED
@@ -0,0 +1,22 @@
1
+ # "Foldable" plugin for Nesta CMS
2
+
3
+ In Nesta, the summary of an article (what appears on home or category pages) is specified in metadata, independently of the article's body. That's nice if you want it to be independent, but what if you really do want the summary to be the same as the beginning of the article? It's annoying to have to repeat it twice, especially if has formatting or more than just a simple paragraph.
4
+
5
+ This plugin allows you to place a `~~fold~~` in your content, and will set the summary automatically to the body content that comes before it (not including the heading.) For instance, you could have an article like this:
6
+
7
+ Date: February 21, 2012
8
+
9
+ # My Awesome Article
10
+
11
+ This paragraph is included in the summary
12
+
13
+ * So is this
14
+ * and this
15
+
16
+ <!-- ~~fold ~~ -->
17
+
18
+ But this part is not in the summary.
19
+
20
+ The plugin makes no attempt to remove the `~~fold~~` from the body's content. Wrap it in an HTML comment so that it doesn't show on your body page. The summary will include everything up to, but not including, the line containing `~~fold~~`, so the summary won't include the `<!--` at the start of the line.
21
+
22
+ Setting the summary via metadata will still work as normal. If your page has both a `~~fold~~` and a summary set in metadata, the metadata wins and the `~~fold~~` is ignored.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,44 @@
1
+ module Nesta
2
+ module Plugin
3
+ module Foldable
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::Foldable::Helpers
12
+ end
13
+
14
+ class Page
15
+ alias_method :pre_fold_summary, :summary
16
+ def summary
17
+ result = pre_fold_summary
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
+
32
+ if body_text.include? '~~fold~~'
33
+ $stderr.puts body_text
34
+ summary_text = body_text.sub(/^[^\n]*~~fold~~.*\Z/m, '');
35
+ x = convert_to_html(@format, nil, summary_text)
36
+ $stderr.puts "Summary: #{x}"
37
+ x
38
+ else
39
+ $stderr.puts "#{heading}: no fold here"
40
+ nil
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,7 @@
1
+ module Nesta
2
+ module Plugin
3
+ module Foldable
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ require "nesta-plugin-foldable/version"
2
+
3
+ Nesta::Plugin.register(__FILE__)
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "nesta-plugin-foldable/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "nesta-plugin-foldable"
7
+ s.version = Nesta::Plugin::Foldable::VERSION
8
+ s.authors = ["Micah Chalmer"]
9
+ s.email = ["micah@micahchalmer.net"]
10
+ s.homepage = ""
11
+ s.summary = %q{Nesta plugin "Foldable"}
12
+ s.description = %q{Place a "fold" in a Nesta article and have the summary automatically set to the part of the body content that comes before it.}
13
+
14
+ s.rubyforge_project = "nesta-plugin-foldable"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
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")
25
+ s.add_development_dependency("rake")
26
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nesta-plugin-foldable
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Micah Chalmer
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-02-22 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: nesta
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 45
29
+ segments:
30
+ - 0
31
+ - 9
32
+ - 11
33
+ version: 0.9.11
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
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
+ 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
+ email:
52
+ - micah@micahchalmer.net
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ extra_rdoc_files: []
58
+
59
+ files:
60
+ - .gitignore
61
+ - Gemfile
62
+ - README.mdown
63
+ - Rakefile
64
+ - lib/nesta-plugin-foldable.rb
65
+ - lib/nesta-plugin-foldable/init.rb
66
+ - lib/nesta-plugin-foldable/version.rb
67
+ - nesta-plugin-foldable.gemspec
68
+ homepage: ""
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options: []
73
+
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ requirements: []
95
+
96
+ rubyforge_project: nesta-plugin-foldable
97
+ rubygems_version: 1.8.17
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Nesta plugin "Foldable"
101
+ test_files: []
102
+