Loading lib/jsduck/assets.rb +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ module JsDuck @images = Images.new(@opts.images) @welcome = Welcome.create(@opts.welcome) @guides = Guides.create(@opts.guides, DocFormatter.new(@relations, @opts)) @guides = Guides.create(@opts.guides, DocFormatter.new(@relations, @opts), @opts) @videos = Videos.create(@opts.videos) @examples = Examples.create(@opts.examples, @opts) @categories = Categories.create(@opts.categories_path, DocFormatter.new(@relations, @opts), @relations) Loading lib/jsduck/guides.rb +20 −3 Original line number Diff line number Diff line Loading @@ -10,20 +10,21 @@ module JsDuck # Reads in guides and converts them to JsonP files class Guides < GroupedAsset # Creates Guides object from filename and formatter def self.create(filename, formatter) def self.create(filename, formatter, opts) if filename Guides.new(filename, formatter) Guides.new(filename, formatter, opts) else NullObject.new(:to_array => [], :to_html => "", :[] => nil) end end # Parses guides config file def initialize(filename, formatter) def initialize(filename, formatter, opts) @path = File.dirname(filename) @groups = JsonDuck.read(filename) build_map_by_name("Two guides have the same name") @formatter = formatter @opts = opts end # Writes all guides to given dir in JsonP format Loading @@ -47,6 +48,9 @@ module JsDuck # Copy the whole guide dir over FileUtils.cp_r(in_dir, out_dir) # Ensure the guide has an icon fix_icon(out_dir) @formatter.doc_context = {:filename => guide_file, :linenr => 0} name = File.basename(in_dir) @formatter.img_path = "guides/#{name}" Loading @@ -55,6 +59,19 @@ module JsDuck JsonDuck.write_jsonp(out_dir+"/README.js", name, {:guide => html, :title => guide["title"]}) end # Ensures the guide dir contains icon.png. # When there isn't looks for icon-lg.png and renames it to icon.png. # When neither exists, copies over default icon. def fix_icon(dir) if File.exists?(dir+"/icon.png") # All ok elsif File.exists?(dir+"/icon-lg.png") FileUtils.mv(dir+"/icon-lg.png", dir+"/icon.png") else FileUtils.cp(@opts.template_dir+"/resources/images/default-guide.png", dir+"/icon.png") end end # Creates table of contents at the top of guide by looking for <h2> elements in HTML. def add_toc(guide, html) toc = [ Loading template/app/view/guides/Index.js +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ Ext.define('Docs.view.guides.Index', { { xtype: 'container', html: '<h1 class="eg">Guides</h1>' }, Ext.create('Docs.view.ThumbList', { itemTpl: [ '<dd ext:url="#!/guide/{name}"><div class="thumb"><img src="guides/{name}/icon-lg.png"/></div>', '<dd ext:url="#!/guide/{name}"><div class="thumb"><img src="guides/{name}/icon.png"/></div>', '<div><h4>{title}</h4><p>{description}</p></div>', '</dd>' ], Loading template/resources/images/default-guide.png 0 → 100644 +12.9 KiB Loading image diff... Loading
lib/jsduck/assets.rb +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ module JsDuck @images = Images.new(@opts.images) @welcome = Welcome.create(@opts.welcome) @guides = Guides.create(@opts.guides, DocFormatter.new(@relations, @opts)) @guides = Guides.create(@opts.guides, DocFormatter.new(@relations, @opts), @opts) @videos = Videos.create(@opts.videos) @examples = Examples.create(@opts.examples, @opts) @categories = Categories.create(@opts.categories_path, DocFormatter.new(@relations, @opts), @relations) Loading
lib/jsduck/guides.rb +20 −3 Original line number Diff line number Diff line Loading @@ -10,20 +10,21 @@ module JsDuck # Reads in guides and converts them to JsonP files class Guides < GroupedAsset # Creates Guides object from filename and formatter def self.create(filename, formatter) def self.create(filename, formatter, opts) if filename Guides.new(filename, formatter) Guides.new(filename, formatter, opts) else NullObject.new(:to_array => [], :to_html => "", :[] => nil) end end # Parses guides config file def initialize(filename, formatter) def initialize(filename, formatter, opts) @path = File.dirname(filename) @groups = JsonDuck.read(filename) build_map_by_name("Two guides have the same name") @formatter = formatter @opts = opts end # Writes all guides to given dir in JsonP format Loading @@ -47,6 +48,9 @@ module JsDuck # Copy the whole guide dir over FileUtils.cp_r(in_dir, out_dir) # Ensure the guide has an icon fix_icon(out_dir) @formatter.doc_context = {:filename => guide_file, :linenr => 0} name = File.basename(in_dir) @formatter.img_path = "guides/#{name}" Loading @@ -55,6 +59,19 @@ module JsDuck JsonDuck.write_jsonp(out_dir+"/README.js", name, {:guide => html, :title => guide["title"]}) end # Ensures the guide dir contains icon.png. # When there isn't looks for icon-lg.png and renames it to icon.png. # When neither exists, copies over default icon. def fix_icon(dir) if File.exists?(dir+"/icon.png") # All ok elsif File.exists?(dir+"/icon-lg.png") FileUtils.mv(dir+"/icon-lg.png", dir+"/icon.png") else FileUtils.cp(@opts.template_dir+"/resources/images/default-guide.png", dir+"/icon.png") end end # Creates table of contents at the top of guide by looking for <h2> elements in HTML. def add_toc(guide, html) toc = [ Loading
template/app/view/guides/Index.js +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ Ext.define('Docs.view.guides.Index', { { xtype: 'container', html: '<h1 class="eg">Guides</h1>' }, Ext.create('Docs.view.ThumbList', { itemTpl: [ '<dd ext:url="#!/guide/{name}"><div class="thumb"><img src="guides/{name}/icon-lg.png"/></div>', '<dd ext:url="#!/guide/{name}"><div class="thumb"><img src="guides/{name}/icon.png"/></div>', '<div><h4>{title}</h4><p>{description}</p></div>', '</dd>' ], Loading