Commit ec5391c9 authored by Nick Poulden's avatar Nick Poulden
Browse files

Relative example URLs for exported docs

parent 2b4e9ada
Loading
Loading
Loading
Loading
+27 −2
Original line number Diff line number Diff line
@@ -154,12 +154,37 @@ class JsDuckRunner
    @options += options
  end

  def add_sdk
  def add_sdk(mode = nil)

    head_html = <<-EOHTML
      <link rel="canonical" href="http://docs.sencha.com/ext-js/4-0/" />
      <meta name="description" content="Ext JS 4.0 API Documentation from Sencha. Class documentation, Guides and Videos on how to create Javascript applications with Ext JS 4">
    EOHTML

    if mode == 'export'

      relative_sdk_path = "../"

      ["template-min/extIframe.html", "template-min/welcome.html"].each do |file|
        html = IO.read(file);

        out = []

        html.each_line do |line|
          out << line.sub(/((src|href)="extjs\/)/, '\2="' + relative_sdk_path)
        end

        File.open(file, 'w') {|f| f.write(out) }
      end

      head_html = <<-EOHTML
        <script type="text/javascript">
          Docs.exampleBaseUrl = "#{relative_sdk_path}examples/";
        </script>
      EOHTML

    end

    @options += [
      "--title", "Sencha Docs - Ext JS 4.0",
      "--head-html", head_html,
@@ -515,7 +540,7 @@ task :sdk, [:mode] => :sass do |t, args|
  compress if mode == "export" || mode == "live"

  runner = JsDuckRunner.new
  runner.add_sdk
  runner.add_sdk(mode)
  runner.add_debug if mode == "debug"
  runner.add_seo if mode == "debug" || mode == "live"
  runner.add_sdk_export_notice if mode == "export"
+8 −1
Original line number Diff line number Diff line
@@ -8,11 +8,17 @@ Ext.define('Docs.view.examples.Container', {
    alias: 'widget.examplecontainer',
    layout: 'fit',

    exampleBaseUrl: "extjs/examples/",

    initComponent: function() {
        this.tpl = new Ext.XTemplate(
            '<iframe style="width: 100%; height: 100%; border: 0;" src="extjs/examples/{url}"></iframe>'
            '<iframe style="width: 100%; height: 100%; border: 0;" src="{baseUrl}{url}"></iframe>'
        );

        if (Docs.exampleBaseUrl) {
            this.exampleBaseUrl = Docs.exampleBaseUrl;
        }

        this.callParent(arguments);
    },

@@ -21,6 +27,7 @@ Ext.define('Docs.view.examples.Container', {
     * @param {Object} example Example object
     */
    load: function(example) {
        example.baseUrl = this.exampleBaseUrl;
        this.update(this.tpl.apply(example));
    },

+4 −2
Original line number Diff line number Diff line
@@ -13,10 +13,12 @@ Ext.define('Docs.view.examples.Index', {
    autoScroll: true,

    initComponent: function() {

        this.cls += Docs.touchExamplesUi ? " touch-examples-ui" : "";
        var touchExampleRoot = Docs.exampleBaseUrl ? Docs.exampleBaseUrl : "touch/examples";

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

        this.items = [
            { xtype: 'container', html: '<h1 class="eg">Examples</h1>' },