Commit 8e717b35 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add --welcome option to set welcome page content.

The welcome page content is now inside template/welcome.html

Additionally extracted ContentGrabber class that deals with
extracting content from page.
parent 3c841761
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ def run_jsduck(extra_options)
    "ruby", "bin/jsduck",
    # --external=Error to ignore the Error class that Ext.Error extends.
    "--external", "Error",
    "--welcome", "template/welcome.html",
    "--guides", "#{SDK_DIR}/guides/guides.json",
    "--videos", "#{SDK_DIR}/guides/videos.json",
    "--examples", "#{SDK_DIR}/extjs/examples/examples.json",
+7 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ require 'jsduck/exporter'
require 'jsduck/timer'
require 'jsduck/parallel_wrap'
require 'jsduck/logger'
require 'jsduck/welcome'
require 'jsduck/guides'
require 'jsduck/videos'
require 'jsduck/examples'
@@ -46,6 +47,11 @@ module JsDuck
      Aliases.new(@relations).resolve_all
      Lint.new(@relations).run

      @welcome = Welcome.new
      if @opts.welcome
        @timer.time(:parsing) { @welcome.parse(@opts.welcome) }
      end

      @guides = Guides.new(get_doc_formatter)
      if @opts.guides
        @timer.time(:parsing) { @guides.parse(@opts.guides) }
@@ -222,6 +228,7 @@ module JsDuck
      html.gsub!("{footer}", "<div id='footer-content' style='display: none'>#{@footer}</div>")
      html.gsub!("{extjs_path}", @opts.extjs_path)
      html.gsub!("{local_storage_db}", @opts.local_storage_db)
      html.gsub!("{welcome}", @welcome.to_html)
      html.gsub!("{categories}", @categories.to_html)
      html.gsub!("{guides}", @guides.to_html)
      html.gsub!("{head_html}", @opts.head_html)
+7 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ module JsDuck
    attr_accessor :footer
    attr_accessor :head_html
    attr_accessor :body_html
    attr_accessor :welcome
    attr_accessor :guides
    attr_accessor :videos
    attr_accessor :examples
@@ -49,6 +50,7 @@ module JsDuck
      @footer = 'Generated with <a href="https://github.com/senchalabs/jsduck">JSDuck</a>.'
      @head_html = ""
      @body_html = ""
      @welcome = nil
      @guides = nil
      @videos = nil
      @examples = nil
@@ -128,6 +130,11 @@ module JsDuck
          @body_html = html
        end

        opts.on('--welcome=PATH',
          "Path to HTML file with content for welcome page.", " ") do |path|
          @welcome = path
        end

        opts.on('--guides=PATH',
          "Path to JSON file describing the guides. The file",
          "should be in a dir containing the actual guides.",

lib/jsduck/welcome.rb

0 → 100644
+21 −0
Original line number Diff line number Diff line
module JsDuck

  # Reads in HTML file with content for welcome page
  class Welcome
    # Parses welcome HTML file
    def parse(filename)
      @html = IO.read(filename)
    end

    # Returns the HTML
    def to_html
      if @html
        "<div id='welcome-content' style='display:none'>#{@html}</div>"
      else
        ""
      end
    end

  end

end
+21 −0
Original line number Diff line number Diff line
/**
 * Extracts content from elements on page.
 */
Ext.define('Docs.ContentGrabber', {
    singleton: true,

    /**
     * Gets HTML inside the element. Then removes the element.
     * @param {String} id The ID of the element.
     * @return {String} HTML
     */
    get: function(id) {
        var html;
        var el = Ext.get(id);
        if (el) {
            html = el.dom.innerHTML;
            el.remove();
        }
        return html;
    }
});
Loading