Allow alternate stylesheets in pages
Useful when you create a site web, you don't need to create a new web when you are testing the stylesheets. The final user can change the stylesheet for the current page. i.e. on Firefox: View -> Page style -> The stylesheet
This commit is contained in:
parent
0de286e7a8
commit
528852b9b3
@ -1422,8 +1422,23 @@ class BasePage: # pylint: disable=C1001
|
||||
Html("link", type="text/css", href=url3,
|
||||
media='print', rel="stylesheet", indent=False),
|
||||
Html("link", type="text/css", href=url2,
|
||||
media="screen", rel="stylesheet", indent=False),
|
||||
media="screen", title=self._("Default"),
|
||||
rel="stylesheet", indent=False),
|
||||
)
|
||||
# create all alternate stylesheets
|
||||
# Cannot use it on local files (file://)
|
||||
for css_f in CSS:
|
||||
already_done = False
|
||||
for css_fn in ("UsEr_", "Basic", "Mainz", "Nebraska"):
|
||||
if css_fn in css_f and not already_done:
|
||||
css_f = css_f.replace("UsEr_","")
|
||||
fname = "/".join(["css", css_f + ".css"])
|
||||
urlx = self.report.build_url_fname(fname, None,
|
||||
self.uplink)
|
||||
links += Html("link", rel="alternate stylesheet",
|
||||
title=css_f, indent=False,
|
||||
media="screen", type="text/css",
|
||||
href=urlx)
|
||||
|
||||
# Link to Navigation Menus stylesheet
|
||||
if CSS[self.report.css]["navigation"]:
|
||||
|
@ -1008,6 +1008,18 @@ class NavWebReport(Report):
|
||||
"""
|
||||
imgs = []
|
||||
|
||||
# copy all screen style sheet
|
||||
for css_f in CSS:
|
||||
already_done = False
|
||||
for css_fn in ("UsEr_", "Basic", "Mainz", "Nebraska", "Vis"):
|
||||
if css_fn in css_f and not already_done:
|
||||
already_done = True
|
||||
fname = CSS[css_f]["filename"]
|
||||
# add images for this css
|
||||
imgs += CSS[css_f]["images"]
|
||||
css_f = css_f.replace("UsEr_","")
|
||||
self.copy_file(fname, css_f + ".css", "css")
|
||||
|
||||
# copy screen style sheet
|
||||
if CSS[self.css]["filename"]:
|
||||
fname = CSS[self.css]["filename"]
|
||||
@ -1683,13 +1695,13 @@ class NavWebOptions(MenuReportOptions):
|
||||
cright.set_help(_("The copyright to be used for the web files"))
|
||||
addopt("cright", cright)
|
||||
|
||||
self.__css = EnumeratedListOption(('StyleSheet'), CSS["default"]["id"])
|
||||
self.__css = EnumeratedListOption(('StyleSheet'), CSS["Basic-Ash"]["id"])
|
||||
for (dummy_fname, gid) in sorted(
|
||||
[(CSS[key]["translation"], CSS[key]["id"])
|
||||
for key in list(CSS.keys())]):
|
||||
if CSS[gid]["user"]:
|
||||
self.__css.add_item(CSS[gid]["id"], CSS[gid]["translation"])
|
||||
self.__css.set_help(_('The stylesheet to be used for the web pages'))
|
||||
self.__css.set_help(_('The default stylesheet to be used for the pages'))
|
||||
addopt("css", self.__css)
|
||||
self.__css.connect("value-changed", self.__stylesheet_changed)
|
||||
|
||||
|
@ -58,7 +58,7 @@ def load_on_reg(dbstate, uistate, plugin):
|
||||
|
||||
# default style sheet in the options
|
||||
# Basic Ash style sheet
|
||||
["default", 1, _("Basic-Ash"),
|
||||
["Basic-Ash", 1, _("Basic-Ash"),
|
||||
path_css('Web_Basic-Ash.css'), None, [], [] ],
|
||||
|
||||
# Basic Blue style sheet with navigation menus
|
||||
@ -173,7 +173,8 @@ def load_on_reg(dbstate, uistate, plugin):
|
||||
list_files = os.listdir(USER_CSS)
|
||||
for cssfile in list_files:
|
||||
if cssfile.endswith(".css"):
|
||||
CSS_FILES.append([cssfile, 1, cssfile.replace('.css', ''),
|
||||
css_f = cssfile.replace('.css', '')
|
||||
CSS_FILES.append(["UsEr_" + css_f, 1, css_f,
|
||||
os.path.join(USER_CSS,cssfile), None,
|
||||
looking_for_urls_in_user_css(cssfile),
|
||||
[] ])
|
||||
|
Loading…
Reference in New Issue
Block a user