Skip to content

Instantly share code, notes, and snippets.

@averrin
Created July 1, 2011 13:47
Show Gist options
  • Save averrin/1058576 to your computer and use it in GitHub Desktop.
Save averrin/1058576 to your computer and use it in GitHub Desktop.
outwiker
=== modified file 'src/core/config.py'
--- src/core/config.py 2011-06-10 19:03:28 +0000
+++ src/core/config.py 2011-07-01 13:21:35 +0000
@@ -212,6 +212,7 @@
Config.__init__ (self, fname, readonly)
self.typeOption = StringOption (self, PageConfig.sectionName, u"type", u"")
+ self.templateOption = StringOption (self, PageConfig.sectionName, u"template", u"")
self.orderOption = IntegerOption (self, PageConfig.sectionName, PageConfig.orderParamName, -1)
self.lastViewedPageOption = StringOption (self,u"History", u"LastViewedPage", u"")
=== modified file 'src/core/htmlimprover.py'
--- src/core/htmlimprover.py 2011-05-26 17:54:11 +0000
+++ src/core/htmlimprover.py 2011-07-01 12:18:34 +0000
@@ -61,7 +61,7 @@
item = text[index: index + len (parts[n]) ]
if n % 2 == 0:
item = item.replace ("\n\n", "<P>")
- item = item.replace ("\n", "<BR>")
+ #item = item.replace ("\n", "<BR>")
item = item.replace ("<BR><LI>", "<LI>")
index += len (parts[n]) + len (starttag)
else:
=== modified file 'src/core/htmltemplate.py'
--- src/core/htmltemplate.py 2011-06-11 06:20:11 +0000
+++ src/core/htmltemplate.py 2011-07-01 12:21:05 +0000
@@ -12,7 +12,7 @@
"""
Класс для генерации HTML-страницы на основе шаблона
"""
- def __init__ (self, path):
+ def __init__ (self, path, tpl_fname=u"template.html"):
"""
path - путь до директории с шаблоном.
@@ -25,15 +25,14 @@
self.fontfamily = self.config.fontFaceNameOption.value
self.userStyle = self.config.userStyleOption.value
- tpl_fname = u"template.html"
tpl_path = os.path.join (path, tpl_fname)
with open (tpl_path) as fp:
self.template = Template (unicode (fp.read().strip(), "utf8") )
- def substitute (self, content):
+ def substitute (self, content, **kwargs):
return self.template.substitute (content=content,
fontsize=self.fontsize,
fontfamily = self.fontfamily,
- userstyle = self.userStyle)
+ userstyle = self.userStyle, **kwargs)
=== modified file 'src/core/tree.py'
--- src/core/tree.py 2011-06-10 18:45:56 +0000
+++ src/core/tree.py 2011-07-01 13:29:30 +0000
@@ -333,6 +333,7 @@
"""
paramTags = u"tags"
paramType = u"type"
+ paramTemplate = u"template"
@staticmethod
def getTypeString ():
=== modified file 'src/gui/TextEditor.py'
--- src/gui/TextEditor.py 2011-06-04 17:39:48 +0000
+++ src/gui/TextEditor.py 2011-07-01 11:59:15 +0000
@@ -14,6 +14,9 @@
from core.textprinter import TextPrinter
from .editorsearchpanel import EditorSearchPanel
+from libs.zen import zen_core
+zen_core.insertion_point=''
+
# begin wxGlade: dependencies
# end wxGlade
@@ -161,6 +164,18 @@
if key == wx.WXK_ESCAPE:
self.searchPanel.Close()
+ elif key == wx.WXK_TAB:
+ line = self.textCtrl.GetLine(self.textCtrl.GetCurrentLine())
+ end = self.textCtrl.GetLineEndPosition(self.textCtrl.GetCurrentLine())
+ start = self.textCtrl.PositionFromLine(self.textCtrl.GetCurrentLine())
+ abbr, index = zen_core.find_abbr_in_line(str(line),len(line)-1)
+ #print line, len(line), start, end
+ #abbr=False
+ if abbr:
+ newText = zen_core.expand_abbreviation(abbr,'html','xhtml')
+ self.textCtrl.SetTargetStart(line.find(abbr)+start)
+ self.textCtrl.SetTargetEnd(end)
+ self.textCtrl.ReplaceTarget(newText)
event.Skip()
=== modified file 'src/gui/pagedialog.py'
--- src/gui/pagedialog.py 2011-02-15 06:22:21 +0000
+++ src/gui/pagedialog.py 2011-07-01 13:06:28 +0000
@@ -155,6 +155,8 @@
assert currentPage != None
self.currentPage = currentPage
+
+
self.SetTitle(_(u"Edit page properties"))
self._prepareForChange (currentPage)
=== 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-01 13:44:55 +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,17 @@
if page.readonly and os.path.exists (path):
# Если страница открыта только для чтения и html-файл уже существует, то покажем его
return path
-
- tpl = HtmlTemplate (os.path.join (getTemplatesDir(), "html") )
+ if hasattr(page._params,'templateOption'):
+ tn=page._params.templateOption.value
+ if not tn:
+ tn=u'template.html'
+ else:
+ tn=u'template.html'
+ tpl = HtmlTemplate (os.path.join (getTemplatesDir(), "html"), tpl_fname=tn)
text = HtmlImprover.run (page.content)
text = re.sub ("\n<BR>\n(<li>)|(<LI>)", "\n<LI>", text)
-
- result = tpl.substitute (content=text)
+ recent = RecentWiki (Application.config)
+ result = tpl.substitute (content=text,path=str(recent._recentes[0]))
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