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
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
title: Website Styles Reference
|
3
|
+
---
|
4
|
+
|
5
|
+
Following is a list of all website styles that are included in the webgen distribution. Each style
|
6
|
+
can be used when creating a website by using the command
|
7
|
+
|
8
|
+
webgen create -b default -b STYLE_NAME SITE_DIR
|
9
|
+
|
10
|
+
or applied later using the command
|
11
|
+
|
12
|
+
webgen apply STYLE_NAME
|
13
|
+
|
14
|
+
When you click on the link provided for each website style, you will get a full browser preview of
|
15
|
+
the respective website style. You can then return to this list by using the *back button* of your
|
16
|
+
browser:
|
17
|
+
|
18
|
+
<%
|
19
|
+
context.content_node.tree.node_access[:alcn].select do |name, node|
|
20
|
+
node.is_directory? && node.parent == context.content_node.tree[File.join(context.content_node.parent.absolute_lcn, '/website_styles')]
|
21
|
+
end.sort.each do |name, node|
|
22
|
+
%>
|
23
|
+
<h2 id="<%= node.cn %>"><%= node.cn %></h2>
|
24
|
+
<div class="website-styles">
|
25
|
+
<%= context.dest_node.link_to(node, :link_text => "Full window version") %>
|
26
|
+
<object type="text/html" data="<%= context.dest_node.route_to(node) %>">Nothing</object>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
title: Webgen::Source::FileSystem
|
3
|
+
---
|
4
|
+
## Description
|
5
|
+
|
6
|
+
This is the default source extension used when creating a new webgen website. It uses files that
|
7
|
+
match a certain glob (default value for the glob is to match all files) under a specific directory.
|
8
|
+
|
9
|
+
> The default configuration for a new website uses all files under the `src` directory.
|
10
|
+
{.information}
|
11
|
+
|
12
|
+
The first parameter for the file system source is the directory under which the to-be-used files are
|
13
|
+
and the second, optional, parameter specifies a glob (see [Dir.glob]).
|
14
|
+
|
15
|
+
[Dir.glob]: http://ruby-doc.org/core/classes/Dir.html#M002375
|
16
|
+
|
17
|
+
## Examples
|
18
|
+
|
19
|
+
The used sources can be specified via the [`sources` configuration option]({relocatable:
|
20
|
+
../reference_configuration.html#sources}), so each of the examples below can be specified in the
|
21
|
+
`config.yaml` file.
|
22
|
+
|
23
|
+
1. The default configuration: all files under the `src` folder of the website directory
|
24
|
+
|
25
|
+
sources: [[/, Webgen::Source::FileSystem, src]]
|
26
|
+
|
27
|
+
2. The default configuration and additionally all files under a `misc` directory:
|
28
|
+
|
29
|
+
sources:
|
30
|
+
- [/, Webgen::Source::FileSystem, src]
|
31
|
+
- [/, Webgen::Source::FileSystem, misc]
|
32
|
+
|
33
|
+
3. The default configuration and mounting all image files from an external directory under the
|
34
|
+
`/images/` directory:
|
35
|
+
|
36
|
+
sources:
|
37
|
+
- [/, Webgen::Source::FileSystem, src]
|
38
|
+
- [/images/, Webgen::Source::FileSystem, /media/storage/pictures, **/*.jpg]
|
39
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
title: Webgen::Source::TarArchive
|
3
|
+
---
|
4
|
+
## Description
|
5
|
+
|
6
|
+
The tar archive source can be used to include the files from a (possibly gzipped) tar archive. The
|
7
|
+
used archive can be stored locally on the file system but it is also possible to use archives
|
8
|
+
accessible via the http(s) and ftp protcols.
|
9
|
+
|
10
|
+
> This extension is only available if you have installed the [archive-tar-minitar][1] library. The
|
11
|
+
> preferred way to do this is via Rubygems:
|
12
|
+
>
|
13
|
+
> gem install archive-tar-minitar
|
14
|
+
{.warning}
|
15
|
+
|
16
|
+
The first parameter for the tar archive source is the URL of the archive and the second, optional,
|
17
|
+
parameter specifies a glob (see [File.fnmatch]) for selecting the to-be-used files/directories in the
|
18
|
+
tar archive.
|
19
|
+
|
20
|
+
[File.fnmatch]: http://ruby-doc.org/core/classes/File.html#M002603
|
21
|
+
[1]: http://raa.ruby-lang.org/project/minitar/
|
22
|
+
|
23
|
+
## Examples
|
24
|
+
|
25
|
+
The used sources can be specified via the [`sources` configuration option]({relocatable:
|
26
|
+
../reference_configuration.html#sources}), so each of the examples below can be specified in the
|
27
|
+
`config.yaml` file.
|
28
|
+
|
29
|
+
1. Using all files/directories from a local tar archive in addition the default configuration:
|
30
|
+
|
31
|
+
sources:
|
32
|
+
- [/, Webgen::Source::FileSystem, src]
|
33
|
+
- [/, Webgen::Source::TarArchive, archive.tar]
|
34
|
+
|
35
|
+
2. Using images stored in a remote gzipped tar archive in addition to the default configuration:
|
36
|
+
|
37
|
+
sources:
|
38
|
+
- [/, Webgen::Source::FileSystem, src]
|
39
|
+
- [/, Webgen::Source::TarArchive, http://www.example.com/archive/data.tgz, **/*.jpg]
|
40
|
+
|
data/doc/tag/tikz.page
CHANGED
@@ -84,7 +84,8 @@ edge node {0,1,R} (A)
|
|
84
84
|
<td>
|
85
85
|
{tikz:: {path: chain.png, libraries: [arrows,automata,shadows,positioning],
|
86
86
|
opts: "->,>=stealth,shorten >=1pt,auto,node distance=2.8cm,on grid,semithick,
|
87
|
-
every state/.style={fill=red,draw=none,circular drop shadow,text=white}"
|
87
|
+
every state/.style={fill=red,draw=none,circular drop shadow,text=white}",
|
88
|
+
resolution: 300 72}}
|
88
89
|
\node[initial,state] (A) {$q_a$};
|
89
90
|
\node[state] (B) [above right=of A] {$q_b$};
|
90
91
|
\node[state] (D) [below right=of A] {$q_d$};
|
data/doc/webgen_page_format.page
CHANGED
@@ -10,7 +10,7 @@ easy to use.
|
|
10
10
|
## Structure
|
11
11
|
|
12
12
|
A file using the Webgen Page Format consists of one or more blocks which are the smallest units
|
13
|
-
|
13
|
+
recognized. Blocks are separated from each other through a line containing three dashes. This is
|
14
14
|
illustrated in the following examples which are all valid files in WebPage Format:
|
15
15
|
|
16
16
|
Example 1:
|
@@ -66,17 +66,18 @@ it, it feels like just writing a plain text document.
|
|
66
66
|
|
67
67
|
A content block is used to provide content in a specific format. Each file in Webgen Page Format
|
68
68
|
needs to have at least one content block which may be empty. However, it can have as many content
|
69
|
-
blocks as necessary.
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
[extensions page]({relocatable:
|
77
|
-
|
78
|
-
|
79
|
-
use
|
69
|
+
blocks as necessary. This functionality can be used, for example, to provide the main content of an
|
70
|
+
HTML page in one block and sidebar content in another one.
|
71
|
+
|
72
|
+
Each content block needs to have a unique name and additional options can also be set. The name
|
73
|
+
uniquely identifies a content block and is used to access it. The only option used by webgen is the
|
74
|
+
`pipeline` option which specifies the processing pipeline for the block. The processing pipeline is
|
75
|
+
used for rendering the block by using the specified content processors in the specified order. There
|
76
|
+
are many different content processors available - have a look at the [extensions page]({relocatable:
|
77
|
+
extensions.html}) for an overview.
|
78
|
+
|
79
|
+
webgen extensions that use files in Webgen Page Format may specify defaults for the name and the
|
80
|
+
options of a block but these defaults can be overwritten. You can use one of two ways to do this:
|
80
81
|
|
81
82
|
* you either specify the name and additional options of the block on the starting line with the
|
82
83
|
three dashes
|
data/lib/webgen/blackboard.rb
CHANGED
@@ -4,12 +4,12 @@ module Webgen
|
|
4
4
|
|
5
5
|
# A blackboard object provides two features for inter-object communication:
|
6
6
|
#
|
7
|
-
# * services
|
7
|
+
# * *services*: An object can add a service to the blackboard which can be called by any other
|
8
8
|
# object by just specifing the service name. Therefore it is easy to change the underlying
|
9
9
|
# implementation of the service and there are no hard dependencies on specific class or method
|
10
10
|
# names.
|
11
11
|
#
|
12
|
-
# * listeners
|
12
|
+
# * *listeners*: Objects may register themselves for specific messsage names and get notified when
|
13
13
|
# such a message gets dispatched.
|
14
14
|
#
|
15
15
|
# For a list of all available services and messages have a look at the main Webgen documentation
|
data/lib/webgen/cache.rb
CHANGED
@@ -5,15 +5,15 @@ require 'facets/kernel/constant'
|
|
5
5
|
|
6
6
|
module Webgen
|
7
7
|
|
8
|
-
# A cache object provides access to various caches to speed up rendering of a website
|
8
|
+
# A cache object provides access to various caches to speed up rendering of a website:
|
9
9
|
#
|
10
|
-
# permanent
|
10
|
+
# [permanent] The permanent cache should be used for data that should be available between webgen
|
11
11
|
# runs.
|
12
12
|
#
|
13
|
-
# volatile
|
13
|
+
# [volatile] The volatile cache is used for data that can easily be regenerated but might be
|
14
14
|
# expensive to do so. This cache is not stored between webgen runs.
|
15
15
|
#
|
16
|
-
# standard
|
16
|
+
# [standard] The standard cache saves data between webgen runs and returns the cached data (not
|
17
17
|
# the newly set data) if it is available. This is useful, for example, to store file
|
18
18
|
# modifcation times and check if a file has been changed between runs.
|
19
19
|
#
|
data/lib/webgen/cli.rb
CHANGED
@@ -8,16 +8,17 @@ module Webgen
|
|
8
8
|
|
9
9
|
# Namespace for all classes that act as CLI commands.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# == Implementing a CLI command
|
12
12
|
#
|
13
13
|
# Each CLI command class needs to be put into this module and has to end with +Command+, otherwise
|
14
14
|
# it is not used. A CLI command is an extension that can be invoked from the webgen command and
|
15
15
|
# thus needs to be derived from CmdParse::Command. For detailed information on this class and the
|
16
16
|
# whole cmdparse package have a look at http://cmdparse.rubyforge.org!
|
17
17
|
#
|
18
|
-
#
|
18
|
+
# == Sample CLI command
|
19
19
|
#
|
20
|
-
# Here is a sample CLI command extension
|
20
|
+
# Here is a sample CLI command extension which could be put, for example, into the
|
21
|
+
# <tt>ext/init.rb</tt> of a webgen website:
|
21
22
|
#
|
22
23
|
# require 'webgen/cli'
|
23
24
|
#
|
@@ -26,13 +27,13 @@ module Webgen
|
|
26
27
|
# def initialize
|
27
28
|
# super('sample', false)
|
28
29
|
# self.short_desc = "This sample command just outputs its parameters"
|
29
|
-
# self.description = Utils.format("Uses the global verbosity level and outputs additional " +
|
30
|
+
# self.description = Webgen::CLI::Utils.format("Uses the global verbosity level and outputs additional " +
|
30
31
|
# "information when the level is set to verbose!")
|
31
32
|
# @username = nil
|
32
33
|
# self.options = CmdParse::OptionParserWrapper.new do |opts|
|
33
34
|
# opts.separator "Options:"
|
34
35
|
# opts.on('-u', '--user USER', String,
|
35
|
-
# 'Specify an additional user name to output') {
|
36
|
+
# 'Specify an additional user name to output') {|username| @username = username}
|
36
37
|
# end
|
37
38
|
# end
|
38
39
|
#
|
@@ -51,8 +52,8 @@ module Webgen
|
|
51
52
|
#
|
52
53
|
# end
|
53
54
|
#
|
54
|
-
# Note the use of Utils.format in the initialize method so that the long text gets
|
55
|
-
# correctly! The Utils class provides some other useful methods, too!
|
55
|
+
# Note the use of Webgen::CLI::Utils.format in the initialize method so that the long text gets
|
56
|
+
# wrapped correctly! The Utils class provides some other useful methods, too!
|
56
57
|
#
|
57
58
|
# For information about which attributes are available on the webgen command parser instance have
|
58
59
|
# a look at Webgen::CLI::CommandParser!
|
@@ -61,6 +62,7 @@ module Webgen
|
|
61
62
|
autoload :RunCommand, 'webgen/cli/run_command'
|
62
63
|
autoload :CreateCommand, 'webgen/cli/create_command'
|
63
64
|
autoload :WebguiCommand, 'webgen/cli/webgui_command'
|
65
|
+
autoload :ApplyCommand, 'webgen/cli/apply_command'
|
64
66
|
|
65
67
|
autoload :Utils, 'webgen/cli/utils'
|
66
68
|
|
@@ -84,7 +86,7 @@ module Webgen
|
|
84
86
|
# set or empty, the current working directory.
|
85
87
|
def initialize # :nodoc:
|
86
88
|
super(true)
|
87
|
-
@directory =
|
89
|
+
@directory = nil
|
88
90
|
@verbosity = :normal
|
89
91
|
@log_level = ::Logger::WARN
|
90
92
|
@log_filter = nil
|
@@ -101,19 +103,30 @@ module Webgen
|
|
101
103
|
end
|
102
104
|
self.add_command(CmdParse::HelpCommand.new)
|
103
105
|
self.add_command(CmdParse::VersionCommand.new)
|
104
|
-
Webgen::CLI.constants.select {|c| c =~ /.+Command$/ }.each do |c|
|
105
|
-
self.add_command(Webgen::CLI.const_get(c).new, (c.to_s == 'RunCommand' ? true : false))
|
106
|
-
end
|
107
106
|
end
|
108
107
|
|
109
108
|
# Utility method for sub-commands to create the correct Webgen::Website object.
|
110
109
|
def create_website
|
111
|
-
|
112
|
-
|
110
|
+
if !defined?(@website)
|
111
|
+
@website = Webgen::Website.new(@directory) do |config|
|
112
|
+
config['logger.mask'] = @log_filter
|
113
|
+
end
|
114
|
+
@website.logger.level = @log_level
|
115
|
+
@website.logger.verbosity = @verbosity
|
116
|
+
end
|
117
|
+
@website
|
118
|
+
end
|
119
|
+
|
120
|
+
# :nodoc:
|
121
|
+
def parse(argv = ARGV)
|
122
|
+
super do |level, cmd_name|
|
123
|
+
if level == 0
|
124
|
+
create_website.init
|
125
|
+
Webgen::CLI.constants.select {|c| c =~ /.+Command$/ }.each do |c|
|
126
|
+
self.add_command(Webgen::CLI.const_get(c).new, (c.to_s == 'RunCommand' ? true : false))
|
127
|
+
end
|
128
|
+
end
|
113
129
|
end
|
114
|
-
website.logger.level = @log_level
|
115
|
-
website.logger.verbosity = @verbosity
|
116
|
-
website
|
117
130
|
end
|
118
131
|
|
119
132
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'webgen/cli'
|
4
|
+
require 'webgen/websitemanager'
|
5
|
+
|
6
|
+
module Webgen::CLI
|
7
|
+
|
8
|
+
# The CLI command for applying a bundle to a webgen website.
|
9
|
+
class ApplyCommand < CmdParse::Command
|
10
|
+
|
11
|
+
def initialize #:nodoc:
|
12
|
+
super('apply', false)
|
13
|
+
@force = false
|
14
|
+
|
15
|
+
self.short_desc = 'Apply a website bundle to an existing webgen website'
|
16
|
+
self.options = CmdParse::OptionParserWrapper.new do |opts|
|
17
|
+
opts.separator "Options:"
|
18
|
+
opts.on('-f', '--[no-]force', 'Specifies whether files should be overwritten (default: no)') do |val|
|
19
|
+
@force = val
|
20
|
+
end
|
21
|
+
opts.separator ""
|
22
|
+
opts.separator "Arguments:"
|
23
|
+
opts.separator opts.summary_indent + "BUNDLE_NAME: The name of a bundle shipped with webgen. The name is "
|
24
|
+
opts.separator opts.summary_indent + " matched against all possible bundle names and if there is only "
|
25
|
+
opts.separator opts.summary_indent + " match the bundle is applied."
|
26
|
+
opts.separator opts.summary_indent + "BUNDLE_URL: The URL of a bundle (needs to be a tar archive"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def usage # :nodoc:
|
31
|
+
"Usage: #{commandparser.program_name} [global options] apply [options] (BUNDLE_NAME|BUNDLE_URL)"
|
32
|
+
end
|
33
|
+
|
34
|
+
def show_help # :nodoc:
|
35
|
+
super
|
36
|
+
wm = Webgen::WebsiteManager.new(commandparser.directory)
|
37
|
+
|
38
|
+
puts
|
39
|
+
puts "Available bundles:"
|
40
|
+
puts Utils.headline('Bundles')
|
41
|
+
wm.bundles.sort.each {|name, entry| Utils.hash_output(name, entry.instance_eval { @table }) }
|
42
|
+
end
|
43
|
+
|
44
|
+
# Apply the style specified in <tt>args[0]</tt> to the webgen website.
|
45
|
+
def execute(args)
|
46
|
+
wm = Webgen::WebsiteManager.new(commandparser.directory)
|
47
|
+
if !File.directory?(commandparser.directory)
|
48
|
+
raise "You need to specify a valid webgen website directory!"
|
49
|
+
elsif args.length == 0
|
50
|
+
raise OptionParser::MissingArgument.new('STYLE')
|
51
|
+
else
|
52
|
+
name = Utils.match_bundle_name(wm, args[0])
|
53
|
+
puts "The following files in the website directory will be created or overwritten:"
|
54
|
+
puts wm.bundles[name].paths.sort.join("\n")
|
55
|
+
continue = @force
|
56
|
+
if !continue
|
57
|
+
print "Procede? (yes/no): "
|
58
|
+
continue = ($stdin.readline =~ /y(es)?/)
|
59
|
+
end
|
60
|
+
wm.apply_bundle(name) if continue
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -11,17 +11,17 @@ module Webgen::CLI
|
|
11
11
|
def initialize #:nodoc:
|
12
12
|
super('create', false)
|
13
13
|
self.description = Utils.format("If the verbosity level is set to verbose, the created files are listed.")
|
14
|
-
@
|
15
|
-
@style = 'andreas07'
|
14
|
+
@bundles = []
|
16
15
|
|
17
|
-
self.short_desc = 'Create a basic webgen website
|
16
|
+
self.short_desc = 'Create a basic webgen website from website bundles'
|
18
17
|
self.options = CmdParse::OptionParserWrapper.new do |opts|
|
19
18
|
opts.separator "Options:"
|
20
|
-
opts.on('-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
opts.on('-b', '--bundle BUNDLE', String, "A website bundle name/URL or 'none'. Can be used more than once (default: [default, style-andreas07])") do |val|
|
20
|
+
if val.downcase == 'none'
|
21
|
+
@bundles = nil
|
22
|
+
elsif !@bundles.nil?
|
23
|
+
@bundles << val
|
24
|
+
end
|
25
25
|
end
|
26
26
|
opts.separator ""
|
27
27
|
opts.separator "Arguments:"
|
@@ -38,11 +38,9 @@ module Webgen::CLI
|
|
38
38
|
wm = Webgen::WebsiteManager.new(commandparser.directory)
|
39
39
|
|
40
40
|
puts
|
41
|
-
puts "Available
|
42
|
-
puts Utils.headline('
|
43
|
-
wm.
|
44
|
-
puts Utils.headline('Styles')
|
45
|
-
wm.styles.select {|k,v| k =~ /^website-|[^-]+/ }.sort.each {|name, entry| Utils.hash_output(name, entry.instance_eval { @table }) }
|
41
|
+
puts "Available bundles:"
|
42
|
+
puts Utils.headline('Bundles')
|
43
|
+
wm.bundles.sort.each {|name, entry| Utils.hash_output(name, entry.instance_eval { @table }) }
|
46
44
|
end
|
47
45
|
|
48
46
|
# Create a webgen website in the directory <tt>args[0]</tt>.
|
@@ -52,11 +50,19 @@ module Webgen::CLI
|
|
52
50
|
else
|
53
51
|
wm = Webgen::WebsiteManager.new(args[0])
|
54
52
|
paths = wm.create_website
|
55
|
-
|
56
|
-
|
53
|
+
begin
|
54
|
+
if @bundles
|
55
|
+
@bundles = ['default', 'style-andreas07'] if @bundles.empty?
|
56
|
+
@bundles.each {|name| paths += wm.apply_bundle(Utils.match_bundle_name(wm, name)) }
|
57
|
+
end
|
58
|
+
rescue
|
59
|
+
require 'fileutils'
|
60
|
+
FileUtils.rm_rf(args[0])
|
61
|
+
raise
|
62
|
+
end
|
57
63
|
if commandparser.verbosity == :verbose
|
58
64
|
puts "The following files were created in the directory #{args[0]}:"
|
59
|
-
puts paths.sort.
|
65
|
+
puts paths.sort.join("\n")
|
60
66
|
end
|
61
67
|
end
|
62
68
|
end
|
data/lib/webgen/cli/utils.rb
CHANGED
@@ -83,6 +83,29 @@ module Webgen::CLI
|
|
83
83
|
puts
|
84
84
|
end
|
85
85
|
|
86
|
+
# Tries to match +name+ to a unique bundle name of the WebsiteManager +wm+. If this can not be
|
87
|
+
# done, it is checked whether +name+ is actually a valid bundle URL and if so, the URL source is
|
88
|
+
# added to the bundles of +wm+.
|
89
|
+
#
|
90
|
+
# Returns the correct bundle name or raises an error.
|
91
|
+
def self.match_bundle_name(wm, name)
|
92
|
+
matches = wm.bundles.keys.select {|k| k =~ /#{Regexp.escape(name)}/}
|
93
|
+
if matches.size > 1
|
94
|
+
raise ArgumentError.new("#{name} matches more than one bundle: #{matches.join(", ")}")
|
95
|
+
elsif matches.size == 0
|
96
|
+
begin
|
97
|
+
source = Webgen::Source::TarArchive.new(name)
|
98
|
+
wm.add_source(source, 'custom-URL-source')
|
99
|
+
name = 'custom-URL-source'
|
100
|
+
rescue
|
101
|
+
raise ArgumentError.new("#{name} is neither a valid bundle name nor a valid URL")
|
102
|
+
end
|
103
|
+
else
|
104
|
+
name = matches.first
|
105
|
+
end
|
106
|
+
name
|
107
|
+
end
|
108
|
+
|
86
109
|
end
|
87
110
|
|
88
111
|
end
|