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

Let examples also have "title" and "description".

Previously these fields were named "text" and "desc" which was
different from guides and videos for no actual reason.

We still support the old field names for backwards compatibility.
parent bf8099c8
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -24,12 +24,26 @@ module JsDuck
    end

    # Prefix all relative URL-s in examples list with path given in --examples-base-url
    # Create names for each example when not present
    #
    # For backwards compatibility:
    #
    # - Create names for each example when not present
    # - Create title from text
    # - Create description from desc
    #
    def fix_examples_data
      each_item do |ex|
        unless ex["url"] =~ /^https?:\/\//
          ex["url"] = @opts.examples_base_url + ex["url"]
          ex["name"] = ex["url"] unless ex["name"]
          unless ex["title"]
            ex["title"] = ex["text"]
            ex.delete("text")
          end
          unless ex["description"]
            ex["description"] = ex["desc"]
            ex.delete("desc")
          end
        end
      end
    end
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ Ext.define('Docs.view.TreeContainer', {
                convert: function(example) {
                    return {
                        leaf: true,
                        text: example.text,
                        text: example.title,
                        url: '#!/example/' + example.name,
                        iconCls: 'icon-example'
                    };
+2 −2
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ Ext.define('Docs.view.examples.Index', {
                itemTpl: [
                    '<dd ext:url="#!/example/{name}">',
                        '<div class="thumb"><img src="'+baseUrl+'/{icon}"/></div>',
                        '<div><h4>{text}',
                        '<div><h4>{title}',
                            '<tpl if="status === \'new\'">',
                                '<span class="new-sample"> (New)</span>',
                            '</tpl>',
@@ -36,7 +36,7 @@ Ext.define('Docs.view.examples.Index', {
                            '<tpl if="status === \'experimental\'">',
                                '<span class="new-sample"> (Experimental)</span>',
                            '</tpl>',
                        '</h4><p>{desc}</p></div>',
                        '</h4><p>{description}</p></div>',
                    '</dd>'
                ],
                data: Docs.data.examples