briandk / gitvisualizations

A suite of visualization tools for analyzing files in git
http://briandk.com/codetimeline_demos/simulator/simulator.html
3 stars 3 forks source link

Inject CSS and JavaScript into HTML for a unified single Timeline HTML output file #58

Open briandk opened 11 years ago

briandk commented 11 years ago

On the output side of things, we'll loop over a collection using mustache. Here's an example for CSS:

  {{#stylesheets}}  
    <style type="text/css" 
     media="screen" 
     id="{{{filename}}}">
      {{{content}}}
    </style>
  {{/stylesheets}}

On the Python side, each element of the stylesheets array would be a hash (perhaps of type externalFile) like this:

{ filename: " ",
  assetType: " ",
  content: " " }

Then, to create an array of such hashes (for CSS files) it might be something like

TO Create an array of external file hashes
  for pathnames in directory  
  create an externalFile instance
  if pathname extension is "css"

Then I just have to define a class for externalFile that subclasses dict type, and a corresponding __init__ method, like

def __init__(self): # not sure if this should be __init__(self, dict)
    self['filename'] = " "
    self ['assetType'] = " "
    self ['content'] = " "
briandk commented 11 years ago

On second thought, it might be more useful to subclass object so that I'd have fields like this:

class ExternalFile(object):
    def __init__(self):
        self.filename = ""
        self.assetType = ""
        self.content = ""