Commit 20896e51 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Use --examples-base-url also used for icons.

Instead of hardcoding ExtJS and Touch examples paths, the
--examples-base-url option determines where icons are located.

The important change is that examples.json file now has to define
icons relative to --examples-base-url (this was the case for Touch,
but not for ExtJS).

Example title and description fields are now also correctly convered,
independent of url being absolute or not.

Auto-created example name no more contains the --examples-base-url
in it.
parent f65653c3
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -33,9 +33,15 @@ module JsDuck
    #
    def fix_examples_data
      each_item do |ex|
        ex["name"] = ex["url"] unless ex["name"]

        unless ex["url"] =~ /^https?:\/\//
          ex["url"] = @opts.examples_base_url + ex["url"]
          ex["name"] = ex["url"] unless ex["name"]
        end
        unless ex["icon"] =~ /^https?:\/\//
          ex["icon"] = @opts.examples_base_url + ex["icon"]
        end

        unless ex["title"]
          ex["title"] = ex["text"]
          ex.delete("text")
@@ -46,11 +52,10 @@ module JsDuck
        end
      end
    end
    end

    # Extracts example icon URL from example hash
    def icon_url(example)
      @opts.examples_base_url + example["icon"]
      example["icon"]
    end

  end
+1 −6
Original line number Diff line number Diff line
@@ -13,19 +13,14 @@ Ext.define('Docs.view.examples.Index', {
    autoScroll: true,

    initComponent: function() {

        this.cls += Docs.data.touchExamplesUi ? " touch-examples-ui" : "";

        var touchExampleRoot = Docs.exampleBaseUrl || "touch/examples",
            extjsExampleRoot = Docs.exampleBaseUrl || "extjs/examples/",
            baseUrl = Docs.data.touchExamplesUi ? touchExampleRoot : (extjsExampleRoot + "shared/screens");

        this.items = [
            { xtype: 'container', html: '<h1 class="eg">Examples</h1>' },
            Ext.create('Docs.view.ThumbList', {
                itemTpl: [
                    '<dd ext:url="#!/example/{name}">',
                        '<div class="thumb"><img src="'+baseUrl+'/{icon}"/></div>',
                        '<div class="thumb"><img src="{icon}"/></div>',
                        '<div><h4>{title}',
                            '<tpl if="status === \'new\'">',
                                '<span class="new-sample"> (New)</span>',