Module: Webby

Defined in:
lib/webby/stelan/mktemp.rb,
lib/webby.rb,
lib/webby/builder.rb,
lib/webby/filters.rb,
lib/webby/helpers.rb,
lib/webby/journal.rb,
lib/webby/renderer.rb,
lib/webby/auto_builder.rb,
lib/webby/filters/tidy.rb,
lib/webby/filters/slides.rb,
lib/webby/link_validator.rb,
lib/webby/filters/outline.rb,
lib/webby/filters/basepath.rb,
lib/webby/stelan/paginator.rb

Overview

:stopdoc: Skeleton module for the ‘mktemp’ routine.

Ideally, one would do this in their code to import the “mktemp” call directly into their current namespace:

require 'mktemp'
include MkTemp
# do something with mktemp()

It is recommended that you look at the documentation for the mktemp() call directly for specific usage.

The compilation of software known as mktemp.rb is distributed under the following terms: Copyright © 2005-2006 Erik Hollensbe. All rights reserved.

Redistribution and use in source form, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

++

Defined Under Namespace

Modules: Apps, Filters, Helpers, MkTemp, Resources Classes: AutoBuilder, Builder, Error, Journal, LinkValidator, Paginator, Renderer

Constant Summary collapse

VERSION =

:stopdoc:

'0.9.4'
LIBPATH =

:nodoc:

::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
PATH =
::File.dirname(LIBPATH) + ::File::SEPARATOR
YAML_SEP =
'---'

Class Method Summary collapse

Class Method Details

.cairnObject

call-seq:

cairn    => filename

The Webby cairn file is used to mark the last time the content was built into the output directory. It is an empty file; only the modification time of the file is important.



149
150
151
# File 'lib/webby.rb', line 149

def self.cairn
  @cairn ||= ::File.join(site.output_dir, '.cairn')
end

.deprecated(method, message = nil) ⇒ Object

Prints a deprecation warning using the logger. The message states that the given method is being deprecated. An optional message can be give to – somthing nice and fuzzy about a new method or why this one has to go away; sniff, we’ll miss you little buddy.



190
191
192
193
194
# File 'lib/webby.rb', line 190

def self.deprecated( method, message = nil )
  msg = "'#{method}' has been deprecated"
  msg << "\n\t#{message}" unless message.nil?
  Logging::Logger['Webby'].warn msg
end

.editorObject

call-seq:

Webby.editor    => string or nil

Returns the default editor to use when creating new pages. This editor will be spawned to allow the user to edit the newly created page.



135
136
137
138
139
140
# File 'lib/webby.rb', line 135

def self.editor
  return @editor if defined? @editor

  @editor = if ENV['EDITOR'].nil? or ENV['EDITOR'].empty? then nil
            else ENV['EDITOR'] end
end

.excludeObject

call-seq

Webby.exclude    => regexp

Returns a regular expression used to exclude resources from the content directory from being processed by Webby. This same regular expression is also used to exclude layouts.



125
126
127
# File 'lib/webby.rb', line 125

def self.exclude
  @exclude ||= Regexp.new(site.exclude.join('|'))
end

.libpath(*args) ⇒ Object

Returns the library path for Webby. If any arguments are given, they will be joined to the end of the libray path using File.join.



157
158
159
# File 'lib/webby.rb', line 157

def self.libpath( *args )
  args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
end

.load_filesObject

Scan the layouts/ folder and the content/ folder and create a new Resource object for each file found there.



199
200
201
202
203
204
205
# File 'lib/webby.rb', line 199

def self.load_files
  ::Find.find(site.layout_dir, site.content_dir) do |path|
    next unless test ?f, path
    next if path =~ ::Webby.exclude
    Resources.new path
  end
end

.path(*args) ⇒ Object

Returns the path for Webby. If any arguments are given, they will be joined to the end of the path using File.join.



165
166
167
# File 'lib/webby.rb', line 165

def self.path( *args )
  args.empty? ? PATH : ::File.join(PATH, args.flatten)
end

.require_all_libs_relative_to(fname, dir = nil) ⇒ Object

call-seq:

Webby.require_all_libs_relative_to( filename, directory = nil )

Utility method used to rquire all files ending in .rb that lie in the directory below this file that has the same name as the filename passed in. Optionally, a specific directory name can be passed in such that the filename does not have to be equivalent to the directory.



177
178
179
180
181
182
183
# File 'lib/webby.rb', line 177

def self.require_all_libs_relative_to( fname, dir = nil )
  dir ||= ::File.basename(fname, '.*')
  search_me = ::File.expand_path(
      ::File.join(::File.dirname(fname), dir, '*.rb'))

  Dir.glob(search_me).sort.each {|rb| require rb}
end

.siteObject

call-seq:

Webby.site    => struct

Returns a struct containing the configuration parameters for the Webby site. These defaults should be overridden as needed in the site specific Rakefile.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/webby.rb', line 28

def self.site
  return @site if defined? @site
  @site = OpenStruct.new(
    :output_dir    => 'output',
    :content_dir   => 'content',
    :layout_dir    => 'layouts',
    :template_dir  => 'templates',
    :exclude       => %w(tmp$ bak$ ~$ CVS \.svn),
    :page_defaults => {
      'layout'     => 'default'
    },
    :find_by       => 'title',
    :base          => nil,
    :create_mode   => 'page',
    :blog_dir      => 'blog',
    :tumblog_dir   => 'tumblog',
    :default_ext   => 'txt',

    # Items for running the embedded webserver
    :use_web_server => true,
    :web_port      => 4331,

    # Items used to deploy the website
    :user       => ENV['USER'] || ENV['USERNAME'],
    :host       => 'example.com',
    :remote_dir => '/not/a/valid/dir',
    :rsync_args => %w(-av),

    # Global options for HAML and SASS
    :haml_options => {},
    :sass_options => {},

    # Options passed to the 'tidy' program when the tidy filter is used
    :tidy_options => '-indent -wrap 80',

    # List of valid URIs (these automatically pass validation)
    :valid_uris => [],

    # Options for coderay processing
    :coderay => {
      :lang => :ruby,
      :line_numbers => nil,
      :line_number_start => 1,
      :bold_every => 10,
      :tab_width => 8
    },

    # Options for graphviz processing
    :graphviz => {
      :path => nil,
      :cmd => 'dot',
      :type => 'png'
    },

    # Options for tex2img processing
    :tex2img => {
      :path => nil,
      :type => 'png',
      :bg => 'white',
      :fg => 'black',
      :resolution => '150x150'
    },

    # Options for ultraviolet syntax highlighting
    :uv => {
      :lang => 'ruby',
      :line_numbers => false,
      :theme => 'mac_classic'
    },

    # XPath identifiers used by the basepath filter
    :xpaths => %w(
        /html/head//base[@href]
        /html/head//link[@href]
        //script[@src]
        /html/body[@background]
        /html/body//a[@href]
        /html/body//object[@data]
        /html/body//img[@src]
        /html/body//area[@href]
        /html/body//form[@action]
        /html/body//input[@src]
    )
    # other possible XPaths to include for base path substitution
    #   /html/body//object[@usemap]
    #   /html/body//img[@usemap]
    #   /html/body//input[@usemap]
  )
end