Commit f7cdbb75 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix print-page stylesheets page in export mode.

Added print-template.html which like template.html gets scanned for
CSS files which then get concatenated.
parent 55feae7e
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -195,20 +195,22 @@ end
# Deletes those input CSS files and writes out concatenated CSS to
# resources/css/app.css
# Finally replaces the CSS section with <link> to that one CSS file.
def combine_css(html, base_dir)
def combine_css(html, base_dir, opts = :write)
  css_section_re = /<!-- BEGIN CSS -->.*<!-- END CSS -->/m
  css = []
  css_section_re.match(html)[0].each_line do |line|
    if line =~ /<link rel="stylesheet" href="(.*?)"/
      file = $1
      css << IO.read(base_dir + "/" + file)
      system("rm", base_dir + "/" + file)
      system("rm", base_dir + "/" + file) if opts == :write
    end
  end

  if opts == :write
    fname = "#{OUT_DIR}/resources/css/app.css"
    File.open(fname, 'w') {|f| f.write(css.join("\n")) }
    yui_compress(fname)
  end
  html.sub(css_section_re, '<link rel="stylesheet" href="resources/css/app.css" type="text/css" />')
end

@@ -252,6 +254,15 @@ task :compress do
  # Remove the entire app/ dir
  system("rm", "-r", "#{OUT_DIR}/app")

  # Optionally concatenate CSS in print-template.html file
  print_template = "#{OUT_DIR}/print-template.html";
  if File.exists?(print_template)
    html = IO.read(print_template);
    # Just modify HTML to link app.css, don't write files.
    html = combine_css(html, OUT_DIR, :replace_html_only)
    File.open(print_template, 'w') {|f| f.write(html) }
  end

  # Concatenate CSS and JS files referenced in index.html file
  html = IO.read(index_html)
  html = combine_css(html, OUT_DIR)
+2 −20
Original line number Diff line number Diff line
@@ -48,26 +48,8 @@ function format_class($cls) {
}

function print_page($title, $body) {
  echo "<!DOCTYPE html>";
  echo '<html>';
  echo "<head>";
  echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
  echo "<meta name=\"description\" content=\"Official ExtJS 4.0 API Documentation for $title from Sencha. Examples, guides, screencasts and comments on how to use $title.\" />";
  echo '<link rel="stylesheet" href="resources/css/reset.css" type="text/css" />';
  echo '<link rel="stylesheet" href="resources/css/docs-ext.css" type="text/css" />';
  echo '<link rel="stylesheet" href="resources/css/viewport.css" type="text/css" />';

  echo "<title>$title | Ext JS 4.0 API Docs | Sencha</title>";
  echo "</head>";
  echo '<body style="background: #fff;">';
  echo '<div id="north-region" style="padding: 1px 0 11px 11px"><div class="logo"><span><a href="http://docs.sencha.com">Sencha Docs</a></span> <a href="http://docs.sencha.com/ext-js/4-0">Ext JS 4.0</a></div></div>';
  echo '<div id="center-container" class="class-overview" style="padding: 20px">';

  echo $body;

  echo '</div>';
  echo "</body>";
  echo "</html>";
  $html = file_get_contents('print-template.html');
  echo preg_replace(array('/\{title}/', '/\{body}/'), array($title, $body), $html);
}

function print_index_page() {
+24 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<meta name=\"description\" content=\"Official ExtJS 4.0 API Documentation for {title} from Sencha. Examples, guides, screencasts and comments on how to use {title}.\" >
<!-- BEGIN CSS -->
<link rel="stylesheet" href="resources/css/reset.css" type="text/css" />
<link rel="stylesheet" href="resources/css/docs-ext.css" type="text/css" />
<link rel="stylesheet" href="resources/css/viewport.css" type="text/css" />
<!-- END CSS -->
<title>{title} | Ext JS 4.0 API Docs | Sencha</title>
</head>
<body style="background: #fff;">
<div id="north-region" style="padding: 1px 0 11px 11px">
  <div class="logo">
    <span><a href="http://docs.sencha.com">Sencha Docs</a></span>
    <a href="http://docs.sencha.com/ext-js/4-0">Ext JS 4.0</a>
  </div>
</div>
<div id="center-container" class="class-overview" style="padding: 20px">
  {body}
</div>
</body>
</html>