class Smeagol::Settings
Wiki
settings.
TODO: Would it be possible/prudent to move all this into controller?
Constants
- FILE
The name of the settings file. TODO: Rename to `_smeagol.yml` ?
- PARTIALS
Default template includes directory.
- SITE_PATH
Default site stage directory.
- SYNC_SCRIPT
Default sync command.
Attributes
TODO: I hate this. Make's me want to switch to Liquid templates.
Hurry up with Mustache 2.0 already!
Detailed description of site.
Files to exclude that would otherwise be included.
Include posts with future dates? By default all posts dated in the future are omitted.
Files to include that would not otherwise be included. A good example is `.htaccess` becuase dot files are excluded by default.
Page to use as site index. The default is `Home`. A non-wiki page can be used as well, such as `index.html` (well, duh!).
Support the use of mathjax? Default is `true`.
Where to find template partials. This is the location that Mustache uses when looking for partials. The default is `_partials`.
Include a GitHub “Fork Me” ribbon in corner of page. Entry should give color and position separated by a space. The resulting ribbon will have a link to `source_url`.
TODO: Rename this `github_forkme` or something like that.
Examples
ribbon: red right
Note this might be deprecated as one can add it by hand to custom page template.
Boolean flag to produce an rss.xml feed file for blog posts.
Special branch if using silly branch style, e.g. `gh-pages`.
If deployment of a site is done via git, then `site_origin` can be used to setup a Repository
instance that can handle pulls and pushes automatically.
Examples
site_origin: git@github.com:trans/trans.github.com.git
Set `site_stage` if the site needs to be staged for deployment. In other words, if the servable files in the wiki need to be copied into a separate directory. This can be set to `true` in which case the default `_site` path will be used, otherwise set it to the path desired.
Non-absolute paths are relative to the wiki's location. Be sure to add this to the wiki's .gitignore file, if it is, and if not prefixed by and underscore, be sure to add it to `exclude` setting as well.
Smeagol
uses `rsync` to copy files from the repository to the staging location if given by `site_path`. By default this command is:
"rsync -arv --del --exclude .git* %s/ %s/"
Where the first %s is the repository location and the second is the location specified by the `site_path` setting. If this needs to be different it can be change here. Just be sure to honor the `%s` slots.
If set to `~` (ie. `nil`) then the files will be copied directly to the site_path
directory without using rsync.
Project's development site, if applicable. e.g. `github.com/trans`
TODO: Rename this field.
Single line description of site.
Title of site.
Google analytics tracking id. Could be used for other such services if custom template is used.
Note this will probably be deprecates because you can add the code snippet easily enough to your custom page template.
Site's URL. If someone wanted to visit your website, this is the link they would follow, e.g. `trans.github.com`
Internal: Do not set this in _settings.yml!
Gollum
wiki's repo uri. e.g. `git@github.com:trans/trans.github.com.wiki.git`
The particular tag or reference id to serve. Default is 'master'.
Public Class Methods
Load settings.
wiki_dir
- Local file system location of wiki repo. [String]
Returns settings instance. [Settings]
# File lib/smeagol/settings.rb, line 28 def self.load(wiki_dir=nil) wiki_dir = Dir.pwd unless wiki_dir file = File.join(wiki_dir, FILE) file = File.expand_path(file) if File.exist?(file) settings = YAML.load_file(file) else settings = {} end settings[:wiki_dir] = wiki_dir new(settings) end
Initialize Settings
.
settings - Settings
hash. [Hash]
# File lib/smeagol/settings.rb, line 48 def initialize(settings={}) @partials = PARTIALS @index = 'Home' @rss = true @exclude = [] @include = [] @site = nil @date_format = "%B %d, %Y" @site_stage = nil @site_sync = SYNC_SCRIPT #@static = false @mathjax = true @future = false # TODO: Raise error if no wiki_dir ? @wiki_dir = settings[:wiki_dir] assign(settings) end
Public Instance Methods
Deprecated: Access settings like a Hash.
# File lib/smeagol/settings.rb, line 69 def [](key) __send__(key) end
Assign settings hash via writer methods.
Returns nothing.
# File lib/smeagol/settings.rb, line 76 def assign(settings={}) settings.each do |k,v| __send__("#{k}=", v) if respond_to?("#{k}=") end end
# File lib/smeagol/settings.rb, line 119 def site {'stage'=>site_stage, 'origin'=>site_origin, 'branch'=>site_branch} end
If deployment of a site is done via git or via a staging directory, then `site` can be used to set these.
Examples
site: origin: git@github.com:trans/trans.github.com.git branch: gh-pages path: _site
# File lib/smeagol/settings.rb, line 133 def site=(entry) case entry when Hash self.site_origin = site['origin'] self.site_branch = site['branch'] self.site_stage = site['stage'] self.site_sync = site['sync'] if site['sync'] else raise ArgumentError, 'site must be a mapping' # TODO: maybe make this smarter in future to guess if single entry is origin or stage. #self.site_stage = entry end end
Expanded site directory.
If `site_path` is an absolute path it will returned as given, otherwise this will be relative to the location of the wiki.
Returns String of site path.
# File lib/smeagol/settings.rb, line 281 def site_path site_path = (TrueClass === site_stage ? SITE_PATH : site_stage || SITE_PATH) path = relative?(site_path) ? ::File.join(wiki_dir, site_path) : site_path path.chomp('/') # ensure no trailing path separator path end
Returns Repository
object for git-based deployment site.
# File lib/smeagol/settings.rb, line 295 def site_repo @site_repo ||= ( opts = (site || {}).dup opts[:path] = site_path Repository.new(opts) ) end
# File lib/smeagol/settings.rb, line 103 def wiki {'origin'=>wiki_origin, 'ref'=>wiki_ref} end
# File lib/smeagol/settings.rb, line 108 def wiki=(entry) case entry when Hash self.wiki_origin = site['origin'] self.wiki_ref = site['ref'] else raise ArgumentError, 'wiki must be a mapping' end end
Private Instance Methods
# File lib/smeagol/settings.rb, line 308 def relative?(path) return false if path =~ /^[A-Z]\:/ return false if path.start_with?(::File::SEPARATOR) return false if path.start_with?('/') #return false if path.start_with?('.') return true end