Skip to content

Instantly share code, notes, and snippets.

@averrin
Created July 5, 2011 13:25
Show Gist options
  • Save averrin/1064827 to your computer and use it in GitHub Desktop.
Save averrin/1064827 to your computer and use it in GitHub Desktop.
outwiker.templates
=== modified file 'src/pages/html/HtmlPanel.py'
--- src/pages/html/HtmlPanel.py 2011-06-14 17:44:58 +0000
+++ src/pages/html/HtmlPanel.py 2011-07-05 13:21:23 +0000
@@ -18,7 +18,7 @@
from gui.htmlrenderfactory import getHtmlRender
from gui.HtmlTextEditor import HtmlTextEditor
from core.system import getTemplatesDir
-
+from core.recent import RecentWiki
class ToolsInfo (object):
def __init__ (self, id, alwaysEnabled):
@@ -476,6 +476,14 @@
_(u"Convert HTML Symbols"),
_(u"Convert HTML Symbols"),
None)
+
+ self._addTool (self.pageToolsMenu,
+ "ID_CODE",
+ lambda event: self.codeEditor.turnText (u"<pre><code>", u"</code></pre>"),
+ _(u"CODE\tCtrl+-"),
+ _(u"CODE (<pre><code>…</code></pre>)"),
+ os.path.join (self.imagesDir, "text_heading_6.png"))
+
def initGui (self, mainWindow):
@@ -503,12 +511,24 @@
if page.readonly and os.path.exists (path):
# Если страница открыта только для чтения и html-файл уже существует, то покажем его
return path
-
- tpl = HtmlTemplate (os.path.join (getTemplatesDir(), "html") )
+ tpl_path=os.path.join(getTemplatesDir(), "html")
+ tpl_path_alt=os.path.expanduser('~/.outwiker/templates/html')
+ tpl_name=u'template.html'
+
+
+ if hasattr(page._params,'templateOption'):
+ tn=page._params.templateOption.value
+ if tn and os.path.isfile(os.path.join(tpl_path,tn)):
+ tpl_name=tn
+ if tn and os.path.isfile(os.path.join(tpl_path_alt,tn)):
+ tpl_name=tn
+ tpl_path=tpl_path_alt
+
+
+ tpl = HtmlTemplate (tpl_path, tpl_fname=tpl_name)
text = HtmlImprover.run (page.content)
text = re.sub ("\n<BR>\n(<li>)|(<LI>)", "\n<LI>", text)
-
- result = tpl.substitute (content=text)
+ result = tpl.substitute (content=text,static=os.path.join(getTemplatesDir(), "static"))
with open (path, "wb") as fp:
fp.write (result.encode ("utf-8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment