foreman_remote_execution 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/doc/Gemfile +7 -0
- data/doc/Gemfile.lock +90 -0
- data/doc/Rakefile +41 -0
- data/doc/_config.yml +33 -0
- data/doc/plugins/alert_block.rb +27 -0
- data/doc/plugins/div_tag.rb +24 -0
- data/doc/plugins/graphviz.rb +121 -0
- data/doc/plugins/plantuml.rb +84 -0
- data/doc/plugins/play.rb +13 -0
- data/doc/plugins/tags.rb +138 -0
- data/doc/plugins/toc.rb +20 -0
- data/doc/source/404.md +6 -0
- data/doc/source/_includes/footer.html +21 -0
- data/doc/source/_includes/header.html +59 -0
- data/doc/source/_includes/tocify.html +6 -0
- data/doc/source/_layouts/default.html +9 -0
- data/doc/source/_layouts/page.html +25 -0
- data/doc/source/atom.xml +32 -0
- data/doc/source/design/index.md +1317 -0
- data/doc/source/index.md +18 -0
- data/doc/source/static/css/bootstrap-responsive.min.css +9 -0
- data/doc/source/static/css/bootstrap.min.css +866 -0
- data/doc/source/static/css/jquery.tocify.css +128 -0
- data/doc/source/static/css/style.css +285 -0
- data/doc/source/static/css/syntax.css +60 -0
- data/doc/source/static/images/foreman.png +0 -0
- data/doc/source/static/images/glyphicons-halflings-white.png +0 -0
- data/doc/source/static/images/glyphicons-halflings.png +0 -0
- data/doc/source/static/js/bootstrap.min.js +7 -0
- data/doc/source/static/js/jquery-ui-1.9.2.custom.min.js +6 -0
- data/doc/source/static/js/jquery.js +2 -0
- data/doc/source/static/js/jquery.tocify.min.js +3 -0
- data/doc/source/static/js/scroll.js +24 -0
- data/lib/foreman_remote_execution/version.rb +1 -1
- metadata +90 -23
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YzFkYTZlMjZjOTNjMjg5MjRlZjA0YzhlODkxMjNiN2NkOTljMTgxMw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 14df7931599fdfff719c3c5c9fa6bccc8204bd74
|
4
|
+
data.tar.gz: 227732341a3e7cc85392236bf15728e7a1be9640
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MzE5N2Q5NDU5Nzc2MGMyMDc0ZTgwOTY2NWU3NTg0OGZjYTY0NWYwYTE0ZGNi
|
11
|
-
NmViNTlhY2JkOWI1MWI2N2ZjYjYxNTE1NTgxY2Q4NTBkYTc2ZmY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OGVlYzBhMDYyZjFlYTAzMDVmZjU2YjEyMDIwZDNiOGJhNjVmNjcyNGIzMTVi
|
14
|
-
MjVkYzUyMTA3OTEzNDExNzRiZDUyZDczYmJkOGQyNDg4MTY4N2IwODYwZjU5
|
15
|
-
MDY1N2UwMDAxNTQyODQ5MGQzZWQ2N2UwMWZlYmQ5YmYzMTc3Njg=
|
6
|
+
metadata.gz: df9b36dea0fc4332234f07614cb6cbd6cfd388e39fdf99dd473f1bd653dd6ad0e892d7e0da5020045a7df5cedca13eb9a5a866c03e58957ae3709a675e01443e
|
7
|
+
data.tar.gz: aab71ad163408fec86b470a3a4a07aa899c2bfeef99d5e239e5e0a8ea2107edc072ebb020f8f2aed06a384d4d528a4bcf07014590d253af976dbf27b55f7df45
|
data/doc/Gemfile
ADDED
data/doc/Gemfile.lock
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
blankslate (2.1.2.4)
|
5
|
+
celluloid (0.16.0)
|
6
|
+
timers (~> 4.0.0)
|
7
|
+
classifier-reborn (2.0.3)
|
8
|
+
fast-stemmer (~> 1.0)
|
9
|
+
coderay (1.1.0)
|
10
|
+
coffee-script (2.3.0)
|
11
|
+
coffee-script-source
|
12
|
+
execjs
|
13
|
+
coffee-script-source (1.9.1)
|
14
|
+
colorator (0.1)
|
15
|
+
execjs (2.3.0)
|
16
|
+
fast-stemmer (1.0.2)
|
17
|
+
ffi (1.9.6)
|
18
|
+
hitimes (1.2.2)
|
19
|
+
jekyll (2.5.3)
|
20
|
+
classifier-reborn (~> 2.0)
|
21
|
+
colorator (~> 0.1)
|
22
|
+
jekyll-coffeescript (~> 1.0)
|
23
|
+
jekyll-gist (~> 1.0)
|
24
|
+
jekyll-paginate (~> 1.0)
|
25
|
+
jekyll-sass-converter (~> 1.0)
|
26
|
+
jekyll-watch (~> 1.1)
|
27
|
+
kramdown (~> 1.3)
|
28
|
+
liquid (~> 2.6.1)
|
29
|
+
mercenary (~> 0.3.3)
|
30
|
+
pygments.rb (~> 0.6.0)
|
31
|
+
redcarpet (~> 3.1)
|
32
|
+
safe_yaml (~> 1.0)
|
33
|
+
toml (~> 0.1.0)
|
34
|
+
jekyll-coffeescript (1.0.1)
|
35
|
+
coffee-script (~> 2.2)
|
36
|
+
jekyll-gist (1.1.0)
|
37
|
+
jekyll-paginate (1.1.0)
|
38
|
+
jekyll-sass-converter (1.3.0)
|
39
|
+
sass (~> 3.2)
|
40
|
+
jekyll-watch (1.2.1)
|
41
|
+
listen (~> 2.7)
|
42
|
+
kramdown (1.6.0)
|
43
|
+
libv8 (3.16.14.7)
|
44
|
+
liquid (2.6.2)
|
45
|
+
listen (2.8.5)
|
46
|
+
celluloid (>= 0.15.2)
|
47
|
+
rb-fsevent (>= 0.9.3)
|
48
|
+
rb-inotify (>= 0.9)
|
49
|
+
mercenary (0.3.5)
|
50
|
+
method_source (0.8.2)
|
51
|
+
nuggets (1.0.0)
|
52
|
+
parslet (1.5.0)
|
53
|
+
blankslate (~> 2.0)
|
54
|
+
posix-spawn (0.3.10)
|
55
|
+
pry (0.10.1)
|
56
|
+
coderay (~> 1.1.0)
|
57
|
+
method_source (~> 0.8.1)
|
58
|
+
slop (~> 3.4)
|
59
|
+
pygments.rb (0.6.2)
|
60
|
+
posix-spawn (~> 0.3.6)
|
61
|
+
yajl-ruby (~> 1.2.0)
|
62
|
+
rake (10.4.2)
|
63
|
+
rb-fsevent (0.9.4)
|
64
|
+
rb-inotify (0.9.5)
|
65
|
+
ffi (>= 0.5.0)
|
66
|
+
redcarpet (3.2.2)
|
67
|
+
ref (1.0.5)
|
68
|
+
ruby-nuggets (1.0.0)
|
69
|
+
nuggets (= 1.0.0)
|
70
|
+
safe_yaml (1.0.4)
|
71
|
+
sass (3.4.13)
|
72
|
+
slop (3.6.0)
|
73
|
+
therubyracer (0.12.1)
|
74
|
+
libv8 (~> 3.16.14.0)
|
75
|
+
ref
|
76
|
+
timers (4.0.1)
|
77
|
+
hitimes
|
78
|
+
toml (0.1.2)
|
79
|
+
parslet (~> 1.5.0)
|
80
|
+
yajl-ruby (1.2.1)
|
81
|
+
|
82
|
+
PLATFORMS
|
83
|
+
ruby
|
84
|
+
|
85
|
+
DEPENDENCIES
|
86
|
+
jekyll
|
87
|
+
pry
|
88
|
+
rake
|
89
|
+
ruby-nuggets
|
90
|
+
therubyracer
|
data/doc/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
root = File.dirname __FILE__
|
5
|
+
|
6
|
+
task :default => :publish
|
7
|
+
|
8
|
+
def system(cmd)
|
9
|
+
puts ">> #{cmd}"
|
10
|
+
super cmd
|
11
|
+
end
|
12
|
+
|
13
|
+
task :plantuml_install do
|
14
|
+
unless File.exist?('.bin/plantuml.jar')
|
15
|
+
sh 'wget https://downloads.sourceforge.net/project/plantuml/plantuml.jar -O .bin/plantuml.jar'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
task :fetch do
|
20
|
+
unless File.exist?('public/.git')
|
21
|
+
FileUtils.rm_rf('public')
|
22
|
+
sh 'git clone git@github.com:theforeman/foreman_remote_execution.git public'
|
23
|
+
end
|
24
|
+
Dir.chdir('public') do
|
25
|
+
sh 'git fetch --all'
|
26
|
+
sh 'git checkout gh-pages'
|
27
|
+
sh 'git reset --hard origin/gh-pages'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
task :build => :plantuml_install do
|
32
|
+
sh 'jekyll build'
|
33
|
+
end
|
34
|
+
|
35
|
+
task :publish => [:fetch, :build] do
|
36
|
+
Dir.chdir('public') do
|
37
|
+
sh 'git add -A .'
|
38
|
+
sh 'git commit -m Update'
|
39
|
+
sh 'git push'
|
40
|
+
end
|
41
|
+
end
|
data/doc/_config.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
name: Formean Remote Execution
|
3
|
+
title: Foreman Remote Execution
|
4
|
+
url: http://theforeman.github.io
|
5
|
+
baseurl: /foreman_remote_execution/
|
6
|
+
markdown: redcarpet
|
7
|
+
highlighter: pygments
|
8
|
+
|
9
|
+
source: ./source
|
10
|
+
destination: ./public
|
11
|
+
plugins: ./plugins
|
12
|
+
include:
|
13
|
+
- .nojekyll
|
14
|
+
|
15
|
+
tag_page_layout: tag_page
|
16
|
+
tag_page_dir: tag
|
17
|
+
|
18
|
+
permalink: /blog/:year/:month/:day/:title/
|
19
|
+
|
20
|
+
sass:
|
21
|
+
sass_dir: _sass
|
22
|
+
|
23
|
+
redcarpet:
|
24
|
+
extensions:
|
25
|
+
- with_toc_data
|
26
|
+
- html_toc
|
27
|
+
- strikethrough
|
28
|
+
|
29
|
+
plantuml:
|
30
|
+
plantuml_jar: .bin/plantuml.jar # path to plantuml jar
|
31
|
+
tmp_folder: tmp # tmp folder to put generated image files
|
32
|
+
background_color: transparent # [optional] UML image background color
|
33
|
+
# dot_exe: /usr/local/bin/dot # [optional] path to Graphviz dot execution
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'div_tag'
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class AlertBlock < DivTag
|
5
|
+
def initialize(tag_name, markup, tokens)
|
6
|
+
@alert_type = tag_name.split('_').first
|
7
|
+
super tag_name, markup + ' alert alert-' + @alert_type, tokens
|
8
|
+
end
|
9
|
+
|
10
|
+
def tag
|
11
|
+
'div'
|
12
|
+
end
|
13
|
+
|
14
|
+
HEADER = { 'info' => 'Note',
|
15
|
+
'warning' => 'Warning',
|
16
|
+
'danger' => 'Danger' }
|
17
|
+
|
18
|
+
def render_content(context, content)
|
19
|
+
super context, "**#{HEADER[@alert_type]}** \n" + content
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Liquid::Template.register_tag('info_block', Jekyll::AlertBlock)
|
25
|
+
Liquid::Template.register_tag('warning_block', Jekyll::AlertBlock)
|
26
|
+
Liquid::Template.register_tag('danger_block', Jekyll::AlertBlock)
|
27
|
+
# Liquid::Template.register_tag('success_block', Jekyll::AlertBlock)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class DivTag < Liquid::Block
|
3
|
+
def render(context)
|
4
|
+
content = super
|
5
|
+
|
6
|
+
<<-HTML.gsub(/^ +\|/, '')
|
7
|
+
|<#{tag} class="#{@markup}">
|
8
|
+
| #{render_content context, content}
|
9
|
+
|</#{tag}>
|
10
|
+
HTML
|
11
|
+
end
|
12
|
+
|
13
|
+
def tag
|
14
|
+
@tag_name.split('_').first
|
15
|
+
end
|
16
|
+
|
17
|
+
def render_content(context, content)
|
18
|
+
context.registers[:site].converters.find { |c| c.is_a? Jekyll::Converters::Markdown }.convert(content)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Liquid::Template.register_tag('div_tag', Jekyll::DivTag)
|
24
|
+
Liquid::Template.register_tag('span_tag', Jekyll::DivTag)
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# taken from https://raw.githubusercontent.com/kui/octopress-graphviz/master/graphviz_block.rb
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
class GraphvizBlock < Liquid::Block
|
7
|
+
|
8
|
+
DIV_CLASS_ATTR = 'graphviz-wrapper'
|
9
|
+
DEFAULT_GRAPH_NAME = 'Graphviz'
|
10
|
+
DOT_OPTS = '-Tsvg'
|
11
|
+
DOT_EXEC = 'dot'
|
12
|
+
DOT_EXTS = (ENV['PATHEXT'] || '.exe;.bat;.com').split(";")
|
13
|
+
DOT_EXTS.unshift ''
|
14
|
+
DOT_PATH = ENV['PATH'].split(File::PATH_SEPARATOR)
|
15
|
+
.map { |a| File.join a, DOT_EXEC }
|
16
|
+
.map { |a| DOT_EXTS.map { |ex| a+ex } }.flatten
|
17
|
+
.find { |c| File.executable_real? c }
|
18
|
+
raise "not found a executable file: #{DOT_EXEC}" if DOT_PATH.nil?
|
19
|
+
DOT_CMD = "#{DOT_PATH} #{DOT_OPTS}"
|
20
|
+
|
21
|
+
def initialize(tag_name, markup, tokens)
|
22
|
+
super
|
23
|
+
@tag_name = tag_name
|
24
|
+
|
25
|
+
@title = markup or ""
|
26
|
+
@title.strip!
|
27
|
+
|
28
|
+
@src = ""
|
29
|
+
end
|
30
|
+
|
31
|
+
def render(context)
|
32
|
+
code = super
|
33
|
+
title = if @title.empty? then
|
34
|
+
DEFAULT_GRAPH_NAME
|
35
|
+
else
|
36
|
+
@title
|
37
|
+
end
|
38
|
+
|
39
|
+
case @tag_name
|
40
|
+
when 'graphviz' then
|
41
|
+
render_graphviz code
|
42
|
+
when 'graph' then
|
43
|
+
render_graph 'graph', title, code
|
44
|
+
when 'digraph' then
|
45
|
+
render_graph 'digraph', title, code
|
46
|
+
else
|
47
|
+
raise "unknown liquid tag name: #{@tag_name}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def render_graphviz(code)
|
52
|
+
@src = code
|
53
|
+
svg = generate_svg code
|
54
|
+
filter_for_inline_svg svg
|
55
|
+
end
|
56
|
+
|
57
|
+
def filter_for_inline_svg(code)
|
58
|
+
code = remove_declarations code
|
59
|
+
code = remove_xmlns_attrs code
|
60
|
+
code = add_desc_attrs code
|
61
|
+
code = insert_desc_elements code
|
62
|
+
code = wrap_with_div code
|
63
|
+
code = code.gsub /<polygon fill="white" stroke="none"/, '<polygon fill="transparent" stroke="none"'
|
64
|
+
code
|
65
|
+
end
|
66
|
+
|
67
|
+
def generate_svg code
|
68
|
+
Open3.popen3(DOT_CMD) do |stdin, stdout, stderr|
|
69
|
+
stdout.binmode
|
70
|
+
stdin.print code
|
71
|
+
stdin.close
|
72
|
+
|
73
|
+
err = stderr.read
|
74
|
+
if not (err.nil? || err.strip.empty?)
|
75
|
+
raise "Error from #{DOT_CMD}:\n#{err}"
|
76
|
+
end
|
77
|
+
|
78
|
+
svg = stdout.read
|
79
|
+
svg.force_encoding 'UTF-8'
|
80
|
+
|
81
|
+
return svg
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def remove_declarations(svg)
|
86
|
+
svg.sub(/<!DOCTYPE .+?>/im, '').sub(/<\?xml .+?\?>/im, '')
|
87
|
+
end
|
88
|
+
|
89
|
+
def remove_xmlns_attrs(svg)
|
90
|
+
svg.sub(%[xmlns="http://www.w3.org/2000/svg"], '')
|
91
|
+
.sub(%[xmlns:xlink="http://www.w3.org/1999/xlink"], '')
|
92
|
+
end
|
93
|
+
|
94
|
+
def add_desc_attrs(svg)
|
95
|
+
svg.sub!("<svg", %[<svg aria-label="#{CGI::escapeHTML @title}"])
|
96
|
+
svg.sub!("<svg", %[<svg role="img"])
|
97
|
+
|
98
|
+
return svg
|
99
|
+
end
|
100
|
+
|
101
|
+
def insert_desc_elements(svg)
|
102
|
+
inserted_elements = %[<title>#{CGI::escapeHTML @title}</title>\n]
|
103
|
+
inserted_elements << %[<desc>#{CGI::escapeHTML @src}</desc>\n]
|
104
|
+
svg.sub!(/(<svg [^>]*>)/, "\\1\n#{inserted_elements}")
|
105
|
+
|
106
|
+
return svg
|
107
|
+
end
|
108
|
+
|
109
|
+
def wrap_with_div(svg)
|
110
|
+
%[<div class="#{DIV_CLASS_ATTR}">#{svg}</div>]
|
111
|
+
end
|
112
|
+
|
113
|
+
def render_graph(type, title, code)
|
114
|
+
render_graphviz %[#{type} "#{title}" { #{code} }]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
Liquid::Template.register_tag('graphviz', Jekyll::GraphvizBlock)
|
120
|
+
Liquid::Template.register_tag('graph', Jekyll::GraphvizBlock)
|
121
|
+
Liquid::Template.register_tag('digraph', Jekyll::GraphvizBlock)
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Title: PlantUML Code Blocks for Jekyll
|
2
|
+
# Author: YJ Park (yjpark@gmail.com)
|
3
|
+
# https://github.com/yjpark/jekyll-plantuml
|
4
|
+
# Description: Integrate PlantUML into Jekyll and Octopress.
|
5
|
+
#
|
6
|
+
# Syntax:
|
7
|
+
# {% plantuml %}
|
8
|
+
# plantuml code
|
9
|
+
# {% endplantuml %}
|
10
|
+
#
|
11
|
+
require 'open3'
|
12
|
+
require 'fileutils'
|
13
|
+
|
14
|
+
module Jekyll
|
15
|
+
|
16
|
+
class PlantUMLBlock < Liquid::Block
|
17
|
+
attr_reader :config
|
18
|
+
|
19
|
+
def render(context)
|
20
|
+
site = context.registers[:site]
|
21
|
+
self.config = site.config['plantuml']
|
22
|
+
|
23
|
+
tmproot = File.expand_path(tmp_folder)
|
24
|
+
folder = "/images/plantuml/"
|
25
|
+
create_tmp_folder(tmproot, folder)
|
26
|
+
|
27
|
+
code = @nodelist.join + background_color
|
28
|
+
filename = Digest::MD5.hexdigest(code) + ".png"
|
29
|
+
filepath = tmproot + folder + filename
|
30
|
+
if !File.exist?(filepath)
|
31
|
+
plantuml_jar = File.expand_path(plantuml_jar_path)
|
32
|
+
cmd = "java -Djava.awt.headless=true -jar " + plantuml_jar + dot_cmd + " -pipe > " + filepath
|
33
|
+
result, status = Open3.capture2e(cmd, :stdin_data=>code)
|
34
|
+
Jekyll.logger.debug(filepath + " -->\t" + status.inspect() + "\t" + result)
|
35
|
+
end
|
36
|
+
|
37
|
+
site.static_files << Jekyll::StaticFile.new(site, tmproot, folder, filename)
|
38
|
+
|
39
|
+
"<img src='" + "#{ site.baseurl }/" + folder + filename + "'>"
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def config=(cfg)
|
45
|
+
@config = cfg || Jekyll.logger.abort_with("Missing 'plantuml' configurations.")
|
46
|
+
end
|
47
|
+
|
48
|
+
def background_color
|
49
|
+
config['background_color'].nil? ? '' : " skinparam backgroundColor " + config['background_color']
|
50
|
+
end
|
51
|
+
|
52
|
+
def plantuml_jar_path
|
53
|
+
config['plantuml_jar'] || Jekyll.logger.abort_with("Missing configuration 'plantuml.plantuml_jar'.")
|
54
|
+
end
|
55
|
+
|
56
|
+
def tmp_folder
|
57
|
+
config['tmp_folder'] || Jekyll.logger.abort_with("Missing configuration 'plantuml.tmp_folder'.")
|
58
|
+
end
|
59
|
+
|
60
|
+
def dot_cmd
|
61
|
+
@dot_cmd ||= begin
|
62
|
+
dotpath = File.expand_path(config['dot_exe'] || '__NULL__')
|
63
|
+
if File.exist?(dotpath)
|
64
|
+
# Jekyll.logger.info("PlantUML: Use graphviz dot: " + dotpath)
|
65
|
+
" -graphvizdot " + dotpath
|
66
|
+
else
|
67
|
+
# Jekyll.logger.info("PlantUML: Assume graphviz dot is in PATH.")
|
68
|
+
''
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def create_tmp_folder(tmproot, folder)
|
74
|
+
folderpath = tmproot + folder
|
75
|
+
if !File.exist?(folderpath)
|
76
|
+
FileUtils::mkdir_p folderpath
|
77
|
+
Jekyll.logger.info("Create PlantUML image folder: " + folderpath)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end # PlantUMLBlock
|
82
|
+
end
|
83
|
+
|
84
|
+
Liquid::Template.register_tag('plantuml', Jekyll::PlantUMLBlock)
|
data/doc/plugins/play.rb
ADDED
data/doc/plugins/tags.rb
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
require 'nuggets/range/quantile'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
|
6
|
+
class Tagger < Generator
|
7
|
+
|
8
|
+
safe true
|
9
|
+
|
10
|
+
attr_accessor :site
|
11
|
+
|
12
|
+
@types = [:page, :feed]
|
13
|
+
|
14
|
+
class << self; attr_accessor :types, :site; end
|
15
|
+
|
16
|
+
def generate(site)
|
17
|
+
self.class.site = self.site = site
|
18
|
+
|
19
|
+
generate_tag_pages
|
20
|
+
add_tag_cloud
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Generates a page per tag and adds them to all the pages of +site+.
|
26
|
+
# A <tt>tag_page_layout</tt> have to be defined in your <tt>_config.yml</tt>
|
27
|
+
# to use this.
|
28
|
+
def generate_tag_pages
|
29
|
+
active_tags.each { |tag, posts| new_tag(tag, posts) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def new_tag(tag, posts)
|
33
|
+
self.class.types.each { |type|
|
34
|
+
if layout = site.config["tag_#{type}_layout"]
|
35
|
+
data = { 'layout' => layout, 'posts' => posts.sort.reverse!, 'tag' => tag, 'title' => tag }
|
36
|
+
|
37
|
+
name = yield data if block_given?
|
38
|
+
name ||= tag
|
39
|
+
|
40
|
+
tag_dir = site.config["tag_#{type}_dir"]
|
41
|
+
tag_dir = File.join(tag_dir, (pretty? ? name : ''))
|
42
|
+
|
43
|
+
page_name = "#{pretty? ? 'index' : name}#{site.layouts[data['layout']].ext}"
|
44
|
+
|
45
|
+
site.pages << TagPage.new(
|
46
|
+
site, site.source, tag_dir, page_name, data
|
47
|
+
)
|
48
|
+
end
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_tag_cloud(num = 5, name = 'tag_data')
|
53
|
+
s, t = site, { name => calculate_tag_cloud(num) }
|
54
|
+
s.respond_to?(:add_payload) ? s.add_payload(t) : s.config.update(t)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Calculates the css class of every tag for a tag cloud. The possible
|
58
|
+
# classes are: set-1..set-5.
|
59
|
+
#
|
60
|
+
# [[<TAG>, <CLASS>], ...]
|
61
|
+
def calculate_tag_cloud(num = 5)
|
62
|
+
range = 0
|
63
|
+
|
64
|
+
tags = active_tags.map { |tag, posts|
|
65
|
+
[tag.to_s, range < (size = posts.size) ? range = size : size]
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
range = 1..range
|
70
|
+
|
71
|
+
tags.sort!.map! { |tag, size| [tag, range.quantile(size, num)] }
|
72
|
+
end
|
73
|
+
|
74
|
+
def active_tags
|
75
|
+
return site.tags unless site.config["ignored_tags"]
|
76
|
+
site.tags.reject { |t| site.config["ignored_tags"].include? t[0] }
|
77
|
+
end
|
78
|
+
|
79
|
+
def pretty?
|
80
|
+
@pretty ||= (site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty')
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
class TagPage < Page
|
86
|
+
|
87
|
+
def initialize(site, base, dir, name, data = {})
|
88
|
+
self.content = data.delete('content') || ''
|
89
|
+
self.data = data
|
90
|
+
|
91
|
+
super(site, base, dir[-1, 1] == '/' ? dir : '/' + dir, name)
|
92
|
+
end
|
93
|
+
|
94
|
+
def read_yaml(*)
|
95
|
+
# Do nothing
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
module Filters
|
101
|
+
|
102
|
+
def tag_cloud(site)
|
103
|
+
active_tag_data.map { |tag, set|
|
104
|
+
tag_link(tag, tag_url(tag), :class => "set-#{set} label label-default")
|
105
|
+
}.join(' ')
|
106
|
+
end
|
107
|
+
|
108
|
+
def tag_link(tag, url = tag_url(tag), html_opts = nil)
|
109
|
+
html_opts &&= ' ' << html_opts.map { |k, v| %Q{#{k}="#{v}"} }.join(' ')
|
110
|
+
%Q{<a href="#{url}"#{html_opts}>#{tag}</a>}
|
111
|
+
end
|
112
|
+
|
113
|
+
def tag_url(tag, type = :page, site = Tagger.site)
|
114
|
+
# FIXME generate full url for atom.xml page
|
115
|
+
url = File.join('', site.config["tag_#{type}_dir"], ERB::Util.u(tag))
|
116
|
+
site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty' ? url : url << '.html'
|
117
|
+
end
|
118
|
+
|
119
|
+
def tags(obj)
|
120
|
+
tags = obj['tags'].dup
|
121
|
+
tags.map! { |t| t.first } if tags.first.is_a?(Array)
|
122
|
+
tags.map! { |t| tag_link(t, tag_url(t), rel: 'tag', class: 'label label-default') if t.is_a?(String) }.compact!
|
123
|
+
tags.join(' ')
|
124
|
+
end
|
125
|
+
|
126
|
+
def keywords(obj)
|
127
|
+
return '' if not obj['tags']
|
128
|
+
tags = obj['tags'].dup
|
129
|
+
tags.join(',')
|
130
|
+
end
|
131
|
+
|
132
|
+
def active_tag_data(site = Tagger.site)
|
133
|
+
return site.config['tag_data'] unless site.config["ignored_tags"]
|
134
|
+
site.config["tag_data"].reject { |tag, set| site.config["ignored_tags"].include? tag }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
data/doc/plugins/toc.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module FancyToCFilter
|
3
|
+
def fancytoc(input)
|
4
|
+
|
5
|
+
converter = @context.registers[:site].converters.find { |c| c.is_a? Jekyll::Converters::Markdown }
|
6
|
+
extensions = converter.instance_variable_get(:@parser).instance_variable_get(:@redcarpet_extensions)
|
7
|
+
toc_generator = Redcarpet::Markdown.new(Redcarpet::Render::HTML_TOC, extensions)
|
8
|
+
toc = toc_generator.render(input)
|
9
|
+
|
10
|
+
<<-HTML unless toc.empty?
|
11
|
+
<div class="toc well" data-spy="affix" data-offset-top="0" data-offset-bottom="0">
|
12
|
+
<h4>Table of content</h4>
|
13
|
+
#{toc}
|
14
|
+
</div>
|
15
|
+
HTML
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Liquid::Template.register_filter(Jekyll::FancyToCFilter)
|
data/doc/source/404.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="footer">
|
2
|
+
<div class="container">
|
3
|
+
<p>This web site is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_GB">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>. Source available: <a xmlns:dct="http://purl.org/dc/terms/" href="https://github.com/theforeman/theforeman.org" rel="dct:source">github/theforeman/theforeman.org</a>.</p>
|
4
|
+
<a href="https://plus.google.com/102496134326414788199" rel="publisher">Google+ community</a>
|
5
|
+
</div>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<script type="text/javascript">
|
9
|
+
var _gaq = _gaq || [];
|
10
|
+
_gaq.push(['_setAccount', 'UA-2134730-5']);
|
11
|
+
_gaq.push(['_trackPageview']);
|
12
|
+
|
13
|
+
(function() {
|
14
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
15
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
16
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
17
|
+
})();
|
18
|
+
</script>
|
19
|
+
|
20
|
+
</body>
|
21
|
+
</html>
|