strelka-cms 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ChangeLog +95 -1
- data/History.rdoc +5 -0
- data/Manifest.txt +5 -3
- data/Rakefile +43 -9
- data/lib/strelka/apps.rb +12 -0
- data/lib/strelka/cms.rb +2 -2
- data/{data/strelka-cms/apps/content-feeds → lib/strelka/cms/feeds.rb} +1 -4
- data/lib/strelka/cms/page.rb +1 -0
- data/lib/strelka/cms/pagecatalog.rb +22 -4
- data/lib/strelka/cms/pagefilter.rb +0 -28
- data/lib/strelka/cms/pagefilter/autoindex.rb +37 -29
- data/{data/strelka-cms/apps/content-manager → lib/strelka/cms/publisher.rb} +50 -28
- data/spec/{lib/helpers.rb → helpers.rb} +5 -15
- data/spec/strelka/cms/page_spec.rb +18 -26
- data/spec/strelka/cms/pagecatalog_spec.rb +42 -26
- data/spec/strelka/cms/pagefilter/autoindex_spec.rb +83 -0
- data/spec/strelka/cms_spec.rb +5 -10
- metadata +122 -90
- metadata.gz.sig +1 -3
- data/.gemtest +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48864468ff1c947baea455bf5c0ed7c21aeb858e
|
4
|
+
data.tar.gz: 819f8b4ff6994d34a202beee4989f936ef444883
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14105cf4607b97da98b9519e642d0bf3b7bdd26c8ce084e0aca445fe03562f231fe08c9c03e82c4cf35369a7e0eb8bfcebfbefb8e37cbb1e922cb4033e6453c7
|
7
|
+
data.tar.gz: a925e1a36d975456d11d0d548324b9b4b270fd8073c222bb171fdce1ec2f21c12c674b6672f48479820ddd937815d39efc172ed52270fcf94c9a013e9fe7361a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/ChangeLog
CHANGED
@@ -1,9 +1,103 @@
|
|
1
|
+
2017-07-05 Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
* .gems, .pryrc, .ruby-gemset, .ruby-version, .rvm.gems, .rvmrc,
|
4
|
+
Rakefile, config.yml, data/strelka-cms/CMS_SCHEMA.sql, data/strelka-
|
5
|
+
cms/DEV_DB_SETUP.sql, lib/sequel/plugins/inline_migrations.rb,
|
6
|
+
lib/sequel/plugins/inline_schema.rb,
|
7
|
+
lib/sequel/plugins/soft_deletes.rb, lib/strelka/app/content-
|
8
|
+
feeds.rb, lib/strelka/app/content-manager.rb, lib/strelka/apps.rb,
|
9
|
+
lib/strelka/cms.rb, lib/strelka/cms/author.rb,
|
10
|
+
lib/strelka/cms/author_session.rb, lib/strelka/cms/feeds.rb,
|
11
|
+
lib/strelka/cms/model.rb, lib/strelka/cms/page.rb,
|
12
|
+
lib/strelka/cms/publisher.rb:
|
13
|
+
Import sequel workarounds, start work on models
|
14
|
+
[4caedd2c788a] [tip]
|
15
|
+
|
16
|
+
2017-06-14 Michael Granger <ged@FaerieMUD.org>
|
17
|
+
|
18
|
+
* .rvm.gems, .rvmrc, Gemfile, Gemfile.lock, Rakefile, cert/ged.pem,
|
19
|
+
data/strelka-cms/apps/content-feeds, data/strelka-cms/apps/content-
|
20
|
+
manager, lib/strelka/app/content-feeds.rb, lib/strelka/app/content-
|
21
|
+
manager.rb, lib/strelka/cms/page.rb, lib/strelka/cms/pagecatalog.rb,
|
22
|
+
lib/strelka/cms/pagefilter.rb,
|
23
|
+
lib/strelka/cms/pagefilter/autoindex.rb, spec/helpers.rb,
|
24
|
+
spec/lib/helpers.rb, spec/strelka/cms/page_spec.rb,
|
25
|
+
spec/strelka/cms/pagecatalog_spec.rb,
|
26
|
+
spec/strelka/cms/pagefilter/autoindex_spec.rb,
|
27
|
+
spec/strelka/cms_spec.rb, strelka.gemspec:
|
28
|
+
Checkpoint before rewrite
|
29
|
+
[69ae95545cdc]
|
30
|
+
|
31
|
+
2013-03-20 Michael Granger <ged@FaerieMUD.org>
|
32
|
+
|
33
|
+
* .hgtags:
|
34
|
+
Added tag v0.2.0 for changeset 76070ab08bdd
|
35
|
+
[968469d5f06c]
|
36
|
+
|
37
|
+
* .hgsigs:
|
38
|
+
Added signature for changeset 7e6d67090ff3
|
39
|
+
[76070ab08bdd] [v0.2.0]
|
40
|
+
|
41
|
+
* History.rdoc, lib/strelka/cms.rb:
|
42
|
+
Bump the minor version, update history.
|
43
|
+
[7e6d67090ff3]
|
44
|
+
|
45
|
+
* .rvm.gems, .tm_properties, Rakefile, lib/strelka/cms/page.rb,
|
46
|
+
lib/strelka/cms/pagefilter.rb,
|
47
|
+
lib/strelka/cms/pagefilter/example.rb,
|
48
|
+
spec/strelka/cms/page_spec.rb:
|
49
|
+
Update for newer versions of Strelka/convert to Pluggability.
|
50
|
+
[4baf070eb372]
|
51
|
+
|
52
|
+
2013-02-28 Michael Granger <ged@FaerieMUD.org>
|
53
|
+
|
54
|
+
* .hgtags:
|
55
|
+
Added tag v0.1.0 for changeset d9a60c86dfa9
|
56
|
+
[c0c3226c7b49]
|
57
|
+
|
58
|
+
* .hgsigs:
|
59
|
+
Added signature for changeset 34ca70dbf0f8
|
60
|
+
[d9a60c86dfa9] [v0.1.0]
|
61
|
+
|
62
|
+
* History.rdoc, lib/strelka/cms.rb:
|
63
|
+
Bump minor version, update history.
|
64
|
+
[34ca70dbf0f8]
|
65
|
+
|
66
|
+
* .rvm.gems, Rakefile, lib/strelka/cms/page.rb,
|
67
|
+
spec/strelka/cms/page_spec.rb:
|
68
|
+
Update gems, convert from summarize to ots.
|
69
|
+
[aa0f957b7aa8]
|
70
|
+
|
71
|
+
* .rvmrc:
|
72
|
+
Test under Ruby 2 by default
|
73
|
+
[6152c3c159b6]
|
74
|
+
|
75
|
+
2012-10-29 Michael Granger <ged@FaerieMUD.org>
|
76
|
+
|
77
|
+
* .hgtags:
|
78
|
+
Added tag v0.0.1 for changeset a2b1b1cf2f73
|
79
|
+
[412de32e62d7]
|
80
|
+
|
81
|
+
* .hgsigs:
|
82
|
+
Added signature for changeset 82c00e592623
|
83
|
+
[a2b1b1cf2f73] [v0.0.1]
|
84
|
+
|
85
|
+
* .rvm.gems, History.rdoc, Manifest.txt, README.rdoc, Rakefile, data
|
86
|
+
/strelka-cms/apps/content-manager, data/strelka-
|
87
|
+
cms/templates/layout.tmpl, etc/config.yml, public/news/v0.0.1.page:
|
88
|
+
Prep for release.
|
89
|
+
|
90
|
+
- Update dependencies
|
91
|
+
- Add a page for testing the RSSS feeds app.
|
92
|
+
- Allow pages with single dots in the filename.
|
93
|
+
[82c00e592623]
|
94
|
+
|
1
95
|
2012-08-09 Michael Granger <ged@FaerieMUD.org>
|
2
96
|
|
3
97
|
* data/strelka-cms/apps/content-feeds, lib/strelka/cms/page.rb,
|
4
98
|
lib/strelka/cms/pagefilter/autoindex.rb:
|
5
99
|
Merged with a31949150348
|
6
|
-
[8d4142b7bd18]
|
100
|
+
[8d4142b7bd18]
|
7
101
|
|
8
102
|
2012-08-01 Michael Granger <ged@FaerieMUD.org>
|
9
103
|
|
data/History.rdoc
CHANGED
data/Manifest.txt
CHANGED
@@ -4,13 +4,13 @@ Manifest.txt
|
|
4
4
|
Procfile
|
5
5
|
README.rdoc
|
6
6
|
Rakefile
|
7
|
-
data/strelka-cms/apps/content-feeds
|
8
|
-
data/strelka-cms/apps/content-manager
|
9
7
|
data/strelka-cms/templates/autoindex/default.tmpl
|
10
8
|
data/strelka-cms/templates/layout.tmpl
|
11
9
|
data/strelka-cms/templates/page.tmpl
|
12
10
|
etc/mongrel.rb
|
11
|
+
lib/strelka/apps.rb
|
13
12
|
lib/strelka/cms.rb
|
13
|
+
lib/strelka/cms/feeds.rb
|
14
14
|
lib/strelka/cms/page.rb
|
15
15
|
lib/strelka/cms/pagecatalog.rb
|
16
16
|
lib/strelka/cms/pagefilter.rb
|
@@ -20,6 +20,7 @@ lib/strelka/cms/pagefilter/editorial.rb
|
|
20
20
|
lib/strelka/cms/pagefilter/example.rb
|
21
21
|
lib/strelka/cms/pagefilter/strip.rb
|
22
22
|
lib/strelka/cms/pagefilter/textile.rb
|
23
|
+
lib/strelka/cms/publisher.rb
|
23
24
|
public/humans.txt
|
24
25
|
public/images/misc/button-gloss.png
|
25
26
|
public/images/misc/button-overlay.png
|
@@ -47,7 +48,8 @@ public/stylesheets/app.css
|
|
47
48
|
public/stylesheets/foundation.css
|
48
49
|
public/stylesheets/ie.css
|
49
50
|
spec/data/test.page
|
50
|
-
spec/
|
51
|
+
spec/helpers.rb
|
51
52
|
spec/strelka/cms/page_spec.rb
|
52
53
|
spec/strelka/cms/pagecatalog_spec.rb
|
54
|
+
spec/strelka/cms/pagefilter/autoindex_spec.rb
|
53
55
|
spec/strelka/cms_spec.rb
|
data/Rakefile
CHANGED
@@ -8,9 +8,10 @@ rescue LoadError
|
|
8
8
|
abort "This Rakefile requires 'hoe' (gem install hoe)"
|
9
9
|
end
|
10
10
|
|
11
|
+
GEMSPEC = 'strelka-cms.gemspec'
|
12
|
+
|
11
13
|
Hoe.plugin :mercurial
|
12
14
|
Hoe.plugin :signing
|
13
|
-
Hoe.plugin :manualgen
|
14
15
|
Hoe.plugin :deveiate
|
15
16
|
|
16
17
|
Hoe.plugins.delete :rubyforge
|
@@ -19,24 +20,25 @@ hoespec = Hoe.spec 'strelka-cms' do
|
|
19
20
|
self.readme_file = 'README.rdoc'
|
20
21
|
self.history_file = 'History.rdoc'
|
21
22
|
self.extra_rdoc_files = FileList[ '*.rdoc' ]
|
23
|
+
self.license "BSD-3-Clause"
|
22
24
|
|
23
25
|
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
24
26
|
|
25
|
-
self.dependency 'strelka', '~> 0.0'
|
26
|
-
self.dependency 'ratom', '~> 0.6'
|
27
27
|
self.dependency 'RedCloth', '~> 4.2'
|
28
|
+
self.dependency 'nokogiri', '~> 1.6'
|
29
|
+
self.dependency 'strelka', '~> 0.15'
|
30
|
+
self.dependency 'ratom', '~> 0.8'
|
28
31
|
self.dependency 'ots', '~> 0.5'
|
29
|
-
self.dependency '
|
30
|
-
self.dependency 'pluggability', '~> 0.0'
|
32
|
+
self.dependency 'pluggability', '~> 0.2'
|
31
33
|
self.dependency 'tidy-ext', '~> 0.1'
|
32
34
|
self.dependency 'rcodetools', '~> 0.8'
|
33
35
|
self.dependency 'strelka-fancyerrors', '~> 0.0'
|
36
|
+
self.dependency 'mail', '~> 2.6'
|
34
37
|
|
35
|
-
self.dependency 'hoe-deveiate', '~> 0.
|
38
|
+
self.dependency 'hoe-deveiate', '~> 0.3', :developer
|
39
|
+
self.dependency 'fakefs', '~> 0.4', :developer
|
36
40
|
|
37
|
-
self.
|
38
|
-
self.spec_extras[:rdoc_options] = ['-f', 'fivefish', '-t', 'Strelka CMS']
|
39
|
-
self.require_ruby_version( '>=1.9.3' )
|
41
|
+
self.require_ruby_version( '>=2.3.4' )
|
40
42
|
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
|
41
43
|
self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
|
42
44
|
|
@@ -62,6 +64,38 @@ if Rake::Task.task_defined?( '.gemtest' )
|
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
67
|
+
# Use the fivefish formatter for docs generated from development checkout
|
68
|
+
if File.directory?( '.hg' )
|
69
|
+
require 'rdoc/task'
|
70
|
+
|
71
|
+
Rake::Task[ 'docs' ].clear
|
72
|
+
RDoc::Task.new( 'docs' ) do |rdoc|
|
73
|
+
rdoc.main = "README.rdoc"
|
74
|
+
rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb" )
|
75
|
+
rdoc.generator = :fivefish
|
76
|
+
rdoc.title = "Strelka-CMS: A file-based content management system"
|
77
|
+
rdoc.rdoc_dir = 'doc'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
task :gemspec => GEMSPEC
|
83
|
+
file GEMSPEC => __FILE__
|
84
|
+
task GEMSPEC do |task|
|
85
|
+
spec = $hoespec.spec
|
86
|
+
spec.files.delete( '.gemtest' )
|
87
|
+
spec.signing_key = nil
|
88
|
+
spec.cert_chain = Rake::FileList[ 'certs/*.pem' ].to_a
|
89
|
+
spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
|
90
|
+
File.open( task.name, 'w' ) do |fh|
|
91
|
+
fh.write( spec.to_ruby )
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
CLOBBER.include( GEMSPEC.to_s )
|
96
|
+
task :default => :gemspec
|
97
|
+
|
98
|
+
|
65
99
|
|
66
100
|
# Add admin app testing directories to the clobber list
|
67
101
|
CLOBBER.include( 'static', 'run', 'logs', 'strelka.sqlite' )
|
data/lib/strelka/apps.rb
ADDED
data/lib/strelka/cms.rb
CHANGED
@@ -19,10 +19,10 @@ module Strelka::CMS
|
|
19
19
|
|
20
20
|
|
21
21
|
# Version string
|
22
|
-
VERSION = '0.
|
22
|
+
VERSION = '0.3.0'
|
23
23
|
|
24
24
|
# Version-control revision constant
|
25
|
-
REVISION = %q$Revision:
|
25
|
+
REVISION = %q$Revision: e9f738cb50e0 $
|
26
26
|
|
27
27
|
|
28
28
|
require 'strelka/cms/page'
|
@@ -17,7 +17,7 @@ require 'strelka/cms/page'
|
|
17
17
|
|
18
18
|
|
19
19
|
# The Feed applet -- generate RSS and Atom feeds for various things.
|
20
|
-
class Strelka::CMS::
|
20
|
+
class Strelka::CMS::Feeds < Strelka::App
|
21
21
|
extend Loggability,
|
22
22
|
Configurability,
|
23
23
|
Strelka::MethodUtilities
|
@@ -194,6 +194,3 @@ class Strelka::CMS::ContentFeeds < Strelka::App
|
|
194
194
|
|
195
195
|
|
196
196
|
end # class Strelka::CMS::Feeds
|
197
|
-
|
198
|
-
Encoding.default_internal = Encoding::UTF_8
|
199
|
-
Strelka::CMS::Feeds.run if __FILE__ == $0
|
data/lib/strelka/cms/page.rb
CHANGED
@@ -226,6 +226,7 @@ class Strelka::CMS::Page
|
|
226
226
|
### it in its configured template if it has one.
|
227
227
|
def render( * )
|
228
228
|
if path = self.template
|
229
|
+
self.log.debug "Wrapping %p in template at %p" % [ self, path ]
|
229
230
|
tmpl = Inversion::Template.load( path )
|
230
231
|
tmpl.page = self
|
231
232
|
return tmpl
|
@@ -28,7 +28,8 @@ class Strelka::CMS::PageCatalog
|
|
28
28
|
|
29
29
|
### Create a new PageCatalog that will find and read pages from the configured
|
30
30
|
### directory.
|
31
|
-
def initialize( basedir=
|
31
|
+
def initialize( basedir=nil, pattern=DEFAULT_GLOB_PATTERN )
|
32
|
+
basedir ||= Pathname.pwd
|
32
33
|
pattern.slice!( 0, 1 ) if pattern.start_with?( '/' )
|
33
34
|
self.log.debug "New catalog for pages matching: %s in: %s" % [ pattern, basedir ]
|
34
35
|
@basedir = Pathname( basedir )
|
@@ -94,14 +95,30 @@ class Strelka::CMS::PageCatalog
|
|
94
95
|
end
|
95
96
|
|
96
97
|
|
98
|
+
### Fetch a Strelka::CMS::Page from the catalog that matches +pagename+.
|
99
|
+
def []( pagename )
|
100
|
+
pagename = pagename + '.page' unless pagename.end_with?( '.page' )
|
101
|
+
paths = self.page_path_enumerator
|
102
|
+
pagepath = paths.find do |path|
|
103
|
+
self.log.debug "Testing path %s (relative to %s) for %s: %s" %
|
104
|
+
[ path, self.basedir, pagename, path.relative_path_from(self.basedir) ]
|
105
|
+
path.relative_path_from(self.basedir).to_s == pagename.to_s
|
106
|
+
end or return nil
|
107
|
+
|
108
|
+
return Strelka::CMS::Page.load( pagepath, self )
|
109
|
+
end
|
110
|
+
|
111
|
+
|
97
112
|
#########
|
98
113
|
protected
|
99
114
|
#########
|
100
115
|
|
101
116
|
### Return an Enumerator that will yield a Pathname for each page matching the #pageglob
|
102
117
|
def page_path_enumerator
|
103
|
-
self.log.debug "Fetching an enumerator for %s" % [ self.glob ]
|
104
|
-
Pathname.glob( self.glob )
|
118
|
+
self.log.debug "Fetching an enumerator for files matching: %s" % [ self.glob ]
|
119
|
+
paths = Pathname.glob( self.glob )
|
120
|
+
self.log.debug " fully-qualifying %d paths: %p" % [ paths.length, paths ]
|
121
|
+
return paths.collect {|fn| self.basedir + fn }.each
|
105
122
|
end
|
106
123
|
|
107
124
|
|
@@ -110,7 +127,8 @@ class Strelka::CMS::PageCatalog
|
|
110
127
|
def page_enumerator
|
111
128
|
Enumerator.new do |yielder|
|
112
129
|
self.page_path_enumerator.each do |path|
|
113
|
-
|
130
|
+
self.log.debug "Loading %s..." % [ path ]
|
131
|
+
page = Strelka::CMS::Page.load( path.to_s, self )
|
114
132
|
yielder.yield( page )
|
115
133
|
end
|
116
134
|
end
|
@@ -25,34 +25,6 @@ class Strelka::CMS::PageFilter
|
|
25
25
|
plugin_prefixes 'strelka/cms/pagefilter'
|
26
26
|
|
27
27
|
|
28
|
-
### Search for plugins in the $LOAD_PATH and load each of them that's found.
|
29
|
-
def self::load_all
|
30
|
-
loaded = []
|
31
|
-
glob_pat = '{' + self.derivative_dirs.join(',') + '}/*.rb'
|
32
|
-
$LOAD_PATH.uniq.collect {|path| path.untaint; Pathname(path) }.each do |base|
|
33
|
-
self.log.debug " searching for %s" % [ base + glob_pat ]
|
34
|
-
Pathname.glob( base + glob_pat ).each do |plugin|
|
35
|
-
# Don't load this file twice
|
36
|
-
next if Pathname(__FILE__).expand_path == plugin.expand_path
|
37
|
-
|
38
|
-
begin
|
39
|
-
path = plugin.to_s.untaint
|
40
|
-
require( path )
|
41
|
-
loaded << plugin
|
42
|
-
rescue LoadError, SecurityError => err
|
43
|
-
self.log.error " %s while loading %s: %s" %
|
44
|
-
[ err.class.name, plugin.to_s, err.message ]
|
45
|
-
err.backtrace.each do |frame|
|
46
|
-
self.log.debug " #{frame}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
return loaded
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
28
|
#################################################################
|
57
29
|
### I N S T A N C E M E T H O D S
|
58
30
|
#################################################################
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'ostruct'
|
4
|
+
require 'English'
|
4
5
|
|
5
6
|
require 'strelka/cms/pagecatalog'
|
6
7
|
require 'strelka/cms/page'
|
@@ -33,8 +34,8 @@ class Strelka::CMS::PageFilter::AutoIndex < Strelka::CMS::PageFilter
|
|
33
34
|
<\?
|
34
35
|
autoindex # Instruction Target
|
35
36
|
\s+
|
36
|
-
(
|
37
|
-
(
|
37
|
+
(?<pattern>\S+) # glob for pages to link [$1]
|
38
|
+
(?<options>.*?) # options [$2]
|
38
39
|
\s*
|
39
40
|
\?>
|
40
41
|
}xm
|
@@ -59,42 +60,33 @@ class Strelka::CMS::PageFilter::AutoIndex < Strelka::CMS::PageFilter
|
|
59
60
|
def process( source, page )
|
60
61
|
self.log.info "Looking for autoindex directives..."
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
self.log.debug "Generating an index for %p relative to %p." % [ pattern, page.path ]
|
71
|
-
self.generate_index( pattern, page, catalog, options )
|
72
|
-
end
|
73
|
-
return source
|
74
|
-
else
|
75
|
-
self.log.debug "Not generating autoindex sections: no catalog"
|
76
|
-
return source.gsub( PI, NO_CATALOG_COMMENT )
|
63
|
+
catalog = page.catalog or return self.strip_instructions( source )
|
64
|
+
|
65
|
+
self.log.debug "Processing autoindex directives."
|
66
|
+
return source.gsub( PI ) do |*|
|
67
|
+
pattern = $LAST_MATCH_INFO[:pattern]
|
68
|
+
options = $LAST_MATCH_INFO[:options]
|
69
|
+
self.generate_index( pattern, page, catalog, options )
|
77
70
|
end
|
78
71
|
end
|
79
72
|
|
80
73
|
|
74
|
+
### Strip autoindex PIs from +source+ and return it.
|
75
|
+
def strip_instructions( source )
|
76
|
+
self.log.debug "Not generating autoindex sections: no catalog"
|
77
|
+
return source.gsub( PI, NO_CATALOG_COMMENT )
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
81
|
### Create an HTML fragment.
|
82
82
|
def generate_index( pattern, page, catalog, options )
|
83
|
-
self.log.debug "Generating
|
84
|
-
[ pattern, page,
|
83
|
+
self.log.debug "Generating an index for %p relative to %p with options: %p." %
|
84
|
+
[ pattern, page.path, options ]
|
85
|
+
|
85
86
|
options = self.parse_options( options )
|
86
87
|
style = options.style || DEFAULT_STYLE
|
87
88
|
|
88
|
-
pages =
|
89
|
-
self.log.debug " absolute pattern; matching relative to catalog basedir %p" %
|
90
|
-
[ catalog.basedir.to_s ]
|
91
|
-
catalog.matching_pattern( pattern ).to_a
|
92
|
-
else
|
93
|
-
self.log.debug " relative pattern; matching relative to page directory %p" %
|
94
|
-
[ page.path.dirname.to_s ]
|
95
|
-
catalog.relative_to( page.path.dirname ).matching_pattern( pattern ).to_a
|
96
|
-
end
|
97
|
-
pages = self.sort_pages( pages, options ) if options.sortkey
|
89
|
+
pages = self.find_matching_pages( catalog, page, pattern, options )
|
98
90
|
|
99
91
|
style = style + '.tmpl' unless style =~ /\.tmpl$/
|
100
92
|
style = DEFAULT_TEMPLATE_DIR + style
|
@@ -116,6 +108,20 @@ class Strelka::CMS::PageFilter::AutoIndex < Strelka::CMS::PageFilter
|
|
116
108
|
protected
|
117
109
|
#########
|
118
110
|
|
111
|
+
### Return the pages matching the specified +pattern+ in the +catalog+ relative
|
112
|
+
### to the given +page+.
|
113
|
+
def find_matching_pages( catalog, page, pattern, options )
|
114
|
+
self.log.debug "Find pages in catalog %p matching pattern %p relative to page %p.." %
|
115
|
+
[ catalog, pattern, page ]
|
116
|
+
pages = catalog.matching_pattern( pattern )
|
117
|
+
pages = pages.relative_to( page.path.dirname ) unless pattern.start_with?( '/' )
|
118
|
+
pages = self.sort_pages( pages.to_a, options )
|
119
|
+
pages = pages[ 0, options.limit ] if options.limit
|
120
|
+
|
121
|
+
return pages
|
122
|
+
end
|
123
|
+
|
124
|
+
|
119
125
|
### Parse the options to the PI, returning the results as an OpenStruct.
|
120
126
|
def parse_options( optstring )
|
121
127
|
opts = OpenStruct.new
|
@@ -135,6 +141,8 @@ class Strelka::CMS::PageFilter::AutoIndex < Strelka::CMS::PageFilter
|
|
135
141
|
return pages.sort_by {|page| page.path.mtime }.reverse
|
136
142
|
when 'title'
|
137
143
|
return pages.sort_by {|page| page.title }
|
144
|
+
when nil
|
145
|
+
return pages
|
138
146
|
else
|
139
147
|
self.log.error "Don't know how to sort the index by %p" % [ options.sortkey ]
|
140
148
|
end
|