webgen 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc28598716d6dbfc5755161abde547978815a8fb
4
- data.tar.gz: 9fcab153b65bfcb25fe189174e292591153944fb
3
+ metadata.gz: 8014eb18c4f772caae6df97d2a0887e4a1618672
4
+ data.tar.gz: 8ed2ef00768fd1696394485f1785564428308a5d
5
5
  SHA512:
6
- metadata.gz: a8819bc56874a30b1d5c0b63bb7f65a7fe8a104c8c8ed7c2b659db128d600a9ffd66d3e821e476b4c29775596678f83aafaf3025dee52ec715a966184cfbad50
7
- data.tar.gz: e0a3b69860bdcf22c5b654f0c37529543acc7137ba5a6d5841c10fc56b10da308160451d38b4b397d22e82710b28da39deec537c7e5109db4207f2045bc33eeb
6
+ metadata.gz: b346a18e36607dd4262de8f5245e2d19f143433d2b3ddf2d4769216b88a18b35db8ee22728cb9a93e82d1045cbfe85595e1923d522f8d644ec9887442565292f
7
+ data.tar.gz: 2ebbd16b45b3a20337e53321520e05f7ed7054cbf2463538bf6d9a45e1d27269f7929f5e71edb1044ccb71d92fa37f55a90add30887e3c6fd28c58cb8f64e7cd
data/README.md CHANGED
@@ -46,14 +46,14 @@ makes authoring websites easier:
46
46
 
47
47
  * No need to know the Ruby language for basic websites
48
48
 
49
- The main documentation lives at <http://webgen.rubyforge.org/documentation/>.
49
+ The main documentation lives at <http://webgen.gettalong.org/documentation/>.
50
50
 
51
51
 
52
52
  ## Installation
53
53
 
54
54
  webgen is written in Ruby, so you need the Ruby interpreter on your
55
55
  system. You can get it from http://ruby-lang.org/. See
56
- <http://webgen.rubyforge.org/installation.html> for more information.
56
+ <http://webgen.gettalong.org/installation.html> for more information.
57
57
 
58
58
  You can install webgen via Rubygems:
59
59
 
data/Rakefile CHANGED
@@ -98,11 +98,11 @@ EOF
98
98
  s.post_install_message = <<EOF
99
99
 
100
100
  Thanks for choosing webgen! Here are some places to get you started:
101
- * The webgen User Documentation at <http://webgen.rubyforge.org/documentation/>
101
+ * The webgen User Documentation at <http://webgen.gettalong.org/documentation/>
102
102
  * The mailing list archive at <http://rubyforge.org/pipermail/webgen-users/>
103
103
  * The webgen Wiki at <http://github.com/gettalong/webgen/wiki>
104
104
 
105
- Have a look at <http://webgen.rubyforge.org/news.html> for a list of changes!
105
+ Have a look at <http://webgen.gettalong.org/news.html> for a list of changes!
106
106
 
107
107
  Have fun!
108
108
 
@@ -145,7 +145,7 @@ EOF
145
145
 
146
146
  s.author = 'Thomas Leitner'
147
147
  s.email = 't_leitner@gmx.at'
148
- s.homepage = "http://webgen.rubyforge.org"
148
+ s.homepage = "http://webgen.gettalong.org"
149
149
  s.rubyforge_project = 'webgen'
150
150
  end
151
151
 
@@ -188,7 +188,7 @@ EOF
188
188
  rf.configure
189
189
  rf.login
190
190
 
191
- text = "Have a look at http://webgen.rubyforge.org/news.html for the release details!"
191
+ text = "Have a look at http://webgen.gettalong.org/news.html for the release details!"
192
192
  rf.post_news('webgen', "webgen #{Webgen::VERSION} released", text)
193
193
  puts "done"
194
194
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
@@ -10,7 +10,7 @@
10
10
  # * For information on how to write extensions, have a look at the API
11
11
  # documentation of webgen at
12
12
  #
13
- # http://webgen.rubyforge.org/documentation/reference/api/
13
+ # http://webgen.gettalong.org/documentation/reference/api/
14
14
  #
15
15
  # * Have a look at the API documentation of Webgen::BundlerLoader to see
16
16
  # what methods are available in init.rb files.
@@ -12,7 +12,7 @@
12
12
  # The available configuration options can be found on the homepage in the Configuration Option
13
13
  # Reference at
14
14
  #
15
- # http://webgen.rubyforge.org/documentation/reference/configuration_options.html
15
+ # http://webgen.gettalong.org/documentation/reference/configuration_options.html
16
16
  #
17
17
  # More info about YAML itself can be found at http://www.yaml.org/
18
18
  #####
@@ -10,7 +10,7 @@
10
10
 
11
11
  <link href="<%= context.node.feed_link %>" rel="alternate" />
12
12
  <link href="<%= context.node.url %>" rel="self" />
13
- <generator uri="http://webgen.rubyforge.org/" version="<%= Webgen::VERSION %>">
13
+ <generator uri="http://webgen.gettalong.org/" version="<%= Webgen::VERSION %>">
14
14
  webgen - Webgen::PathHandler::Feed
15
15
  </generator>
16
16
  <updated><%= Time.now.xmlschema %></updated>
@@ -1,6 +1,6 @@
1
1
  --- name:tag.langbar pipeline:ruby ------------------------------------------------------------------
2
2
  context.content = context[:nodes].map do |node|
3
- attrs = {'link_text' => node.lang}
3
+ attrs = {'link_text' => context[:config]['tag.langbar.mapping'][node.lang] || node.lang}
4
4
  attrs['class'] = 'webgen-langbar-current-lang' if context.content_node.lang == node.lang
5
5
  context.dest_node.link_to(node, node.lang, attrs)
6
6
  end.join(context[:config]['tag.langbar.separator'])
@@ -772,6 +772,18 @@ options:
772
772
  tag: |
773
773
  {include_file: {filename: my_file.txt, process_output: false}}
774
774
 
775
+ tag.langbar.mapping:
776
+ summary: |
777
+ A hash with a mapping from language codes to display strings. If there is no mapping for a
778
+ language code, the language code itself is displayed.
779
+ syntax: |
780
+ `MAPPING` where `MAPPING` is a hash with the mappings
781
+ example:
782
+ config: |
783
+ tag.langbar.mapping: {de: Deutsch, en: English}
784
+ tag: |
785
+ {menu: {mapping: {de: Deutsch, en: English}}}
786
+
775
787
  tag.langbar.separator:
776
788
  summary: |
777
789
  The string that should be used as separator between the individual language parts.
@@ -1042,6 +1054,16 @@ options:
1042
1054
  config: |
1043
1055
  website.lang: de
1044
1056
 
1057
+ website.link_to_current_page:
1058
+ summary:
1059
+ Specifies whether generated links to the current page should be used. If `false`, then a
1060
+ `<span>` element is used instead of a `<href>` element.
1061
+ syntax: |
1062
+ `true` or `false`.
1063
+ example:
1064
+ config: |
1065
+ website.link_to_current_page: false
1066
+
1045
1067
  website.base_url:
1046
1068
  summary: |
1047
1069
  The base URL of the website. It is used to create absolute URLs when relative URLs won't
@@ -1050,7 +1072,7 @@ options:
1050
1072
  `URL` where `URL` is the base URL of the website
1051
1073
  example:
1052
1074
  config: |
1053
- website.base_url: http://webgen.rubyforge.org
1075
+ website.base_url: http://webgen.gettalong.org
1054
1076
 
1055
1077
  website.tmpdir:
1056
1078
  summary: |
@@ -54,7 +54,7 @@ option('website.lang', 'en') do |val|
54
54
  end
55
55
 
56
56
  option('website.base_url', '', &is_string)
57
-
57
+ option('website.link_to_current_page', true, &true_or_false)
58
58
 
59
59
  ########################################################################
60
60
  # Everything related to the content processor extension
@@ -309,6 +309,7 @@ option('tag.langbar.show_single_lang', true, &true_or_false)
309
309
  option('tag.langbar.show_own_lang', true, &true_or_false)
310
310
  option('tag.langbar.template', '/templates/tag.template')
311
311
  option('tag.langbar.separator', ' | ')
312
+ option('tag.langbar.mapping', {}, &is_hash)
312
313
 
313
314
  tag.register('BreadcrumbTrail')
314
315
  option('tag.breadcrumb_trail.omit_dir_index', false &true_or_false)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'rbconfig'
4
4
  require 'yaml'
5
+ require 'webgen/error'
5
6
 
6
7
  module Webgen
7
8
 
@@ -90,7 +91,7 @@ module Webgen
90
91
  # Load the extension bundle in the context of this BundleLoader object.
91
92
  def load(name)
92
93
  file = resolve_init_file(name)
93
- raise(ArgumentError, "Extension bundle '#{name}' not found") if !file
94
+ raise Webgen::BundleLoadError.new(name) if !file
94
95
  file = File.expand_path(file)
95
96
  return if @loaded.include?(file)
96
97
 
@@ -193,7 +193,10 @@ module Webgen
193
193
  if level == 0
194
194
  # Create website object/automatically performs initialization; needed so that custom
195
195
  # commands can be added
196
- website
196
+ begin
197
+ website
198
+ rescue Webgen::BundleLoadError
199
+ end
197
200
  end
198
201
  end
199
202
  rescue
@@ -39,6 +39,7 @@ module Webgen
39
39
  options[:link_defs] = context.website.ext.link_definitions.merge(options[:link_defs] || {})
40
40
  doc = ::Kramdown::Document.new(context.content, options)
41
41
  context.content = CustomHtmlConverter.new(doc.root, doc.options, context).convert(doc.root)
42
+ context.content.encode!(doc.root.options[:encoding])
42
43
  doc.warnings.each do |warn|
43
44
  context.website.logger.warn { "kramdown warning while parsing <#{context.ref_node}>: #{warn}" }
44
45
  end
@@ -126,6 +126,21 @@ module Webgen
126
126
  end
127
127
 
128
128
 
129
+ # This error is raised when a needed bundle is not found.
130
+ class BundleLoadError < Error
131
+
132
+ # The name of the bundle that is missing.
133
+ attr_reader :bundle
134
+
135
+ # Create a new BundleLoadError.
136
+ def initialize(bundle)
137
+ super("The needed bundle '#{bundle}' is missing.", nil, nil)
138
+ end
139
+
140
+ end
141
+
142
+
143
+
129
144
  # This error is raised when a needed external command is not found.
130
145
  class CommandNotFoundError < Error
131
146
 
@@ -59,7 +59,7 @@ module Webgen
59
59
  def self.append(base, path)
60
60
  raise(ArgumentError, 'base needs to start with a slash (i.e. be an absolute path)') unless base[0] == ?/
61
61
  url = url(base) + url(path, false)
62
- url.path << (url.fragment.nil? ? '' : "##{url.fragment}")
62
+ (url.path << (url.fragment.nil? ? '' : "##{url.fragment}")).encode!(path.encoding)
63
63
  end
64
64
 
65
65
  # Return +true+ if the given path string matches the given path pattern.
@@ -41,14 +41,25 @@ module Webgen
41
41
  node_url.absolute? ? node_url : File.join(tree.website.config['website.base_url'], dest_path)
42
42
  end
43
43
 
44
- # Does exactly the same as Node#route_to but also automatically adds the necessary item
45
- # tracking information.
44
+ # Does exactly the same as Webgen::Node#route_to but also automatically adds the necessary
45
+ # item tracking information.
46
46
  def route_to(node, lang = @lang)
47
47
  tree.website.ext.item_tracker.add(self, :node_meta_info, node)
48
48
  tree.website.ext.item_tracker.add(self, :node_meta_info, node.proxy_node(lang))
49
49
  super
50
50
  end
51
51
 
52
+ # Does exactly the same as Webgen::Node#link_to but replaces the HTML a-tag with a span-tag
53
+ # depending on the configuration option 'website.link_to_current_page'.
54
+ def link_to(*args, &block)
55
+ result = super
56
+ if !tree.website.config['website.link_to_current_page']
57
+ result.sub!(/<a/, '<span').sub!(/<\/a>/, '</span>').
58
+ gsub!(/ (?:href|hreflang)=".*"/, '')
59
+ end
60
+ result
61
+ end
62
+
52
63
  # Return the result of the #content method on the associated path handler or +nil+ if the
53
64
  # associated path handler does not have a #content method.
54
65
  def content
@@ -50,19 +50,27 @@ module Webgen
50
50
  # Following is a simple tag class example which just reverses the body text and adds some
51
51
  # information about the context to the result.
52
52
  #
53
+ # Put the following into the ext/init.rb file of your webgen website:
54
+ #
53
55
  # class Reverser
54
56
  #
55
57
  # def self.call(tag, body, context)
56
- # result = context[:config]['do_reverse'] ? body.reverse : body
57
- # result << "Node: " << context.content_node.alcn << " (" << context.content_node['title'] << ")"
58
- # result << "Reference node: " << context.ref_node.alcn
58
+ # result = context[:config]['tag.reverser.do_reverse'] ? body.reverse : body
59
+ # result << "\nNode: " << context.content_node.alcn << " (" << context.content_node['title'] << ")"
60
+ # result << "\nReference node: " << context.ref_node.alcn
59
61
  # result
60
62
  # end
61
63
  #
62
64
  # end
63
65
  #
64
- # website.config.define_option('reverser.do_reverse', nil, 'Actually do reverse the text')
65
- # website.ext.tag.register Reverser, :names => 'reverse', :mandatory => ['do_reverse']
66
+ # website.config.define_option('tag.reverser.do_reverse', nil)
67
+ # website.ext.tag.register(Reverser, :names => 'reverse',
68
+ # :config_prefix => 'tag.reverser',
69
+ # :mandatory => ['do_reverse'])
70
+ #
71
+ # Then you can use the reverser tag as follows in a page file:
72
+ #
73
+ # {reverse:: {do_reverse: true}}This text is reversed{reverse}
66
74
  #
67
75
  class Tag
68
76
 
@@ -189,8 +197,10 @@ module Webgen
189
197
  # prefix.
190
198
  def create_config(tag, params, tdata, context)
191
199
  values = case params
192
- when Hash then values_from_hash(tag, params, tdata, context)
193
- when String, Array then values_for_default_mandatory(tag, params, tdata, context)
200
+ when Hash
201
+ values_from_hash(tag, params, tdata, context)
202
+ when String, Array, TrueClass, FalseClass, Numeric
203
+ values_for_default_mandatory(tag, params, tdata, context)
194
204
  when NilClass then {}
195
205
  else
196
206
  raise Webgen::RenderError.new("Invalid parameter type (#{params.class})",
@@ -3,6 +3,6 @@
3
3
  module Webgen
4
4
 
5
5
  # The version of webgen.
6
- VERSION = '1.0.0'
6
+ VERSION = '1.1.0'
7
7
 
8
8
  end
@@ -96,7 +96,7 @@ webgen's behaviour is affected by the following environment variables:
96
96
  If no website is specified via the \-d option and this variable is set, webgen assumes that its
97
97
  content is the webgen website directory that should be used.
98
98
  .SH SEE ALSO
99
- The webgen website, http://webgen.rubyforge.org/ for detailed information.
99
+ The webgen website, http://webgen.gettalong.org/ for detailed information.
100
100
  .SH AUTHOR
101
101
  webgen was written by Thomas Leitner <t_leitner@gmx.at>
102
102
  .PP
@@ -18,7 +18,7 @@ class TestPathHandlerBase < Minitest::Test
18
18
  end
19
19
 
20
20
  def setup
21
- setup_website('website.base_url' => 'http://example.com/sub')
21
+ setup_website
22
22
  @obj = TestPathHandler.new(@website)
23
23
  end
24
24
 
@@ -31,7 +31,6 @@ class TestPathHandlerBase < Minitest::Test
31
31
  node = @obj.create_node(path) {|n| count += 1; assert_kind_of(Webgen::PathHandler::Base::Node, n)}
32
32
  assert_equal(path, node.node_info[:path])
33
33
  assert_kind_of(Time, node.meta_info['modified_at'])
34
- assert_equal('http://example.com/sub/path.html', node.url)
35
34
  assert_equal(1, count)
36
35
  assert_nil(node.content)
37
36
  def (@obj).content(node); node; end
@@ -150,4 +149,17 @@ class TestPathHandlerBase < Minitest::Test
150
149
  assert_equal(nil, @obj.node_exists?(Webgen::Path.new('/unknown'), '/unknown'))
151
150
  end
152
151
 
152
+ def test_base_node_methods
153
+ node = Webgen::PathHandler::Base::Node.new(@website.tree.dummy_root, '/', '/')
154
+ child_de = Webgen::PathHandler::Base::Node.new(node, 'somename.html', '/somename.html',
155
+ {'lang' => 'de', 'title' => 'Somename'})
156
+ @website.config = {'website.base_url' => 'http://example.com/sub', 'website.link_to_current_page' => true}
157
+
158
+ assert_equal('http://example.com/sub/somename.html', child_de.url)
159
+
160
+ assert_equal('<a href="somename.html" hreflang="de">Somename</a>', node.link_to(child_de))
161
+ @website.config['website.link_to_current_page'] = false
162
+ assert_equal('<span>Somename</span>', node.link_to(child_de))
163
+ end
164
+
153
165
  end
@@ -28,11 +28,18 @@ class TestTagLangbar < Minitest::Test
28
28
 
29
29
  en_link = '<a class="webgen-langbar-current-lang" href="other.html" hreflang="en">en</a>'
30
30
  check_results(other, en_link, '', '', '', ' | ')
31
+
32
+ @context[:chain] = [node]
33
+ @context[:config] = {'tag.langbar.template' => '/tag.template', 'tag.langbar.mapping' => {'de' => 'Deutsch'}}
34
+ assert_equal('<a href="file.de.html" hreflang="de">Deutsch</a>', @obj.call('langbar', '', @context))
31
35
  end
32
36
 
33
37
  def check_results(node, both_true, both_false, first_false, second_false, separator)
34
38
  @context[:chain] = [node]
35
- @context[:config] = {'tag.langbar.template' => '/tag.template', 'tag.langbar.separator' => separator}
39
+ @context[:config] = {'tag.langbar.template' => '/tag.template',
40
+ 'tag.langbar.separator' => separator,
41
+ 'tag.langbar.mapping' => {}
42
+ }
36
43
 
37
44
  @context[:config].update('tag.langbar.show_single_lang' => true, 'tag.langbar.show_own_lang' => true)
38
45
  assert_equal(both_true, @obj.call('langbar', '', @context))
@@ -40,6 +40,8 @@ EOF
40
40
  end
41
41
 
42
42
  def test_load
43
+ assert_raises(Webgen::BundleLoadError) { @loader.load('unknown') }
44
+
43
45
  @loader.load('webgen')
44
46
  assert_nil(@website.ext.bundle_infos.instance_variable_get(:@infos))
45
47
  assert_equal({}, @website.ext.bundle_infos.bundles['webgen'])
@@ -31,7 +31,7 @@ class TestNode < Minitest::Test
31
31
  check_proc.call(child, node, '/somename.html', 'somename.html', 'somename.de.html',
32
32
  '/somename.de.html', 'de', {})
33
33
 
34
- ['http://webgen.rubyforge.org', 'c:\\test'].each_with_index do |abspath, index|
34
+ ['http://webgen.gettalong.org', 'c:\\test'].each_with_index do |abspath, index|
35
35
  cn = "test#{index}.html"
36
36
  c = Webgen::Node.new(node, cn, abspath)
37
37
  check_proc.call(c, node, abspath, cn, cn, '/' + cn, nil, {})
@@ -30,6 +30,9 @@ class TestPath < Minitest::Test
30
30
  assert_equal('/test/dir', Webgen::Path.append('/other', '../test/dir'))
31
31
  assert_equal('/test', Webgen::Path.append('/', '/../test'))
32
32
  assert_equal('/dir/', Webgen::Path.append('/', '/../dir/.'))
33
+
34
+ assert_equal(Encoding::UTF_8, Webgen::Path.append('/', '/../dir/.').encoding)
35
+ assert_equal(Encoding::UTF_8, Webgen::Path.append('/', '/**.css').encoding)
33
36
  end
34
37
 
35
38
  def test_class_matches_pattern
@@ -67,7 +67,7 @@ class TestTag < Minitest::Test
67
67
  assert_raises(Webgen::RenderError) { @tag.call('my_tag', {}, 'body', context) }
68
68
 
69
69
  @tag.register('MyTag')
70
- assert_raises(Webgen::RenderError) { @tag.call('my_tag', 5, 'body', context) }
70
+ assert_raises(Webgen::RenderError) { @tag.call('my_tag', Class.new, 'body', context) }
71
71
  assert_raises(Webgen::Configuration::Error) { @tag.call('my_tag', {'opt' => :value}, 'body', context) }
72
72
 
73
73
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-01 00:00:00.000000000 Z
11
+ date: 2013-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdparse
@@ -477,18 +477,18 @@ files:
477
477
  - test/webgen/test_utils.rb
478
478
  - test/webgen/test_website.rb
479
479
  - test/webgen/utils/test_tag_parser.rb
480
- homepage: http://webgen.rubyforge.org
480
+ homepage: http://webgen.gettalong.org
481
481
  licenses:
482
482
  - GPL
483
483
  metadata: {}
484
484
  post_install_message: |2+
485
485
 
486
486
  Thanks for choosing webgen! Here are some places to get you started:
487
- * The webgen User Documentation at <http://webgen.rubyforge.org/documentation/>
487
+ * The webgen User Documentation at <http://webgen.gettalong.org/documentation/>
488
488
  * The mailing list archive at <http://rubyforge.org/pipermail/webgen-users/>
489
489
  * The webgen Wiki at <http://github.com/gettalong/webgen/wiki>
490
490
 
491
- Have a look at <http://webgen.rubyforge.org/news.html> for a list of changes!
491
+ Have a look at <http://webgen.gettalong.org/news.html> for a list of changes!
492
492
 
493
493
  Have fun!
494
494