gollum-site 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +29 -9
- data/bin/gollum-site +45 -7
- data/lib/gollum-site.rb +5 -3
- data/lib/gollum-site/markup.rb +0 -3
- data/lib/gollum-site/page.rb +51 -6
- data/lib/gollum-site/site.rb +109 -65
- data/lib/gollum-site/version.rb +1 -1
- data/lib/gollum-site/wiki.rb +6 -0
- data/test/examples/test_site.git/logs/HEAD +1 -0
- data/test/examples/test_site.git/logs/refs/heads/master +1 -0
- data/test/examples/test_site.git/objects/24/d9d55aef25343c5a1c6f2d3ac09512a37a8687 +0 -0
- data/test/examples/test_site.git/objects/43/a97c5259b27129a0fadff58ba8aa8ebbb62523 +0 -0
- data/test/examples/test_site.git/objects/6b/a5b4d83ba18c2bd85fade0c03816e5b2bfa9f4 +0 -0
- data/test/examples/test_site.git/objects/c2/1da0b71136462ceda60b7c4fab79311338eafa +0 -0
- data/test/examples/test_site.git/objects/ff/b5bbc20089dd64632b4aa7b2be312cfaddae35 +0 -0
- data/test/examples/test_site.git/refs/heads/master +1 -1
- data/test/test_site.rb +50 -35
- metadata +15 -4
data/README.md
CHANGED
@@ -52,21 +52,13 @@ A layout is a Liquid template applied to a wiki page during static site
|
|
52
52
|
generation with the following data made available to it:
|
53
53
|
|
54
54
|
* `wiki.base_path` The base path of the Wiki to which the page belongs
|
55
|
+
* `page.path` The output path of the page
|
55
56
|
* `page.content` The formatted content of the page
|
56
57
|
* `page.title` The title of the page
|
57
58
|
* `page.format` The format of the page (textile, org, etc.)
|
58
59
|
* `page.author` The author of the last edit
|
59
60
|
* `page.date` The date of the last edit
|
60
61
|
|
61
|
-
## Default Layout
|
62
|
-
|
63
|
-
A default layout is applied to the root folder for wikis that do not define a
|
64
|
-
root layout. The default layout is the same used in gollum without the edit
|
65
|
-
features. It's possible to generate a site without the default template using
|
66
|
-
the "--no_default_layout" option:
|
67
|
-
|
68
|
-
$ gollum-site --no_default_layout generate
|
69
|
-
|
70
62
|
## Import
|
71
63
|
|
72
64
|
The gollum-site executable provides the ability to import the default layout to
|
@@ -76,6 +68,24 @@ repository before the 'generate' command will recognize them.
|
|
76
68
|
|
77
69
|
$ gollum-site import
|
78
70
|
|
71
|
+
## Working
|
72
|
+
|
73
|
+
You can generate a static site from untracked/uncommitted changes by using the
|
74
|
+
"--working" flag.
|
75
|
+
|
76
|
+
$ gollum-site generate --working
|
77
|
+
|
78
|
+
## Watch
|
79
|
+
|
80
|
+
When running the gollum-site server you can enable directory watching to update
|
81
|
+
the static site when changes are made to any of the wiki or static files. This
|
82
|
+
currently does not work for layout updates (full site regeneration is required).
|
83
|
+
|
84
|
+
$ gollum-site serve --watch
|
85
|
+
|
86
|
+
This feature requires the
|
87
|
+
[directory_watcher](https://rubygems.org/gems/directory_watcher) gem
|
88
|
+
|
79
89
|
## Example
|
80
90
|
|
81
91
|
To see gollum-site in action, let's use it to generate a static site from a
|
@@ -88,3 +98,13 @@ Gollum Wiki. For this example I will use the Radiant wiki:
|
|
88
98
|
|
89
99
|
Now you can browse to http://localhost:8000 and view the Radiant wiki as a
|
90
100
|
static site.
|
101
|
+
|
102
|
+
If you'd like to see generate the radiant wiki with the Gollum layout:
|
103
|
+
|
104
|
+
$ gollum-site import # imports a simple layout
|
105
|
+
$ gollum-site generate --working # this is SLOW
|
106
|
+
$ gollum-site serve --watch
|
107
|
+
|
108
|
+
Now you can browse to http://localhost:8000 and view the Radiant wiki.
|
109
|
+
Additionally, you can make changes to the wiki files that will automatically
|
110
|
+
update in the static site.
|
data/bin/gollum-site
CHANGED
@@ -23,10 +23,11 @@ HELP
|
|
23
23
|
|
24
24
|
options = {
|
25
25
|
'ref' => ( head = Grit::Repo.new('.').head ) ? head.name : 'master', # current branch
|
26
|
+
'working' => false,
|
26
27
|
'base_path' => '/',
|
27
28
|
'output_path' => '_site',
|
28
29
|
'port' => 8000,
|
29
|
-
'
|
30
|
+
'watch' => false
|
30
31
|
}
|
31
32
|
opts = OptionParser.new do |opts|
|
32
33
|
opts.banner = help
|
@@ -35,6 +36,10 @@ opts = OptionParser.new do |opts|
|
|
35
36
|
options['ref'] = ref
|
36
37
|
end
|
37
38
|
|
39
|
+
opts.on("--working", "Use working changes during site generation") do
|
40
|
+
options['working'] = true
|
41
|
+
end
|
42
|
+
|
38
43
|
opts.on("--base_path [BASE_PATH]", "Prefix to apply to internal links") do |base_path|
|
39
44
|
options['base_path'] = base_path
|
40
45
|
end
|
@@ -47,8 +52,8 @@ opts = OptionParser.new do |opts|
|
|
47
52
|
options['port'] = port
|
48
53
|
end
|
49
54
|
|
50
|
-
opts.on("--
|
51
|
-
options['
|
55
|
+
opts.on("--watch", "Regenerate any changes to the working directory") do
|
56
|
+
options['watch'] = true
|
52
57
|
end
|
53
58
|
|
54
59
|
opts.on_tail("--help", "Show this information") do
|
@@ -69,12 +74,45 @@ cmd = ARGV[0]
|
|
69
74
|
|
70
75
|
case cmd
|
71
76
|
when 'generate'
|
72
|
-
|
73
|
-
|
77
|
+
site = Gollum::Site.new('.', {
|
78
|
+
:base_path => options['base_path'],
|
74
79
|
:output_path => options['output_path'],
|
75
|
-
:
|
76
|
-
|
80
|
+
:version => options['working'] ? :working : options['ref']
|
81
|
+
})
|
82
|
+
site.generate()
|
77
83
|
when 'serve'
|
84
|
+
if options['watch']
|
85
|
+
require 'directory_watcher'
|
86
|
+
|
87
|
+
dw = DirectoryWatcher.new('.', {
|
88
|
+
:glob => '**/*',
|
89
|
+
:pre_load => true,
|
90
|
+
:interval => 1
|
91
|
+
})
|
92
|
+
|
93
|
+
site = Gollum::Site.new('.', {
|
94
|
+
:base_path => options['base_path'],
|
95
|
+
:output_path => options['output_path'],
|
96
|
+
:version => :working
|
97
|
+
})
|
98
|
+
|
99
|
+
dw.add_observer do |*args|
|
100
|
+
args.each do |event|
|
101
|
+
# Only respond to modified/added events
|
102
|
+
if event.type == :modified or event.type == :added
|
103
|
+
# Ignore modifications to output path
|
104
|
+
unless ::File.expand_path(event.path).match(::File.expand_path(site.output_path))
|
105
|
+
item = event.path[2..-1]
|
106
|
+
puts "Updating #{item}"
|
107
|
+
site.update_working_item(item)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
dw.start
|
114
|
+
end
|
115
|
+
|
78
116
|
require 'webrick'
|
79
117
|
include WEBrick
|
80
118
|
|
data/lib/gollum-site.rb
CHANGED
@@ -2,11 +2,13 @@ require 'gollum'
|
|
2
2
|
require 'liquid'
|
3
3
|
require 'gollum-site/site'
|
4
4
|
|
5
|
-
# overwrite cname and find method
|
6
|
-
# should replace with custom Page class once issue #63 is fixed
|
7
|
-
# http://github.com/github/gollum/issues/#issue/63
|
5
|
+
# Use custom Page class to overwrite cname and find method
|
8
6
|
require 'gollum-site/page'
|
9
7
|
|
10
8
|
# Markup does not use page version :(
|
11
9
|
# Markup does not handle anchor tags for absent pages
|
10
|
+
# Use custom Markup class once Gollum supports it (>v1.1.0)
|
12
11
|
require 'gollum-site/markup'
|
12
|
+
|
13
|
+
# Absolutely awful hack
|
14
|
+
require 'gollum-site/wiki'
|
data/lib/gollum-site/markup.rb
CHANGED
data/lib/gollum-site/page.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Gollum
|
2
|
-
class Page
|
2
|
+
class SitePage < Gollum::Page
|
3
3
|
# Add ".html" extension to page links
|
4
4
|
def self.cname(name)
|
5
5
|
cname = name.respond_to?(:gsub) ?
|
@@ -14,13 +14,58 @@ module Gollum
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
# Markup uses this method for absent/present class assignment on page links
|
17
18
|
def find(cname, version)
|
18
|
-
name =
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
name = self.class.canonicalize_filename(cname)
|
20
|
+
@wiki.site.pages[name.downcase]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Return layout or nil
|
24
|
+
def layout()
|
25
|
+
name = '_Layout.html'
|
26
|
+
dirs = self.path.split('/')
|
27
|
+
dirs.pop
|
28
|
+
while !dirs.empty?
|
29
|
+
path = dirs.join('/') + '/' + name
|
30
|
+
if l = @wiki.site.layouts[path]
|
31
|
+
return l
|
32
|
+
end
|
33
|
+
dirs.pop
|
34
|
+
end
|
35
|
+
|
36
|
+
if l = @wiki.site.layouts[name]
|
37
|
+
return l
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Output static HTML of current page
|
42
|
+
def generate(output_path, version)
|
43
|
+
data = if l = layout()
|
44
|
+
l.render( 'page' => self,
|
45
|
+
'wiki' => {'base_path' => @wiki.base_path})
|
46
|
+
else
|
47
|
+
formatted_data
|
48
|
+
end
|
49
|
+
|
50
|
+
::File.open(::File.join(output_path, self.class.cname(name)), 'w') do |f|
|
51
|
+
f.write(data)
|
23
52
|
end
|
24
53
|
end
|
54
|
+
|
55
|
+
# Return data for Liquid template
|
56
|
+
def to_liquid()
|
57
|
+
{ "path" => self.class.cname(name),
|
58
|
+
"content" => formatted_data,
|
59
|
+
"title" => title,
|
60
|
+
"format" => format.to_s,
|
61
|
+
"author" => version.author.name,
|
62
|
+
"date" => version.authored_date.strftime("%Y-%m-%d %H:%M:%S")}
|
63
|
+
end
|
64
|
+
|
65
|
+
def populate(blob, path)
|
66
|
+
@blob = blob
|
67
|
+
@path = (path + '/' + blob.name)
|
68
|
+
self
|
69
|
+
end
|
25
70
|
end
|
26
71
|
end
|
data/lib/gollum-site/site.rb
CHANGED
@@ -5,92 +5,136 @@ module Gollum
|
|
5
5
|
end
|
6
6
|
|
7
7
|
attr_reader :output_path
|
8
|
+
attr_reader :layouts
|
9
|
+
attr_reader :pages
|
8
10
|
|
9
|
-
def initialize(
|
10
|
-
@wiki =
|
11
|
+
def initialize(path, options = {})
|
12
|
+
@wiki = Gollum::Wiki.new(path, {
|
13
|
+
# markup_class should work after v1.1.0 of Gollum
|
14
|
+
# need to change class name in markup.rb
|
15
|
+
#:markup_class => Gollum::SiteMarkup,
|
16
|
+
:page_class => Gollum::SitePage,
|
17
|
+
:base_path => options[:base_path]
|
18
|
+
})
|
19
|
+
@wiki.site = self
|
11
20
|
@output_path = options[:output_path] || "_site"
|
12
|
-
|
13
|
-
@include_default_layout = true
|
14
|
-
end
|
21
|
+
set_version(options[:version] || "master")
|
15
22
|
end
|
16
23
|
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
layouts = {}
|
25
|
-
items = @wiki.tree_map_for(version).inject([]) do |list, entry|
|
26
|
-
if entry.name =~ /^_Footer./
|
27
|
-
# Ignore
|
28
|
-
elsif entry.name == "_Layout.html"
|
29
|
-
layout = ::Liquid::Template.parse(entry.blob(@wiki.repo).data)
|
30
|
-
layouts[::File.dirname(entry.path)] = layout
|
31
|
-
elsif @wiki.page_class.valid_page_name?(entry.name)
|
32
|
-
sha = @wiki.ref_map[version] || version
|
33
|
-
page = entry.page(@wiki, @wiki.repo.commit(sha))
|
34
|
-
list << page
|
35
|
-
else
|
36
|
-
list << entry
|
37
|
-
end
|
38
|
-
list
|
39
|
-
end
|
24
|
+
# Prepare site for specified version
|
25
|
+
def set_version(version)
|
26
|
+
@version = version
|
27
|
+
@pages = {}
|
28
|
+
@files = {}
|
29
|
+
@layouts = {}
|
40
30
|
|
41
|
-
|
42
|
-
|
43
|
-
default_layout = ::File.join(dir, "_Layout.html")
|
44
|
-
layout = ::Liquid::Template.parse(IO.read(default_layout))
|
45
|
-
layouts["."] = layout
|
46
|
-
css = ::File.join(dir, "css")
|
47
|
-
javascript = ::File.join(dir, "javascript")
|
48
|
-
FileUtils.cp_r([css, javascript], @output_path)
|
49
|
-
end
|
31
|
+
@commit = version == :working ? @wiki.repo.commit("HEAD") : @wiki.repo.commit(version)
|
32
|
+
items = self.ls(version)
|
50
33
|
|
51
34
|
items.each do |item|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
35
|
+
filename = ::File.basename(item.path)
|
36
|
+
dirname = ::File.dirname(item.path)
|
37
|
+
if filename =~ /^_Footer./
|
38
|
+
# ignore
|
39
|
+
elsif filename =~ /^_Layout.html/
|
40
|
+
# layout
|
41
|
+
@layouts[item.path] = ::Liquid::Template.parse(item.data)
|
42
|
+
elsif @wiki.page_class.valid_page_name?(filename)
|
43
|
+
# page
|
44
|
+
page = @wiki.page_class.new(@wiki)
|
45
|
+
blob = OpenStruct.new(:name => filename, :data => item.data)
|
46
|
+
page.populate(blob, dirname)
|
47
|
+
page.version = @commit
|
48
|
+
@pages[page.name.downcase] = page
|
56
49
|
else
|
57
|
-
|
58
|
-
|
59
|
-
data = item.blob(@wiki.repo).data
|
50
|
+
# file
|
51
|
+
@files[item.path] = item.data
|
60
52
|
end
|
61
|
-
f = ::File.new(path, "w")
|
62
|
-
f.write(data)
|
63
|
-
f.close
|
64
53
|
end
|
65
54
|
end
|
66
55
|
|
67
|
-
def
|
68
|
-
if
|
69
|
-
|
56
|
+
def ls(version = 'master')
|
57
|
+
if version == :working
|
58
|
+
ls_opts = {
|
59
|
+
:others => true,
|
60
|
+
:exclude_standard => true,
|
61
|
+
:cached => true,
|
62
|
+
:z => true
|
63
|
+
}
|
64
|
+
|
65
|
+
ls_opts_del = {
|
66
|
+
:deleted => true,
|
67
|
+
:exclude_standard => true,
|
68
|
+
:z => true
|
69
|
+
}
|
70
|
+
|
71
|
+
# if output_path is in work_tree, it should be excluded
|
72
|
+
if ::File.expand_path(@output_path).match(::File.expand_path(@wiki.repo.git.work_tree))
|
73
|
+
ls_opts[:exclude] = @output_path
|
74
|
+
ls_opts_del[:exclude] = @output_path
|
75
|
+
end
|
76
|
+
|
77
|
+
cwd = Dir.pwd # need to change directories for git ls-files -o
|
78
|
+
Dir.chdir(@wiki.repo.git.work_tree)
|
79
|
+
deleted = @wiki.repo.git.native(:ls_files, ls_opts_del).split("\0")
|
80
|
+
working = @wiki.repo.git.native(:ls_files, ls_opts).split("\0")
|
81
|
+
work_tree = (working - deleted).map do |path|
|
82
|
+
path = @wiki.decode_git_path(path)
|
83
|
+
OpenStruct.new(:path => path, :data => IO.read(path))
|
84
|
+
end
|
85
|
+
Dir.chdir(cwd) # change back to original directory
|
86
|
+
return work_tree
|
70
87
|
else
|
71
|
-
|
88
|
+
return @wiki.tree_map_for(version).map do |entry|
|
89
|
+
OpenStruct.new(:path => entry.path, :data => entry.blob(@wiki.repo).data)
|
90
|
+
end
|
72
91
|
end
|
73
92
|
end
|
74
93
|
|
75
|
-
|
76
|
-
|
77
|
-
|
94
|
+
# path must be relative to top level of wiki repo
|
95
|
+
def update_working_item(path)
|
96
|
+
filename = ::File.basename(path)
|
97
|
+
dirname = ::File.dirname(path)
|
98
|
+
if filename =~ /^_Footer./
|
99
|
+
# ignore
|
100
|
+
elsif filename =~ /^_Layout.html/
|
101
|
+
# layout
|
102
|
+
elsif @wiki.page_class.valid_page_name?(filename)
|
103
|
+
# page
|
104
|
+
abspath = ::File.join(@wiki.repo.git.work_tree, path)
|
105
|
+
page = @wiki.page_class.new(@wiki)
|
106
|
+
blob = OpenStruct.new(:name => filename, :data => IO.read(abspath))
|
107
|
+
page.populate(blob, dirname)
|
108
|
+
page.version = @commit
|
109
|
+
@pages[page.name.downcase] = page
|
110
|
+
page.generate(@output_path, @version)
|
78
111
|
else
|
79
|
-
|
80
|
-
|
112
|
+
# file
|
113
|
+
data = IO.read(abspath)
|
114
|
+
@files[path] = data
|
115
|
+
path = ::File.join(@output_path, path)
|
116
|
+
::FileUtils.mkdir_p(::File.dirname(path))
|
117
|
+
::File.open(path, "w") do |f|
|
118
|
+
f.write(data)
|
119
|
+
end
|
81
120
|
end
|
82
121
|
end
|
83
122
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
123
|
+
# Public: generate the static site
|
124
|
+
def generate()
|
125
|
+
::Dir.mkdir(@output_path) unless ::File.exists? @output_path
|
126
|
+
|
127
|
+
@pages.each do |name, page|
|
128
|
+
page.generate(@output_path, @version)
|
129
|
+
end
|
91
130
|
|
92
|
-
|
93
|
-
|
131
|
+
@files.each do |path, data|
|
132
|
+
path = ::File.join(@output_path, path)
|
133
|
+
::FileUtils.mkdir_p(::File.dirname(path))
|
134
|
+
::File.open(path, "w") do |f|
|
135
|
+
f.write(data)
|
136
|
+
end
|
137
|
+
end
|
94
138
|
end
|
95
139
|
end
|
96
140
|
end
|
data/lib/gollum-site/version.rb
CHANGED
@@ -1,2 +1,3 @@
|
|
1
1
|
0000000000000000000000000000000000000000 45170c1c68e6ddd4d4c08adfb2aaf3c12d9b6329 Daniel Reverri <reverri@gmail.com> 1288900058 -0700 clone: from /Users/dreverri/src/basho/gollum-site/test/examples/test_site.git
|
2
2
|
45170c1c68e6ddd4d4c08adfb2aaf3c12d9b6329 3134a0792941bf0df537c3a10d2502fdc3be08a5 Daniel Reverri <reverri@gmail.com> 1288900147 -0700 commit: Adding Page-One
|
3
|
+
3134a0792941bf0df537c3a10d2502fdc3be08a5 24d9d55aef25343c5a1c6f2d3ac09512a37a8687 François de Metz <fdemetz@af83.com> 1288968005 +0100 push
|
@@ -1,2 +1,3 @@
|
|
1
1
|
0000000000000000000000000000000000000000 45170c1c68e6ddd4d4c08adfb2aaf3c12d9b6329 Daniel Reverri <reverri@gmail.com> 1288900058 -0700 clone: from /Users/dreverri/src/basho/gollum-site/test/examples/test_site.git
|
2
2
|
45170c1c68e6ddd4d4c08adfb2aaf3c12d9b6329 3134a0792941bf0df537c3a10d2502fdc3be08a5 Daniel Reverri <reverri@gmail.com> 1288900147 -0700 commit: Adding Page-One
|
3
|
+
3134a0792941bf0df537c3a10d2502fdc3be08a5 24d9d55aef25343c5a1c6f2d3ac09512a37a8687 François de Metz <fdemetz@af83.com> 1288968005 +0100 push
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
24d9d55aef25343c5a1c6f2d3ac09512a37a8687
|
data/test/test_site.rb
CHANGED
@@ -2,21 +2,25 @@ require File.join(File.dirname(__FILE__), *%w[helper])
|
|
2
2
|
|
3
3
|
context "Site" do
|
4
4
|
setup do
|
5
|
-
|
6
|
-
@site = Gollum::Site.new(
|
7
|
-
|
8
|
-
|
5
|
+
path = testpath("examples/test_site.git")
|
6
|
+
@site = Gollum::Site.new(path,{
|
7
|
+
:output_path => testpath("examples/site"),
|
8
|
+
:version => "master"
|
9
|
+
})
|
10
|
+
@site.generate()
|
9
11
|
end
|
10
12
|
|
11
13
|
test "generate static site" do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
diff = Dir[@site.output_path + "/**/*"].
|
15
|
+
map { |f| f.sub(@site.output_path, "") } - ["/Home.html",
|
16
|
+
"/Page-One.html",
|
17
|
+
"/Page1.html",
|
18
|
+
"/Page2.html",
|
19
|
+
"/page.html",
|
20
|
+
"/static",
|
21
|
+
"/static/static.jpg",
|
22
|
+
"/static/static.txt"]
|
23
|
+
assert_equal([], diff)
|
20
24
|
end
|
21
25
|
|
22
26
|
test "render page with layout and link" do
|
@@ -37,44 +41,55 @@ context "Site" do
|
|
37
41
|
assert_equal(["<html><body><p>Site test</p></body></html>\n"], File.open(page_path).readlines)
|
38
42
|
end
|
39
43
|
|
44
|
+
test "page.path is available on template" do
|
45
|
+
page_path = File.join(@site.output_path, "page.html")
|
46
|
+
assert_equal(["<ul><li>page.html</li></ul>\n"], File.open(page_path).readlines)
|
47
|
+
end
|
48
|
+
|
40
49
|
teardown do
|
41
50
|
FileUtils.rm_r(@site.output_path)
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
45
|
-
context "
|
54
|
+
context "Preview" do
|
46
55
|
setup do
|
47
|
-
@
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
+
@path = testpath("examples/uncommitted_untracked_changes")
|
57
|
+
# Add untracked file
|
58
|
+
File.open(@path + '/Foo.md', 'w') { |f| f.write("Bar") }
|
59
|
+
# Modify tracked file
|
60
|
+
File.open(@path + '/Home.md', 'w') { |f| f.write("Hello World\nHello World") }
|
61
|
+
@site = Gollum::Site.new(@path, {
|
62
|
+
:output_path => testpath("examples/site"),
|
63
|
+
:version => :working
|
64
|
+
})
|
65
|
+
@site.generate()
|
56
66
|
end
|
57
67
|
|
58
|
-
|
59
|
-
|
68
|
+
test "working site has Home.html and Foo.html" do
|
69
|
+
diff = Dir[@site.output_path + "/**/*"].
|
70
|
+
map { |f| f.sub(@site.output_path, "") } - ["/Home.html",
|
71
|
+
"/Foo.html",
|
72
|
+
"/Bar.html"]
|
73
|
+
assert_equal([], diff)
|
60
74
|
end
|
61
|
-
end
|
62
75
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
@site = Gollum::Site.new(@wiki,
|
67
|
-
{:output_path => testpath("examples/site"),
|
68
|
-
:include_default_layout => false})
|
69
|
-
@site.generate("master")
|
76
|
+
test "working site Home.html content is uncommitted version" do
|
77
|
+
data = IO.read(::File.join(@site.output_path, "Home.html"))
|
78
|
+
assert_equal("<p>Hello World\nHello World</p>", data)
|
70
79
|
end
|
71
80
|
|
72
|
-
test "
|
73
|
-
|
74
|
-
|
81
|
+
test "one item can be updated" do
|
82
|
+
File.open(@path + '/Foo.md', 'w') { |f| f.write("Baz") }
|
83
|
+
@site.update_working_item('Foo.md')
|
84
|
+
data = IO.read(::File.join(@site.output_path, "Foo.html"))
|
85
|
+
assert_equal("<p>Baz</p>", data)
|
75
86
|
end
|
76
87
|
|
77
88
|
teardown do
|
89
|
+
# Remove untracked file
|
90
|
+
FileUtils.rm(@path + '/Foo.md')
|
91
|
+
# Reset tracked file
|
92
|
+
File.open(@path + '/Home.md', 'w') { |f| f.write("Hello World\n") }
|
78
93
|
FileUtils.rm_r(@site.output_path)
|
79
94
|
end
|
80
95
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gollum-site
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.6
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Reverri
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-01 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -455,6 +455,7 @@ files:
|
|
455
455
|
- lib/gollum-site/page.rb
|
456
456
|
- lib/gollum-site/site.rb
|
457
457
|
- lib/gollum-site/version.rb
|
458
|
+
- lib/gollum-site/wiki.rb
|
458
459
|
- test/examples/test_site.git/COMMIT_EDITMSG
|
459
460
|
- test/examples/test_site.git/HEAD
|
460
461
|
- test/examples/test_site.git/config
|
@@ -476,11 +477,14 @@ files:
|
|
476
477
|
- test/examples/test_site.git/objects/0c/e23474afb8381a2df45077c7897e72ea66bd82
|
477
478
|
- test/examples/test_site.git/objects/12/d183189412aea09391023586297528722daa1b
|
478
479
|
- test/examples/test_site.git/objects/24/6104cdec11f15d582a78ffefc1be08b1566561
|
480
|
+
- test/examples/test_site.git/objects/24/d9d55aef25343c5a1c6f2d3ac09512a37a8687
|
479
481
|
- test/examples/test_site.git/objects/31/34a0792941bf0df537c3a10d2502fdc3be08a5
|
480
482
|
- test/examples/test_site.git/objects/33/c6cf51b72a58596114e5d2f03261b8deaaa0f0
|
483
|
+
- test/examples/test_site.git/objects/43/a97c5259b27129a0fadff58ba8aa8ebbb62523
|
481
484
|
- test/examples/test_site.git/objects/45/170c1c68e6ddd4d4c08adfb2aaf3c12d9b6329
|
482
485
|
- test/examples/test_site.git/objects/4d/1311a57ece3dc2840c6e48d1b9bf5978e3dc91
|
483
486
|
- test/examples/test_site.git/objects/4d/905a41381ad39d616dee245cf3e324f9fcc02e
|
487
|
+
- test/examples/test_site.git/objects/6b/a5b4d83ba18c2bd85fade0c03816e5b2bfa9f4
|
484
488
|
- test/examples/test_site.git/objects/6c/bc9f20aa7806196638e32f708e012568d4a959
|
485
489
|
- test/examples/test_site.git/objects/71/bb02bb7d563e86a558a0040d77f3cfc82dc4fd
|
486
490
|
- test/examples/test_site.git/objects/7d/f37a9caf358dbb0244742503a456aeac1eaf82
|
@@ -489,6 +493,7 @@ files:
|
|
489
493
|
- test/examples/test_site.git/objects/9b/3d7fbc0ed4fc1db28f361729e4396208e6f846
|
490
494
|
- test/examples/test_site.git/objects/a5/2b08f141c77fa0cd2397fb26f3285ea17bd6ea
|
491
495
|
- test/examples/test_site.git/objects/b1/99a056e7e0dfadc1350413de32d6c9a700e7fa
|
496
|
+
- test/examples/test_site.git/objects/c2/1da0b71136462ceda60b7c4fab79311338eafa
|
492
497
|
- test/examples/test_site.git/objects/c3/d487fda322940d75eac154fc8383093f7bcdf3
|
493
498
|
- test/examples/test_site.git/objects/c4/9a9d6386a9d955b3fac30f863c6b617d5830bc
|
494
499
|
- test/examples/test_site.git/objects/cd/68dbcff0518c406e8caee2fa163006a90626b7
|
@@ -500,6 +505,7 @@ files:
|
|
500
505
|
- test/examples/test_site.git/objects/e7/0688deaa9cae7f981200111abc974a334a4426
|
501
506
|
- test/examples/test_site.git/objects/ea/8b884d4ac9807c17383bace8393379d15f8c2f
|
502
507
|
- test/examples/test_site.git/objects/fe/8086cbd51dd30365c9cbaedf015036445fabe4
|
508
|
+
- test/examples/test_site.git/objects/ff/b5bbc20089dd64632b4aa7b2be312cfaddae35
|
503
509
|
- test/examples/test_site.git/packed-refs
|
504
510
|
- test/examples/test_site.git/refs/heads/master
|
505
511
|
- test/examples/test_site.git/refs/remotes/origin/HEAD
|
@@ -586,11 +592,14 @@ test_files:
|
|
586
592
|
- test/examples/test_site.git/objects/0c/e23474afb8381a2df45077c7897e72ea66bd82
|
587
593
|
- test/examples/test_site.git/objects/12/d183189412aea09391023586297528722daa1b
|
588
594
|
- test/examples/test_site.git/objects/24/6104cdec11f15d582a78ffefc1be08b1566561
|
595
|
+
- test/examples/test_site.git/objects/24/d9d55aef25343c5a1c6f2d3ac09512a37a8687
|
589
596
|
- test/examples/test_site.git/objects/31/34a0792941bf0df537c3a10d2502fdc3be08a5
|
590
597
|
- test/examples/test_site.git/objects/33/c6cf51b72a58596114e5d2f03261b8deaaa0f0
|
598
|
+
- test/examples/test_site.git/objects/43/a97c5259b27129a0fadff58ba8aa8ebbb62523
|
591
599
|
- test/examples/test_site.git/objects/45/170c1c68e6ddd4d4c08adfb2aaf3c12d9b6329
|
592
600
|
- test/examples/test_site.git/objects/4d/1311a57ece3dc2840c6e48d1b9bf5978e3dc91
|
593
601
|
- test/examples/test_site.git/objects/4d/905a41381ad39d616dee245cf3e324f9fcc02e
|
602
|
+
- test/examples/test_site.git/objects/6b/a5b4d83ba18c2bd85fade0c03816e5b2bfa9f4
|
594
603
|
- test/examples/test_site.git/objects/6c/bc9f20aa7806196638e32f708e012568d4a959
|
595
604
|
- test/examples/test_site.git/objects/71/bb02bb7d563e86a558a0040d77f3cfc82dc4fd
|
596
605
|
- test/examples/test_site.git/objects/7d/f37a9caf358dbb0244742503a456aeac1eaf82
|
@@ -599,6 +608,7 @@ test_files:
|
|
599
608
|
- test/examples/test_site.git/objects/9b/3d7fbc0ed4fc1db28f361729e4396208e6f846
|
600
609
|
- test/examples/test_site.git/objects/a5/2b08f141c77fa0cd2397fb26f3285ea17bd6ea
|
601
610
|
- test/examples/test_site.git/objects/b1/99a056e7e0dfadc1350413de32d6c9a700e7fa
|
611
|
+
- test/examples/test_site.git/objects/c2/1da0b71136462ceda60b7c4fab79311338eafa
|
602
612
|
- test/examples/test_site.git/objects/c3/d487fda322940d75eac154fc8383093f7bcdf3
|
603
613
|
- test/examples/test_site.git/objects/c4/9a9d6386a9d955b3fac30f863c6b617d5830bc
|
604
614
|
- test/examples/test_site.git/objects/cd/68dbcff0518c406e8caee2fa163006a90626b7
|
@@ -610,6 +620,7 @@ test_files:
|
|
610
620
|
- test/examples/test_site.git/objects/e7/0688deaa9cae7f981200111abc974a334a4426
|
611
621
|
- test/examples/test_site.git/objects/ea/8b884d4ac9807c17383bace8393379d15f8c2f
|
612
622
|
- test/examples/test_site.git/objects/fe/8086cbd51dd30365c9cbaedf015036445fabe4
|
623
|
+
- test/examples/test_site.git/objects/ff/b5bbc20089dd64632b4aa7b2be312cfaddae35
|
613
624
|
- test/examples/test_site.git/packed-refs
|
614
625
|
- test/examples/test_site.git/refs/heads/master
|
615
626
|
- test/examples/test_site.git/refs/remotes/origin/HEAD
|