Example #1
0
def generate_js(input_filenames):
  load_sequence = parse_deps.calc_load_sequence(input_filenames, srcdir)

  js_chunks = [js_warning_message, '\n']
  js_chunks.append("window.FLATTENED = {};\n")
  js_chunks.append("window.FLATTENED_RAW_SCRIPTS = {};\n")

  for module in load_sequence:
    js_chunks.append("window.FLATTENED['%s'] = true;\n" % module.name)
    for raw_script in module.dependent_raw_scripts:
      js_chunks.append("window.FLATTENED_RAW_SCRIPTS['%s'] = true;\n" %
                       raw_script.name)

  raw_scripts_that_have_been_written = set()
  for module in load_sequence:
    for raw_script in module.dependent_raw_scripts:
      if raw_script.name in raw_scripts_that_have_been_written:
        continue
      js_chunks.append(raw_script.contents)
      js_chunks.append("\n")
      raw_scripts_that_have_been_written.add(raw_script.name)
    js_chunks.append(module.contents)
    js_chunks.append("\n")

  return ''.join(js_chunks)
Example #2
0
def generate_css(input_filenames):
  load_sequence = parse_deps.calc_load_sequence(input_filenames, srcdir)

  style_sheet_chunks = [css_warning_message, '\n']
  for module in load_sequence:
    for style_sheet in module.style_sheets:
      style_sheet_chunks.append("""%s\n""" % style_sheet.contents)

  return ''.join(style_sheet_chunks)
Example #3
0
 def update_deps_and_templates(self):
   current_time = time.time()
   if self.next_deps_check >= current_time:
     return
   print 'Regenerating deps and templates'
   all_js_module_filenames = find_all_js_module_filenames([src_dir])
   load_sequence = parse_deps.calc_load_sequence(
       all_js_module_filenames, [src_dir])
   self.deps = generate.generate_deps_js(load_sequence)
   self.templates = generate.generate_html_for_combined_templates(
       load_sequence)
   self.next_deps_check = current_time + DEPS_CHECK_DELAY