guider 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rspec'
4
+ require 'rspec/core/rake_task'
5
+
6
+ # prints command to standard out and executes it
7
+ def echo_cmd(cmd)
8
+ puts cmd
9
+ system cmd
10
+ end
11
+
12
+ desc "Bumps Guider minor version number"
13
+ task :bump do
14
+ # Extract version number and increment it
15
+ version_line = IO.read("guider.gemspec").lines.grep(/s\.version = /)[0]
16
+ version_line =~ /([0-9]+)\.([0-9]+).([0-9]+)/
17
+ old_version = "#{$1}.#{$2}.#{$3}"
18
+ new_version = "#{$1}.#{$2}.#{$3.to_i + 1}"
19
+ puts "Bumping from #{old_version} to #{new_version}"
20
+
21
+ # Replace it in guider.gemspec
22
+ contents = IO.read("guider.gemspec")
23
+ contents.sub!(/s\.version = '#{old_version}'/, "s.version = '#{new_version}'")
24
+ File.open("guider.gemspec", "w") {|f| f.write(contents) }
25
+
26
+ # Replace it in bin/guider
27
+ contents = IO.read("bin/guider")
28
+ contents.sub!(/VERSION = '#{old_version}'/, "VERSION = '#{new_version}'")
29
+ File.open("bin/guider", "w") {|f| f.write(contents) }
30
+
31
+ # Create a commit
32
+ echo_cmd("git commit guider.gemspec bin/guider -m 'Up version to #{new_version}.'")
33
+ # Create a tag
34
+ echo_cmd("git tag -a v#{new_version} -m 'Tagging #{new_version} release.'")
35
+ end
36
+
37
+ desc "Build Guider gem"
38
+ task :gem do
39
+ system "gem build guider.gemspec"
40
+ end
41
+
42
+ RSpec::Core::RakeTask.new(:spec) do |spec|
43
+ spec.rspec_opts = ["--color"]
44
+ spec.pattern = "spec/**/*_spec.rb"
45
+ end
46
+
47
+ task :default => :spec
data/bin/guider CHANGED
@@ -7,8 +7,18 @@ require "rubygems"
7
7
  require "optparse"
8
8
  require "guider/app"
9
9
 
10
+ VERSION = '0.0.6'
11
+
12
+ def format_footer(text)
13
+ guider = "<a href='https://github.com/nene/guider'>Guider</a>"
14
+ date = Time.new.strftime('%a %d %b %Y %H:%M:%S')
15
+ text.gsub(/\{VERSION\}/, VERSION).gsub(/\{GUIDER\}/, guider).gsub(/\{DATE\}/, date)
16
+ end
17
+
10
18
  options = {
11
19
  :output => Dir.pwd + "/out",
20
+ :title => "Guides",
21
+ :footer => format_footer("Generated on {DATE} by {GUIDER} {VERSION}."),
12
22
  :link_url => "http://localhost/extjs/",
13
23
  :tpl_dir => File.dirname(File.dirname(__FILE__)) + "/template",
14
24
  :warnings => false,
@@ -23,6 +33,16 @@ input_files = OptionParser.new do |opts|
23
33
  options[:output] = File.absolute_path(dir)
24
34
  end
25
35
 
36
+ opts.on("--title=TEXT", "The title for the whole set of guides.",
37
+ "Defaults to: Guides.") do |title|
38
+ options[:title] = title
39
+ end
40
+
41
+ opts.on("--footer=TEXT", "The footer text.",
42
+ "Defaults to: Generated on {DATE} by {GUIDER} {VERSION}.") do |footer|
43
+ options[:footer] = format_footer(footer)
44
+ end
45
+
26
46
  opts.on("--link-url=URL", "Base path for links created by {@link} tags.",
27
47
  "Defaults to http://localhost/extjs/") do |url|
28
48
  options[:link_url] = url
@@ -42,7 +62,7 @@ input_files = OptionParser.new do |opts|
42
62
  end
43
63
 
44
64
  opts.on("--version", "Prints guider version number.") do
45
- puts "Guider 0.0.5"
65
+ puts "Guider #{VERSION}"
46
66
  exit
47
67
  end
48
68
  end.parse!
data/guider.gemspec CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
2
2
  s.required_rubygems_version = ">= 1.3.5"
3
3
 
4
4
  s.name = 'guider'
5
- s.version = '0.0.5'
5
+ s.version = '0.0.6'
6
6
  s.date = Time.new.strftime('%Y-%m-%d')
7
7
  s.summary = "Sencha guide generator"
8
8
  s.description = "JSDuck-compatible guides generator"
data/lib/guider/app.rb CHANGED
@@ -46,7 +46,7 @@ module Guider
46
46
 
47
47
  # Copies over main template resources
48
48
  def copy_template_files
49
- Dir[@options[:tpl_dir]+"/*.{js,css,ico}"].each do |fname|
49
+ Dir[@options[:tpl_dir]+"/*.{js,css,ico,png}"].each do |fname|
50
50
  FileUtils.cp(fname, @options[:output])
51
51
  end
52
52
  end
data/lib/guider/config.rb CHANGED
@@ -20,7 +20,7 @@ module Guider
20
20
 
21
21
  items.each do |guide|
22
22
  if guide["items"]
23
- list << "<li>" + guide["title"] + "\n" + to_list(guide["items"]) + "</li>"
23
+ list << "<li><span>" + guide["title"] + "</span>\n" + to_list(guide["items"]) + "</li>"
24
24
  else
25
25
  list << "<li>#{to_link(guide)}</li>"
26
26
  end
data/lib/guider/guide.rb CHANGED
@@ -8,6 +8,7 @@ module Guider
8
8
  @template = tpl
9
9
  @inline_tags = inline_tags
10
10
  @input_filename = filename
11
+ @options = options
11
12
  @markdown = IO.read(filename)
12
13
  @rel_path = relative_path(options[:input], filename)
13
14
  @html = Kramdown::Document.new(@markdown).to_html
@@ -15,10 +16,13 @@ module Guider
15
16
 
16
17
  def write(filename)
17
18
  Logger.context = @input_filename
19
+ @inline_tags.base_url = @rel_path
18
20
  html = @inline_tags.replace(@html)
19
21
  html = @template.apply({
20
22
  :content => html,
21
- :title => title,
23
+ :title => @options[:title],
24
+ :footer => @options[:footer],
25
+ :guide_name => guide_name,
22
26
  :path => @rel_path,
23
27
  })
24
28
  File.open(filename, 'w') {|f| f.write(html) }
@@ -29,7 +33,7 @@ module Guider
29
33
  end
30
34
 
31
35
  # Extracts the first line from markdown
32
- def title
36
+ def guide_name
33
37
  @markdown =~ /\A(.*?)$/
34
38
  result = $1.sub(/^#/, '').strip
35
39
 
data/lib/guider/index.rb CHANGED
@@ -10,7 +10,11 @@ module Guider
10
10
  end
11
11
 
12
12
  def write
13
- html = @tpl.apply(:title => "Guides", :content => @config.to_html)
13
+ html = @tpl.apply({
14
+ :title => @options[:title],
15
+ :footer => @options[:footer],
16
+ :content => @config.to_html,
17
+ })
14
18
  File.open(@options[:output] + "/index.html", 'w') {|f| f.write(html) }
15
19
  end
16
20
 
@@ -4,9 +4,12 @@ module Guider
4
4
  class InlineTags
5
5
  # The base URL for links created by {@link} tags.
6
6
  attr_accessor :link_url
7
+ # The base URL for referencing guides from root dir.
8
+ attr_accessor :base_url
7
9
 
8
10
  def initialize
9
11
  @link_url = ""
12
+ @base_url = "."
10
13
  end
11
14
 
12
15
  def replace(html)
@@ -49,8 +52,12 @@ module Guider
49
52
  end
50
53
 
51
54
  def replace_old_guide_links!(html)
52
- replace!(html, /<a href="#!?\/guide\/(\w+)">/) do |name|
53
- "<a href='../#{name}'>"
55
+ replace!(html, /<a href="#!?\/guide\/([^"]+)">/) do |name|
56
+ # Transform links to .md files into .html file links
57
+ name.sub!(/README\.md$/, "index.html")
58
+ name.sub!(/\.md$/, ".html")
59
+
60
+ "<a href='#{@base_url}/#{name}'>"
54
61
  end
55
62
  end
56
63
 
data/template/guide.html CHANGED
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>{title}</title>
4
+ <title>{guide_name} - {title}</title>
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
6
  <link rel="shortcut icon" type="image/ico" href="{path}/favicon.ico" />
7
7
  <link rel="stylesheet" type="text/css" href="{path}/styles.css" />
@@ -10,7 +10,19 @@
10
10
  </head>
11
11
  <body>
12
12
 
13
+ <div id="container">
14
+ <div id="header">
15
+ <h1><a href="{path}">{title}</a></h1>
16
+ </div>
17
+
18
+ <div id="content">
13
19
  {content}
20
+ </div>
21
+ </div>
22
+
23
+ <div id="footer">
24
+ <p>{footer}</p>
25
+ </div>
14
26
 
15
27
  <script type="text/javascript">
16
28
  (function(){
data/template/index.html CHANGED
@@ -8,9 +8,19 @@
8
8
  </head>
9
9
  <body id="index-page">
10
10
 
11
- <h1>{title}</h1>
11
+ <div id="container">
12
+ <div id="header">
13
+ <h1><a href="{path}">{title}</a></h1>
14
+ </div>
12
15
 
16
+ <div id="content">
13
17
  {content}
18
+ </div>
19
+ </div>
20
+
21
+ <div id="footer">
22
+ <p>{footer}</p>
23
+ </div>
14
24
 
15
25
  <script type="text/javascript">
16
26
  (function(){
Binary file
data/template/styles.css CHANGED
@@ -4,8 +4,8 @@ body {
4
4
  line-height: 1.231;
5
5
  color: #484848;
6
6
  background: #f8f8f8;
7
- max-width: 900px;
8
- margin: 0 auto;
7
+ margin: 0;
8
+ padding: 0;
9
9
  }
10
10
 
11
11
  h1 {
@@ -39,10 +39,62 @@ img {
39
39
  margin: 0 auto;
40
40
  }
41
41
 
42
+ /* Page header and content sections */
43
+
44
+ #header {
45
+ background: #074E7C url(sencha-logo.png) 5px center no-repeat;
46
+ padding-left: 30px;
47
+ }
48
+ #header h1 {
49
+ margin: 0;
50
+ font-size: 16px;
51
+ line-height: 40px;
52
+ }
53
+ #header a {
54
+ color: white;
55
+ }
56
+
57
+ #content {
58
+ max-width: 900px;
59
+ margin: 0 auto;
60
+ padding: 1em;
61
+ }
62
+
63
+ /* Create sticky footer */
64
+ html, body, #container {
65
+ height: 100%;
66
+ }
67
+ body > #container {
68
+ height: auto;
69
+ min-height: 100%;
70
+ }
71
+ #footer {
72
+ clear: both;
73
+ position: relative;
74
+ z-index: 10;
75
+ height: 20px;
76
+ margin-top: -20px;
77
+ }
78
+
79
+ /* Other footer styles */
80
+ #footer {
81
+ text-align: right;
82
+ font-size: 10px;
83
+ width: 100%;
84
+ }
85
+ #footer p {
86
+ padding-right: 20px;
87
+ margin: 0;
88
+ }
42
89
 
43
90
  /* Special styles for guides list in index page */
44
91
 
45
- body#index-page > ul > li {margin-bottom: 0.5em;}
46
- body#index-page > ul > li > ul {margin: 0.5em 0; font-size: smaller;}
47
- body#index-page > ul > li > a:link {font-weight: bold; }
92
+ body#index-page #content > ul > li {margin-bottom: 0.5em; }
93
+ body#index-page #content > ul > li > ul {margin: 0.5em 0; font-size: smaller; }
94
+ body#index-page #content > ul > li > a:link {font-weight: bold; }
48
95
 
96
+ body#index-page #content > ul > li > span {
97
+ color: #66ab16;
98
+ font-family: "Exo", sans-serif;
99
+ font-weight: bold;
100
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guider
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-25 00:00:00.000000000 Z
12
+ date: 2013-03-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: kramdown
@@ -53,6 +53,7 @@ files:
53
53
  - .gitignore
54
54
  - COPYING
55
55
  - README.md
56
+ - Rakefile
56
57
  - bin/guider
57
58
  - guider.gemspec
58
59
  - lib/guider/app.rb
@@ -68,6 +69,7 @@ files:
68
69
  - template/index.html
69
70
  - template/prettify.css
70
71
  - template/prettify.js
72
+ - template/sencha-logo.png
71
73
  - template/styles.css
72
74
  homepage: https://github.com/nene/guider
73
75
  licenses: []