gettalong-webgen 0.5.7.20090227 → 0.5.8.20090507
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +37 -36
- data/data/webgen/resources.yaml +2 -2
- data/data/webgen/webgui/app.rb +11 -0
- data/data/webgen/webgui/controller/main.rb +30 -26
- data/data/webgen/webgui/{view/page.xhtml → layout/default.xhtml} +8 -8
- data/data/webgen/webgui/start.rb +9 -0
- data/data/webgen/webgui/view/create_website.xhtml +6 -14
- data/data/webgen/webgui/view/manage_website.xhtml +2 -2
- data/data/webgen/website_bundles/default/README +6 -0
- data/data/webgen/website_bundles/default/src/index.page +15 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/1024px/src/images/background.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/bg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/front.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas00/src/images/menubg2.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/bg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/images/front.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas01/src/print.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/bodybg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/contbg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/footerbg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient1.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas03/src/images/gradient2.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/blinkarrow.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/bodybg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/contentbg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/entrybg.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/flash2.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globe.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/globebottom.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/linkarrow.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas04/src/images/menuhover.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/bodybg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas05/src/images/front.png +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.css +6 -4
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/default.template +2 -2
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/bodybg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/boxbg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/greypx.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/header.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/innerbg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/leaves.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas06/src/images/tabs.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/browserfix.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/bodybg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas07/src/images/sidebarbg.gif +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas08/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas08/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/default.template +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-black.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-green.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-orange.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-purple.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg-red.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/bodybg.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/footerbg.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-black.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-green.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-orange.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-purple.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover-red.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/andreas09/src/images/menuhover.jpg +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/simple/README +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.css +0 -0
- data/data/webgen/{website_styles → website_bundles/style}/simple/src/default.template +0 -0
- data/data/webgen/website_skeleton/README +1 -1
- data/data/webgen/website_skeleton/config.yaml +5 -4
- data/doc/contentprocessor/blocks.page +43 -10
- data/doc/contentprocessor/builder.page +1 -1
- data/doc/contentprocessor/erb.page +12 -11
- data/doc/contentprocessor/redcloth.page +3 -1
- data/doc/extensions.page +3 -3
- data/doc/faq.page +13 -10
- data/doc/getting_started.page +12 -15
- data/doc/index.page +7 -1
- data/doc/manual.page +78 -27
- data/doc/reference_configuration.page +166 -3
- data/doc/reference_website_styles.page +28 -0
- data/doc/source/filesystem.page +39 -0
- data/doc/source/tararchive.page +40 -0
- data/doc/tag/tikz.page +2 -1
- data/doc/webgen_page_format.page +13 -12
- data/doc/website_styles.metainfo +8 -0
- data/lib/webgen/blackboard.rb +2 -2
- data/lib/webgen/cache.rb +4 -4
- data/lib/webgen/cli.rb +29 -16
- data/lib/webgen/cli/apply_command.rb +66 -0
- data/lib/webgen/cli/create_command.rb +22 -16
- data/lib/webgen/cli/utils.rb +23 -0
- data/lib/webgen/cli/webgui_command.rb +31 -16
- data/lib/webgen/configuration.rb +8 -6
- data/lib/webgen/contentprocessor.rb +4 -5
- data/lib/webgen/contentprocessor/blocks.rb +2 -0
- data/lib/webgen/contentprocessor/builder.rb +6 -3
- data/lib/webgen/contentprocessor/erb.rb +6 -3
- data/lib/webgen/contentprocessor/erubis.rb +7 -6
- data/lib/webgen/contentprocessor/haml.rb +6 -3
- data/lib/webgen/contentprocessor/rdoc.rb +0 -1
- data/lib/webgen/contentprocessor/redcloth.rb +3 -1
- data/lib/webgen/context.rb +73 -0
- data/lib/webgen/context/nodes.rb +36 -0
- data/lib/webgen/coreext.rb +3 -2
- data/lib/webgen/default_config.rb +3 -1
- data/lib/webgen/deprecated.rb +53 -0
- data/lib/webgen/node.rb +24 -19
- data/lib/webgen/output.rb +50 -7
- data/lib/webgen/page.rb +45 -36
- data/lib/webgen/path.rb +1 -1
- data/lib/webgen/source.rb +32 -4
- data/lib/webgen/source/resource.rb +3 -3
- data/lib/webgen/source/stacked.rb +1 -1
- data/lib/webgen/source/tararchive.rb +73 -0
- data/lib/webgen/sourcehandler.rb +4 -4
- data/lib/webgen/sourcehandler/base.rb +36 -24
- data/lib/webgen/sourcehandler/copy.rb +1 -1
- data/lib/webgen/sourcehandler/feed.rb +2 -2
- data/lib/webgen/sourcehandler/fragment.rb +1 -1
- data/lib/webgen/sourcehandler/metainfo.rb +15 -6
- data/lib/webgen/sourcehandler/page.rb +9 -5
- data/lib/webgen/sourcehandler/virtual.rb +44 -7
- data/lib/webgen/tag/base.rb +19 -13
- data/lib/webgen/tag/link.rb +1 -0
- data/lib/webgen/version.rb +1 -1
- data/lib/webgen/webgentask.rb +15 -13
- data/lib/webgen/website.rb +42 -11
- data/lib/webgen/websiteaccess.rb +1 -1
- data/lib/webgen/websitemanager.rb +61 -66
- data/man/man1/webgen.1 +4 -0
- data/misc/default.css +13 -0
- data/misc/default.template +1 -1
- data/misc/htmldoc.metainfo +2 -1
- data/misc/style.page +33 -0
- data/test/test_cli.rb +1 -7
- data/test/test_common_sitemap.rb +2 -2
- data/test/test_contentprocessor_blocks.rb +14 -1
- data/test/test_contentprocessor_builder.rb +3 -1
- data/test/test_contentprocessor_erb.rb +3 -2
- data/test/test_contentprocessor_erubis.rb +3 -3
- data/test/test_contentprocessor_fragments.rb +3 -3
- data/test/test_contentprocessor_haml.rb +3 -2
- data/test/test_contentprocessor_maruku.rb +3 -3
- data/test/test_contentprocessor_rdiscount.rb +1 -1
- data/test/test_contentprocessor_rdoc.rb +1 -1
- data/test/test_contentprocessor_redcloth.rb +9 -2
- data/test/test_contentprocessor_sass.rb +1 -1
- data/test/test_contentprocessor_tags.rb +1 -1
- data/test/{test_contentprocessor_context.rb → test_context.rb} +9 -7
- data/test/test_node.rb +27 -21
- data/test/test_page.rb +4 -4
- data/test/test_source_tararchive.rb +65 -0
- data/test/test_sourcehandler_fragment.rb +1 -1
- data/test/test_sourcehandler_memory.rb +6 -6
- data/test/test_sourcehandler_metainfo.rb +34 -13
- data/test/test_sourcehandler_page.rb +8 -0
- data/test/test_sourcehandler_virtual.rb +51 -12
- data/test/test_tag_breadcrumbtrail.rb +4 -4
- data/test/test_tag_coderay.rb +1 -1
- data/test/test_tag_date.rb +1 -1
- data/test/test_tag_executecommand.rb +1 -1
- data/test/test_tag_includefile.rb +3 -3
- data/test/test_tag_langbar.rb +6 -6
- data/test/test_tag_link.rb +8 -2
- data/test/test_tag_menu.rb +9 -9
- data/test/test_tag_metainfo.rb +1 -1
- data/test/test_tag_relocatable.rb +1 -1
- data/test/test_tag_sitemap.rb +1 -1
- data/test/test_tag_tikz.rb +2 -2
- data/test/test_website.rb +17 -0
- data/test/test_websitemanager.rb +16 -21
- metadata +181 -171
- data/data/webgen/website_templates/default/README +0 -6
- data/data/webgen/website_templates/default/src/index.page +0 -8
- data/data/webgen/website_templates/project/README +0 -5
- data/data/webgen/website_templates/project/src/about.page +0 -12
- data/data/webgen/website_templates/project/src/download.page +0 -15
- data/data/webgen/website_templates/project/src/features.page +0 -8
- data/data/webgen/website_templates/project/src/index.page +0 -9
- data/data/webgen/website_templates/project/src/screenshots.page +0 -18
- data/lib/webgen/contentprocessor/context.rb +0 -89
data/lib/webgen/webgentask.rb
CHANGED
@@ -41,30 +41,33 @@ module Webgen
|
|
41
41
|
# It is assumed that you have already used the 'webgen' command to create the website directory
|
42
42
|
# for the site.
|
43
43
|
#
|
44
|
-
#
|
44
|
+
# == Basics
|
45
45
|
#
|
46
46
|
# require 'webgen/webgentask'
|
47
47
|
#
|
48
48
|
# Webgen::WebgenTask.new
|
49
49
|
#
|
50
|
-
#
|
50
|
+
# == Attributes
|
51
51
|
#
|
52
52
|
# The attributes available in the new block are:
|
53
53
|
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
54
|
+
# [directory]
|
55
|
+
# the root directory of the webgen site (default <tt>Dir.pwd</tt>)
|
56
|
+
# [config]
|
57
|
+
# the config block for setting additional configuration options
|
58
|
+
# [clobber_outdir]
|
59
|
+
# remove webgens output directory on clobber (default +false+)
|
59
60
|
#
|
60
|
-
#
|
61
|
+
# == Tasks Provided
|
61
62
|
#
|
62
63
|
# The tasks provided are :
|
63
64
|
#
|
64
|
-
#
|
65
|
-
#
|
65
|
+
# [webgen]
|
66
|
+
# render the webgen website
|
67
|
+
# [clobber_webgen]
|
68
|
+
# remove all the files created during generation
|
66
69
|
#
|
67
|
-
#
|
70
|
+
# == Integrate webgen in other project
|
68
71
|
#
|
69
72
|
# To integrate webgen tasks in another project you can use rake namespaces. For example assuming
|
70
73
|
# webgen's site directory is +webgen+ under the main project directory use the following code
|
@@ -96,8 +99,7 @@ module Webgen
|
|
96
99
|
# The directory of the webgen website. This would be the directory of your <tt>config.yaml</tt>
|
97
100
|
# file. Or the parent directory of the <tt>src/</tt> directory for webgen.
|
98
101
|
#
|
99
|
-
# The default for this is assumed to be
|
100
|
-
# Dir.pwd
|
102
|
+
# The default for this is assumed to be <tt>Dir.pwd</tt>
|
101
103
|
attr_accessor :directory
|
102
104
|
|
103
105
|
# The configuration block that is invoked when the Webgen::Website object is initialized. This
|
data/lib/webgen/website.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
+
##
|
4
|
+
# Welcome to the API documentation of wegen!
|
5
|
+
#
|
6
|
+
# Have a look at the base <a href=Webgen.html>webgen module</a> which provides a good starting point!
|
7
|
+
|
8
|
+
|
3
9
|
# Standard lib requires
|
4
10
|
require 'logger'
|
5
11
|
require 'set'
|
@@ -18,16 +24,21 @@ require 'webgen/tree'
|
|
18
24
|
|
19
25
|
# Files for autoloading
|
20
26
|
require 'webgen/common'
|
27
|
+
require 'webgen/context'
|
21
28
|
require 'webgen/source'
|
22
29
|
require 'webgen/output'
|
23
30
|
require 'webgen/sourcehandler'
|
24
31
|
require 'webgen/contentprocessor'
|
32
|
+
require 'webgen/tag'
|
25
33
|
|
26
34
|
# Load other needed files
|
27
35
|
require 'webgen/path'
|
28
36
|
require 'webgen/node'
|
29
37
|
require 'webgen/page'
|
30
38
|
|
39
|
+
# Load deprecated classes/methods/...
|
40
|
+
require 'webgen/deprecated'
|
41
|
+
|
31
42
|
|
32
43
|
# The Webgen namespace houses all classes/modules used by webgen.
|
33
44
|
#
|
@@ -37,7 +48,7 @@ require 'webgen/page'
|
|
37
48
|
# files. Despite this fact, the implementation also provides adequate support for using webgen as a
|
38
49
|
# library and *full* *support* for extending it.
|
39
50
|
#
|
40
|
-
#
|
51
|
+
# == Extending webgen
|
41
52
|
#
|
42
53
|
# webgen can be extended very easily. Any file called <tt>init.rb</tt> put into the <tt>ext/</tt>
|
43
54
|
# directory of the website or into one of its sub-directories is automatically loaded on
|
@@ -72,7 +83,7 @@ require 'webgen/page'
|
|
72
83
|
# an easy way for users to include dynamic content such as automatically
|
73
84
|
# generated menus.
|
74
85
|
#
|
75
|
-
#
|
86
|
+
# == Blackboard services
|
76
87
|
#
|
77
88
|
# The Blackboard class provides an easy communication facility between objects. It implements the
|
78
89
|
# Observer pattern on the one side and allows the definition of services on the other side. One
|
@@ -93,7 +104,7 @@ require 'webgen/page'
|
|
93
104
|
# <tt>:create_sitemap</tt>:: Common::Sitemap#create_sitemap
|
94
105
|
# <tt>:create_directories</tt>:: SourceHandler::Directory#create_directories
|
95
106
|
# <tt>:create_nodes</tt>:: SourceHandler::Main#create_nodes
|
96
|
-
# <tt>:source_paths</tt>:: SourceHandler::Main#
|
107
|
+
# <tt>:source_paths</tt>:: SourceHandler::Main#find_all_source_paths
|
97
108
|
#
|
98
109
|
# Following is the list of all messages that can be listened to:
|
99
110
|
#
|
@@ -119,7 +130,7 @@ require 'webgen/page'
|
|
119
130
|
# <tt>:before_node_deleted</tt>::
|
120
131
|
# See Tree#delete_node
|
121
132
|
#
|
122
|
-
#
|
133
|
+
# == Other places to look at
|
123
134
|
#
|
124
135
|
# Here is a list of modules/classes that are primarily used throughout webgen or provide useful
|
125
136
|
# methods for developing extensions:
|
@@ -141,6 +152,25 @@ module Webgen
|
|
141
152
|
|
142
153
|
|
143
154
|
# Represents a webgen website and is used to render it.
|
155
|
+
#
|
156
|
+
# Normally, webgen is used from the command line via the +webgen+ command or from Rakefiles via
|
157
|
+
# Webgen::WebgenTask. However, you can also easily use webgen as a library and this class provides
|
158
|
+
# the interface for this usage!
|
159
|
+
#
|
160
|
+
# Since a webgen website is, basically, just a directory, the only parameter needed for creating a
|
161
|
+
# new Website object is the website directory. After that you can work with the website:
|
162
|
+
#
|
163
|
+
# * If you want to render the website, you just need to call Website#render which initializes the
|
164
|
+
# website and does all the rendering. When the method call returns, everything has been rendered.
|
165
|
+
#
|
166
|
+
# * If you want to remove the generated output, you just need to invoke Website#clean and it will
|
167
|
+
# be done.
|
168
|
+
#
|
169
|
+
# * Finally, if you want to retrieve data from the website, you first have to call Website#init to
|
170
|
+
# initialize the website. After that you can use the various accessors to retrieve the needed
|
171
|
+
# data. *Note*: This is generally only useful if the website has been rendered because otherwise
|
172
|
+
# there is no data to retrieve.
|
173
|
+
#
|
144
174
|
class Website
|
145
175
|
|
146
176
|
# Raised when the configuration file of the website is invalid.
|
@@ -169,16 +199,17 @@ module Webgen
|
|
169
199
|
# The website directory.
|
170
200
|
attr_reader :directory
|
171
201
|
|
172
|
-
# Create a new webgen website for the website in the directory +dir+.
|
173
|
-
#
|
174
|
-
#
|
175
|
-
|
202
|
+
# Create a new webgen website for the website in the directory +dir+. If +dir+ is +nil+, the
|
203
|
+
# environment variable +WEBGEN_WEBSITE+ or, if it is not set either, the current working
|
204
|
+
# directory is used. You can provide a block (has to take the configuration object as parameter)
|
205
|
+
# for adjusting the configuration values during the initialization.
|
206
|
+
def initialize(dir = nil, logger=Webgen::Logger.new($stdout, false), &block)
|
176
207
|
@blackboard = nil
|
177
208
|
@cache = nil
|
178
209
|
@config = nil
|
179
210
|
@logger = logger
|
180
211
|
@config_block = block
|
181
|
-
@directory = dir
|
212
|
+
@directory = (dir.nil? ? (ENV['WEBGEN_WEBSITE'].to_s.empty? ? Dir.pwd : ENV['WEBGEN_WEBSITE']) : dir)
|
182
213
|
end
|
183
214
|
|
184
215
|
# Define a service +service_name+ provided by the instance of +klass+. The parameter +method+
|
@@ -254,11 +285,11 @@ module Webgen
|
|
254
285
|
# The provided block is executed within a proper environment sothat any object can access the
|
255
286
|
# Website object.
|
256
287
|
def execute_in_env
|
257
|
-
set_back = Thread.current[:webgen_website]
|
288
|
+
set_back = Thread.current[:webgen_website]
|
258
289
|
Thread.current[:webgen_website] = self
|
259
290
|
yield
|
260
291
|
ensure
|
261
|
-
Thread.current[:webgen_website] =
|
292
|
+
Thread.current[:webgen_website] = set_back
|
262
293
|
end
|
263
294
|
|
264
295
|
#######
|
data/lib/webgen/websiteaccess.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Webgen
|
4
4
|
|
5
|
-
#
|
5
|
+
# Should be mixed into modules/classes that need access to the current website object.
|
6
6
|
module WebsiteAccess
|
7
7
|
|
8
8
|
# The methods of this module are available on classes that include WebsiteAccess.
|
@@ -6,107 +6,102 @@ require 'webgen/website'
|
|
6
6
|
|
7
7
|
module Webgen
|
8
8
|
|
9
|
-
# This class is used for managing webgen websites. It provides access to website
|
10
|
-
#
|
9
|
+
# This class is used for managing webgen websites. It provides access to website bundles defined
|
10
|
+
# as resources and makes it easy to apply them to a webgen website.
|
11
11
|
#
|
12
|
-
#
|
12
|
+
# == General information
|
13
13
|
#
|
14
14
|
# Currently, the following actions are supported:
|
15
15
|
#
|
16
|
-
# * creating a website based on a website
|
17
|
-
# * applying a
|
18
|
-
# * applying a style to an existing website (#apply_style)
|
16
|
+
# * creating a website based on a website bundle (#create_website)
|
17
|
+
# * applying a bundle to an existing website (#apply_bundle)
|
19
18
|
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
19
|
+
# Bundles are partial webgen websites that contain certain functionality. For example, most of the
|
20
|
+
# bundles shipped with webgen are style bundles that define the basic page layout or how image
|
21
|
+
# galleries should look like. So style bundles are basically used to change the appearance of
|
22
|
+
# parts (or the whole) website. This makes them a powerful tool as this plugin makes it easy to
|
23
|
+
# change to another style bundle later!
|
23
24
|
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# change the appearance of parts (or the whole) website. This makes them a powerful tool as this
|
27
|
-
# plugin makes it easy to change a style later!
|
25
|
+
# However, not all bundles have to be style bundles. For example, you could as easily create a
|
26
|
+
# bundle for a plugin or for a complete website (e.g. a blog template).
|
28
27
|
#
|
29
|
-
#
|
28
|
+
# == website bundle resource naming convention
|
30
29
|
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
# directory are copied to the root of the destination webgen website when
|
35
|
-
#
|
30
|
+
# The shipped bundles are defined using resources. Each such resource has to be a directory
|
31
|
+
# containing an optional README file in YAML format in which key-value pairs provide additional
|
32
|
+
# information about the bundle (e.g. copyright information, description, ...). All other
|
33
|
+
# files/directories in the directory are copied to the root of the destination webgen website when
|
34
|
+
# the bundle is used.
|
36
35
|
#
|
37
|
-
# This class uses a special naming convention to recognize website
|
36
|
+
# This class uses a special naming convention to recognize website bundles:
|
38
37
|
#
|
39
|
-
# * A resource named <tt>webgen-website-
|
40
|
-
#
|
38
|
+
# * A resource named <tt>webgen-website-bundle-CATEGORY-NAME</tt> is considered to be a bundle in
|
39
|
+
# the category CATEGORY called NAME (where CATEGORY is optional). There are no fixed categories,
|
40
|
+
# one can use anything here! The shipped style bundles are located in the 'style' category. You
|
41
|
+
# need to use the the full name, i.e. CATEGORY-NAME, for accessing a bundle later.
|
41
42
|
#
|
42
|
-
#
|
43
|
-
# in the category CATEGORY called STYLE_NAME. There are no fixed categories, one can use
|
44
|
-
# anything here! Again, the style can later be accessed by providing the category and style
|
45
|
-
# name.
|
46
|
-
#
|
47
|
-
# Website template names have to be unique and style names have to be unique in respect to their
|
48
|
-
# categories!
|
49
|
-
#
|
50
|
-
# Note: All styles without a category or which are in the category 'website' are website styles.
|
43
|
+
# Website bundle names have to be unique!
|
51
44
|
class WebsiteManager
|
52
45
|
|
53
|
-
# A hash with the available website
|
54
|
-
attr_reader :
|
55
|
-
|
56
|
-
# A hash with the available website styles (mapping name to infos).
|
57
|
-
attr_reader :styles
|
46
|
+
# A hash with the available website bundles (mapping name to infos).
|
47
|
+
attr_reader :bundles
|
58
48
|
|
59
49
|
# The used Website object.
|
60
50
|
attr_reader :website
|
61
51
|
|
62
|
-
# Create a new WebsiteManager
|
52
|
+
# Create a new WebsiteManager.
|
53
|
+
#
|
54
|
+
# If +dir+ is a String, then the website manager is created for the website in the directory
|
55
|
+
# +dir+.
|
56
|
+
#
|
57
|
+
# If +dir+ is a Website object, the website manager is created for the website represented by
|
58
|
+
# +dir+. If the website object is initialized if it isn't already.
|
63
59
|
def initialize(dir)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
if dir.kind_of?(Webgen::Website)
|
61
|
+
@website = dir
|
62
|
+
@website.init if @website.config.nil?
|
63
|
+
else
|
64
|
+
@website = Webgen::Website.new(dir)
|
65
|
+
@website.init
|
66
|
+
end
|
67
|
+
@bundles = {}
|
68
68
|
|
69
69
|
@website.execute_in_env do
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
readme = paths.select {|path| path == '/README' }.first
|
74
|
-
paths.delete(readme) if readme
|
75
|
-
infos = OpenStruct.new(readme.nil? ? {} : YAML::load(readme.io.data))
|
76
|
-
infos.paths = paths
|
77
|
-
var[name.sub(prefix, '')] = infos
|
78
|
-
end
|
70
|
+
prefix = "webgen-website-bundle-"
|
71
|
+
@website.config['resources'].select {|name, data| name =~ /^#{prefix}/}.each do |name, data|
|
72
|
+
add_source(Webgen::Source::Resource.new(name), name.sub(prefix, ''))
|
79
73
|
end
|
80
74
|
end
|
81
75
|
end
|
82
76
|
|
83
|
-
#
|
77
|
+
# Treat the +source+ as a website bundle and make it available to the WebsiteManager under
|
78
|
+
# +name+.
|
79
|
+
def add_source(source, name)
|
80
|
+
paths = source.paths.dup
|
81
|
+
readme = paths.select {|path| path == '/README' }.first
|
82
|
+
paths.delete(readme) if readme
|
83
|
+
infos = OpenStruct.new(readme.nil? ? {} : YAML::load(readme.io.data))
|
84
|
+
infos.paths = paths
|
85
|
+
@bundles[name] = infos
|
86
|
+
end
|
87
|
+
|
88
|
+
# Create the basic website skeleton (without any bundle applied).
|
84
89
|
def create_website
|
85
90
|
raise "Directory <#{@website.directory}> does already exist!" if File.exists?(@website.directory)
|
86
91
|
@website.execute_in_env { write_paths(Webgen::Source::Resource.new('webgen-website-skeleton').paths) }
|
87
92
|
end
|
88
93
|
|
89
|
-
# Apply the given +
|
90
|
-
def
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
# Apply the given website style +name+ to the website by copying the styles files.
|
95
|
-
def apply_style(name)
|
96
|
-
write_paths_to_website(@styles[name], 'style')
|
94
|
+
# Apply the given +bundle+ to the website by copying the files.
|
95
|
+
def apply_bundle(bundle)
|
96
|
+
raise ArgumentError.new("Invalid bundle name") if !@bundles.has_key?(bundle)
|
97
|
+
raise "Directory <#{@website.directory}> does not exist!" unless File.exists?(@website.directory)
|
98
|
+
write_paths(@bundles[bundle].paths)
|
97
99
|
end
|
98
100
|
|
99
101
|
#######
|
100
102
|
private
|
101
103
|
#######
|
102
104
|
|
103
|
-
# Do some sanity checks and write the +paths+ from +infos+ to the website directory.
|
104
|
-
def write_paths_to_website(infos, infos_type)
|
105
|
-
raise ArgumentError.new("Invalid #{infos_type} name") if infos.nil?
|
106
|
-
raise "Directory <#{@website.directory}> does not exist!" unless File.exists?(@website.directory)
|
107
|
-
write_paths(infos.paths)
|
108
|
-
end
|
109
|
-
|
110
105
|
# Write the paths to the website directory.
|
111
106
|
def write_paths(paths)
|
112
107
|
paths.each do |path|
|
data/man/man1/webgen.1
CHANGED
@@ -36,6 +36,10 @@ Show generic help.
|
|
36
36
|
Show the version of the program and exit.
|
37
37
|
.SH COMMANDS
|
38
38
|
.TP
|
39
|
+
\fBapply\fR
|
40
|
+
Applies a website bundle to an existing website. The \fIbundle\fR argument may either be the name of
|
41
|
+
a bundle shipped with webgen or an URL to a (gzipped) tar archive bundle.
|
42
|
+
.TP
|
39
43
|
\fBcreate\fR
|
40
44
|
Creates the basic directories and files for webgen. This includes the source and
|
41
45
|
output directories as well as an empty extensions directory. Also, a basic template plus a CSS and
|
data/misc/default.css
CHANGED
@@ -382,3 +382,16 @@ blockquote.blog-entry-details {
|
|
382
382
|
.blog-entry-date, .blog-entry-author {
|
383
383
|
font-weight: bold;
|
384
384
|
}
|
385
|
+
|
386
|
+
|
387
|
+
/* website style preview classes */
|
388
|
+
div.website-styles {
|
389
|
+
margin: 0px 10px;
|
390
|
+
}
|
391
|
+
|
392
|
+
div.website-styles object {
|
393
|
+
border: 1px solid black;
|
394
|
+
width: 100%;
|
395
|
+
height: 300px;
|
396
|
+
overflow: hidden;
|
397
|
+
}
|
data/misc/default.template
CHANGED
data/misc/htmldoc.metainfo
CHANGED
data/misc/style.page
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
title: Style Example
|
3
|
+
---
|
4
|
+
## General Information
|
5
|
+
|
6
|
+
This sample website showcases the website style *<%= context.content_node.parent.cn %>*. Most
|
7
|
+
website styles include dynamic parts by default, for example, automatically generated menus and
|
8
|
+
breadcrumb trails. All such dynamic parts are active in this showcase like they would be on a normal
|
9
|
+
website.
|
10
|
+
|
11
|
+
## How to use this style
|
12
|
+
|
13
|
+
This website style can be used when creating a new website by using the following command:
|
14
|
+
|
15
|
+
webgen create -b default -b <%= context.content_node.parent.cn %> SITE_DIR
|
16
|
+
|
17
|
+
Or it can be applied later on to an already existing website by using the following command:
|
18
|
+
|
19
|
+
webgen apply <%= context.content_node.parent.cn %>
|
20
|
+
|
21
|
+
## Style Information
|
22
|
+
|
23
|
+
<dl>
|
24
|
+
<%
|
25
|
+
require 'webgen/websitemanager'
|
26
|
+
infos = Webgen::WebsiteManager.new(context.website).bundles[context.content_node.parent.cn]
|
27
|
+
infos.instance_eval {@table}.sort {|(ak,av), (bk,bv)| ak.to_s <=> bk.to_s}.each do |name, value|
|
28
|
+
next if name.to_s == 'paths'
|
29
|
+
%>
|
30
|
+
<dt><%= name.to_s.capitalize %></dt>
|
31
|
+
<dd><%= ::ERB::Util::h(value) %></dd>
|
32
|
+
<% end %>
|
33
|
+
</dl>
|
data/test/test_cli.rb
CHANGED
@@ -7,15 +7,9 @@ class TestCLICommandParser < Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
def test_initialize
|
9
9
|
cli = Webgen::CLI::CommandParser.new
|
10
|
-
assert_equal('render', cli.main_command.default_command)
|
11
10
|
assert_equal(:normal, cli.verbosity)
|
12
11
|
assert_equal(Logger::WARN, cli.log_level)
|
13
|
-
assert_equal(
|
12
|
+
assert_equal(nil, cli.directory)
|
14
13
|
end
|
15
14
|
|
16
|
-
def test_website_from_env
|
17
|
-
ENV['WEBGEN_WEBSITE'] = '/webgen/test/site'
|
18
|
-
cli = Webgen::CLI::CommandParser.new
|
19
|
-
assert_equal('/webgen/test/site', cli.directory)
|
20
|
-
end
|
21
15
|
end
|