diff --git a/settings.py b/settings.py index d3e987a..80513d6 100644 --- a/settings.py +++ b/settings.py @@ -121,11 +121,11 @@ 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', - 'swap' + 'swap', # Uncomment the next line to enable the admin: - # 'django.contrib.admin', + 'django.contrib.admin', # Uncomment the next line to enable admin documentation: - # 'django.contrib.admindocs', + 'django.contrib.admindocs', ) # A sample logging configuration. The only tangible logging diff --git a/swap/util.py b/swap/util.py index 4f622ef..5620b88 100644 --- a/swap/util.py +++ b/swap/util.py @@ -73,16 +73,17 @@ def processPage(page_url): page.url = page_url page.original = page_content page.save() - css_assets = [] + css_stylesheets = [] + css_tags = [] mark("save page") page_content = makeLinksAbsolute(page_content,[u'href',u'src'], page_url) mark("make links absolute") - page_content = parseStyleAttributes(page_content, css_assets, page) + page_content = parseStyleAttributes(page_content, css_stylesheets, page) mark("parse style attributes") - page_content = parseStyleTags(page_content, css_assets, page) + page_content = parseStyleTags(page_content, css_stylesheets, page) mark("parse style tags") - page_content = parseLinkedStylesheets(page_content, css_assets, page) + page_content = parseLinkedStylesheets(page_content, css_stylesheets, page) mark("parse linked stylesheets") clear() @@ -91,7 +92,7 @@ def processPage(page_url): page.save() return page -def parseStyleAttributes(document, css_assets, page): +def parseStyleAttributes(document, css_stylesheets, page): """ Grabs any style="" attributes on normal html tags and saves the CSS therein. Replaces the style with a delimited UUID tag that we can use later to re-insert the style @@ -106,11 +107,11 @@ def parseStyleAttributes(document, css_assets, page): css_content = value.strip("\"' ") css_name = 'style=""'#TODO get the ID attribute from the same tag (could be difficult) css_asset = createCSSAsset(css_content, page, css_types['ATTRIBUTE'], name=css_name) - css_assets.append(css_asset)#TODO css_assets is not necessary anymore but perhape we can save cycles by passing it diretly to editpage instead of having to get that all from the DB again + css_stylesheets.append(css_asset)#TODO css_stylesheets is not necessary anymore but perhape we can save cycles by passing it diretly to editpage instead of having to get that all from the DB again output_tokens.append('"' + delimiter + css_asset.uuid + delimiter + '"') return "".join(output_tokens) -def parseStyleTags(document, css_assets, page): +def parseStyleTags(document, css_stylesheets, page): """ Grabs any