Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 6 commits
  • 15 files changed
  • 0 commit comments
  • 1 contributor
View
5 README.mkd
@@ -17,7 +17,10 @@ Features
* Multiple syntax support: Markdown, HTML, reStructuredText, LaTeX, Textile.
* Editor mode and client mode.
* Data is stored in a local SQLite database in client mode.
-* Context search with keywords highlighting.
+* Full-text search with keywords highlighted.
+* Full-text search by using regular expressions.
+* Full-text substitutions.
+* Full-text substitutions using regular expressions.
* Templates for previewing posts.
* Event-driven system.
* I18N.
View
62 doc/UltraBlog.txt 100644 → 100755
@@ -6,7 +6,7 @@
Author: Lenin Lee lenin.lee at gmail dot com *UltraBlog_Author*
URL: http://0x3f.org/?p=1894 *UltraBlog_URL*
Description: Ultimate vim blogging plugin. |UltraBlog_Motivation|
-Version: 3.3.0 |UltraBlog_History|
+Version: 3.4.0 |UltraBlog_History|
License: New BSD |UltraBlog_License|
Contribute: Please report any bugs or suggestions |UltraBlog_Bugs|
to the address above. |UltraBlog_Future|
@@ -65,7 +65,8 @@ Enjoy Vim blogging !
Textile.
* Editor mode and client mode.
* Data is stored in a local SQLite database in client mode.
- * Context search with keywords highlighting.
+ * Context search with keywords highlighted.
+ * Context search by using regular expressions.
* Templates for previewing posts.
==============================================================================
@@ -325,8 +326,29 @@ All keymappings can be customized by setting some options, refer to
Refresh the current buffer.
:UBFind keyword1 [keyword2 ...] *:UBFind*
- Context search for both posts and pages, all keywords will be highlighted.
- Page size of the search result list is controlled by |ub_search_pagesize|.
+ Doing full-text searches for both posts and pages by keywords, all
+ keywords will be highlighted. Page size of the search result list is
+ controlled by |ub_search_pagesize|.
+
+:UBRegexSearch regexp1 [regexp2 ...] *:UBRegexSearch*
+ Doing full-text searches for both posts and pages by regular expressions,
+ all strings that match the regular expressions will be highlighted. Page
+ size of the search result list is controlled by |ub_search_pagesize|.
+
+:UBReplace needle replacement *:UBReplace*
+ Doing full-text substitutions.
+
+:UBRegexReplace regexp replacement *:UBRegexReplace*
+ Doing full-text substitutions using regular expressions.
+
+:UBEnableDebug *:UBEnableDebug*
+ Enable debugging.
+
+:UBDisableDebug *:UBDisableDebug*
+ Disable debugging.
+
+:UBToggleDebug *:UBToggleDebug*
+ Toggle debugging status.
==============================================================================
Options *UltraBlog_Options*
@@ -500,7 +522,9 @@ ub_hotkey_save_current_item *ub_hotkey_save_current_item*
Set the hotkey to execute |:UBSave|.
- This option has no default value.
+ By default, the value is:
+
+ let ub_hotkey_save_current_item='<c-s>'
------------------------------------------------------------------------------
@@ -547,6 +571,20 @@ ub_default_template *ub_default_template*
let ub_default_template="default"
+------------------------------------------------------------------------------
+
+ub_debug *ub_debug*
+
+ Whether or not to enable debugging. Setting this option to 1 enables
+ debugging and 0 disables it.
+
+ In debug mode, SQL statements being executed will be displayed and so are
+ all stack traces of exceptions raised.
+
+ By default, the value is:
+
+ let ub_debug = 0
+
==============================================================================
Future *UltraBlog_Future*
==============================================================================
@@ -568,6 +606,20 @@ Or submit issues with Github's issues tracker:
History *UltraBlog_History*
==============================================================================
+3.4.0
+ * Feature: Add the command |:UBRegexSearch|, doing full-text searches with
+ regular expressions !
+ * Feature: Add the command |:UBReplace|, doing full-text substitutions.
+ * Feature: Add the command |:UBRegexReplace|, doing full-text substitutions
+ with regular expressions.
+ * Feature: Add commands |:UBEnableDebug|, |:UBDisableDebug|,
+ |:UBToggleDebug| and an option |ub_debug|. In debug mode, SQL
+ statements and stack traces of exceptions will be displayed.
+ * Change: Undo keywords highlighting after executing |:UBList|.
+ * Bugfix: Exceptions raised when opening the current item under cursor
+ in item lists if the option |ub_hotkey_save_current_item| has
+ not been set. Now this options comes with a default value.
+
3.3.0
* Feature: Add i18n support !
* Feature: Add a new option |ub_hotkey_save_current_item|, users can
View
11 plugin/UltraBlog.vim
@@ -2,7 +2,7 @@
" File: UltraBlog.vim
" Description: Ultimate vim blogging plugin that manages web logs
" Author: Lenin Lee <lenin.lee at gmail dot com>
-" Version: 3.3.0
+" Version: 3.4.0
" License: The New BSD License
"
" ============================================================================
@@ -188,7 +188,13 @@ command! -nargs=* -complete=customlist,UBNewCmpl UBNew exec('py ub_new_item(<f-a
command! -nargs=* -complete=customlist,UBOpenCmpl UBOpen exec('py ub_open_item_x(<f-args>)')
command! -nargs=* -complete=customlist,UBDelCmpl UBDel exec('py ub_del_item(<f-args>)')
command! -nargs=* -complete=customlist,UBThisCmpl UBThis exec('py ub_blog_this(<f-args>)')
-command! -nargs=+ UBFind exec('py ub_find(1, <f-args>)')
+command! -nargs=+ UBFind exec('py ub_search(0, 1, <f-args>)')
+command! -nargs=+ UBRegexSearch exec('py ub_search(1, 1, <f-args>)')
+command! -nargs=+ UBReplace exec('py ub_replace(0, <f-args>)')
+command! -nargs=+ UBRegexReplace exec('py ub_replace(1, <f-args>)')
+command! -nargs=0 UBEnableDebug exec('py ub_debug(1)')
+command! -nargs=0 UBDisableDebug exec('py ub_debug(0)')
+command! -nargs=0 UBToggleDebug exec('py ub_debug(2)')
" Auto-commands
autocmd! BufEnter * py __ub_on_buffer_enter()
@@ -209,5 +215,4 @@ def __ub_on_buffer_enter():
if ub_is_view_outdated('%'):
ub_refresh_current_view()
ub_set_view_outdated('%', False)
-
EOF
View
74 plugin/locale/en_US.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2012-04-15 19:21+CST\n"
+"POT-Creation-Date: 2012-04-29 17:16+CST\n"
"PO-Revision-Date: 2012-04-15 17:10+0800\n"
"Last-Translator: <lenin.lee@gmail.com>\n"
"Language-Team: English\n"
@@ -16,126 +16,134 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: ultrablog/commands.py:128
+#: ultrablog/commands.py:151 ultrablog/util.py:390
msgid "Invalid view !"
msgstr ""
-#: ultrablog/commands.py:130
+#: ultrablog/commands.py:153
msgid "File not exists !"
msgstr ""
-#: ultrablog/commands.py:196
+#: ultrablog/commands.py:219
msgid "Cannot find SQLAlchemy !"
msgstr ""
-#: ultrablog/commands.py:198
+#: ultrablog/commands.py:221
msgid "Cannot create database objects !"
msgstr ""
-#: ultrablog/commands.py:199
+#: ultrablog/commands.py:222
msgid "Settings of UltraBlog.vim is missing or invalid !"
msgstr ""
-#: ultrablog/commands.py:200
+#: ultrablog/commands.py:223
msgid "Cannot initiate API !"
msgstr ""
-#: ultrablog/commands.py:201
+#: ultrablog/commands.py:224
msgid "Cannot connect to database !"
msgstr ""
-#: ultrablog/commands.py:208
+#: ultrablog/commands.py:231
msgid "Unknow item type, available types are: post, page and tmpl !"
msgstr ""
-#: ultrablog/commands.py:222
+#: ultrablog/commands.py:245
msgid "Invalid scope !"
msgstr ""
-#: ultrablog/commands.py:230
+#: ultrablog/commands.py:253
msgid "Unknown syntax, valid syntaxes are %s"
msgstr ""
-#: ultrablog/commands.py:239
+#: ultrablog/commands.py:262
msgid "Invalid view, this command is only allowed in %s !"
msgstr ""
-#: ultrablog/commands.py:261
+#: ultrablog/commands.py:284
msgid "Not implemented yet !"
msgstr ""
-#: ultrablog/commands.py:292 ultrablog/commands.py:431
+#: ultrablog/commands.py:315 ultrablog/commands.py:456
msgid "Page NO. cannot be less than 1 !"
msgstr ""
-#: ultrablog/commands.py:293 ultrablog/commands.py:432
+#: ultrablog/commands.py:316 ultrablog/commands.py:457
msgid "Illegal page size (%s) !"
msgstr ""
-#: ultrablog/commands.py:330 ultrablog/commands.py:459
+#: ultrablog/commands.py:354 ultrablog/commands.py:494
msgid "No more posts found !"
msgstr ""
-#: ultrablog/commands.py:384
+#: ultrablog/commands.py:408
msgid "No more pages found !"
msgstr ""
-#: ultrablog/commands.py:413
+#: ultrablog/commands.py:437
msgid "No templates found !"
msgstr ""
-#: ultrablog/commands.py:490
+#: ultrablog/commands.py:549
+msgid "%d items substituted !"
+msgstr ""
+
+#: ultrablog/commands.py:563
msgid "This buffer has not been modified !"
msgstr ""
-#: ultrablog/commands.py:581
+#: ultrablog/commands.py:654
msgid "%s sent as %s !"
msgstr ""
-#: ultrablog/commands.py:656
+#: ultrablog/commands.py:729
msgid "No post found !"
msgstr ""
-#: ultrablog/commands.py:662
+#: ultrablog/commands.py:735
msgid "No page found !"
msgstr ""
-#: ultrablog/commands.py:711
+#: ultrablog/commands.py:784
msgid "No template found !"
msgstr ""
-#: ultrablog/commands.py:752
+#: ultrablog/commands.py:825
msgid "Template \"%s\" exists !"
msgstr ""
-#: ultrablog/commands.py:817
+#: ultrablog/commands.py:890
msgid "Template '%s' is not found !"
msgstr ""
-#: ultrablog/commands.py:854
+#: ultrablog/commands.py:927
msgid "Cannot find %s by key value %s !"
msgstr ""
-#: ultrablog/commands.py:858
+#: ultrablog/commands.py:931
msgid "Are you sure to delete %s %s \"%s\" ?"
msgstr ""
-#: ultrablog/commands.py:860
+#: ultrablog/commands.py:933
msgid "Deletion canceled !"
msgstr ""
-#: ultrablog/commands.py:884
+#: ultrablog/commands.py:957
msgid "%s %s \"%s\" was deleted !"
msgstr ""
-#: ultrablog/commands.py:902 ultrablog/commands.py:927
+#: ultrablog/commands.py:975 ultrablog/commands.py:1000
msgid "This is not an item !"
msgstr ""
-#: ultrablog/commands.py:998
+#: ultrablog/commands.py:1072
msgid "Cannot find key value of the current buffer !"
msgstr ""
+#: ultrablog/db.py:191
+msgid "Missing key %s in the settings list of UltraBlog.vim !"
+msgstr ""
+
#: ultrablog/util.py:40
msgid "The buffer has been changed and cannot be cleared !"
msgstr ""
@@ -184,10 +192,10 @@ msgstr ""
msgid "pending"
msgstr ""
-#: ultrablog/util.py:556
+#: ultrablog/util.py:560
msgid "Missing module: python-markdown or python-markdown2 !"
msgstr ""
-#: ultrablog/util.py:565
+#: ultrablog/util.py:569
msgid "Missing module: python-html2text !"
msgstr ""
View
136 plugin/locale/en_US.po~
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2012-04-15 19:07+CST\n"
+"POT-Creation-Date: 2012-04-28 10:23+CST\n"
"PO-Revision-Date: 2012-04-15 17:10+0800\n"
"Last-Translator: <lenin.lee@gmail.com>\n"
"Language-Team: English\n"
@@ -16,26 +16,142 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: ultrablog/commands.py:581
+#: ultrablog/commands.py:135 ultrablog/util.py:388
+msgid "Invalid view !"
+msgstr ""
+
+#: ultrablog/commands.py:137
+msgid "File not exists !"
+msgstr ""
+
+#: ultrablog/commands.py:203
+msgid "Cannot find SQLAlchemy !"
+msgstr ""
+
+#: ultrablog/commands.py:205
+msgid "Cannot create database objects !"
+msgstr ""
+
+#: ultrablog/commands.py:206
+msgid "Settings of UltraBlog.vim is missing or invalid !"
+msgstr ""
+
+#: ultrablog/commands.py:207
+msgid "Cannot initiate API !"
+msgstr ""
+
+#: ultrablog/commands.py:208
+msgid "Cannot connect to database !"
+msgstr ""
+
+#: ultrablog/commands.py:215
+msgid "Unknow item type, available types are: post, page and tmpl !"
+msgstr ""
+
+#: ultrablog/commands.py:229
+msgid "Invalid scope !"
+msgstr ""
+
+#: ultrablog/commands.py:237
+msgid "Unknown syntax, valid syntaxes are %s"
+msgstr ""
+
+#: ultrablog/commands.py:246
+msgid "Invalid view, this command is only allowed in %s !"
+msgstr ""
+
+#: ultrablog/commands.py:268
+msgid "Not implemented yet !"
+msgstr ""
+
+#: ultrablog/commands.py:299 ultrablog/commands.py:440
+msgid "Page NO. cannot be less than 1 !"
+msgstr ""
+
+#: ultrablog/commands.py:300 ultrablog/commands.py:441
+msgid "Illegal page size (%s) !"
+msgstr ""
+
+#: ultrablog/commands.py:338 ultrablog/commands.py:478
+msgid "No more posts found !"
+msgstr ""
+
+#: ultrablog/commands.py:392
+msgid "No more pages found !"
+msgstr ""
+
+#: ultrablog/commands.py:421
+msgid "No templates found !"
+msgstr ""
+
+#: ultrablog/commands.py:536
+msgid "%d items substituted !"
+msgstr ""
+
+#: ultrablog/commands.py:550
+msgid "This buffer has not been modified !"
+msgstr ""
+
+#: ultrablog/commands.py:641
msgid "%s sent as %s !"
msgstr ""
-#: ultrablog/commands.py:854
+#: ultrablog/commands.py:716
+msgid "No post found !"
+msgstr ""
+
+#: ultrablog/commands.py:722
+msgid "No page found !"
+msgstr ""
+
+#: ultrablog/commands.py:771
+msgid "No template found !"
+msgstr ""
+
+#: ultrablog/commands.py:812
+msgid "Template \"%s\" exists !"
+msgstr ""
+
+#: ultrablog/commands.py:877
+msgid "Template '%s' is not found !"
+msgstr ""
+
+#: ultrablog/commands.py:914
msgid "Cannot find %s by key value %s !"
msgstr ""
-#: ultrablog/commands.py:858
+#: ultrablog/commands.py:918
msgid "Are you sure to delete %s %s \"%s\" ?"
msgstr ""
-#: ultrablog/commands.py:860
+#: ultrablog/commands.py:920
msgid "Deletion canceled !"
msgstr ""
-#: ultrablog/commands.py:884
+#: ultrablog/commands.py:944
msgid "%s %s \"%s\" was deleted !"
msgstr ""
+#: ultrablog/commands.py:962 ultrablog/commands.py:987
+msgid "This is not an item !"
+msgstr ""
+
+#: ultrablog/commands.py:1059
+msgid "Cannot find key value of the current buffer !"
+msgstr ""
+
+#: ultrablog/util.py:40
+msgid "The buffer has been changed and cannot be cleared !"
+msgstr ""
+
+#: ultrablog/util.py:55
+msgid "Invalid status !"
+msgstr ""
+
+#: ultrablog/util.py:62
+msgid "'%s' is a reserved word !"
+msgstr ""
+
#: ultrablog/util.py:142
msgid "template"
msgstr ""
@@ -71,3 +187,11 @@ msgstr ""
#: ultrablog/util.py:168
msgid "pending"
msgstr ""
+
+#: ultrablog/util.py:558
+msgid "Missing module: python-markdown or python-markdown2 !"
+msgstr ""
+
+#: ultrablog/util.py:567
+msgid "Missing module: python-html2text !"
+msgstr ""
View
BIN plugin/locale/en_US/LC_MESSAGES/ultrablog.mo
Binary file not shown.
View
78 plugin/locale/messages.pot
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2012-04-15 19:21+CST\n"
+"POT-Creation-Date: 2012-04-29 17:16+CST\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -15,126 +15,134 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n"
-#: ultrablog/commands.py:128
+#: ultrablog/commands.py:151 ultrablog/util.py:390
msgid "Invalid view !"
msgstr ""
-#: ultrablog/commands.py:130
+#: ultrablog/commands.py:153
msgid "File not exists !"
msgstr ""
-#: ultrablog/commands.py:196
+#: ultrablog/commands.py:219
msgid "Cannot find SQLAlchemy !"
msgstr ""
-#: ultrablog/commands.py:198
+#: ultrablog/commands.py:221
msgid "Cannot create database objects !"
msgstr ""
-#: ultrablog/commands.py:199
+#: ultrablog/commands.py:222
msgid "Settings of UltraBlog.vim is missing or invalid !"
msgstr ""
-#: ultrablog/commands.py:200
+#: ultrablog/commands.py:223
msgid "Cannot initiate API !"
msgstr ""
-#: ultrablog/commands.py:201
+#: ultrablog/commands.py:224
msgid "Cannot connect to database !"
msgstr ""
-#: ultrablog/commands.py:208
+#: ultrablog/commands.py:231
msgid "Unknow item type, available types are: post, page and tmpl !"
msgstr ""
-#: ultrablog/commands.py:222
+#: ultrablog/commands.py:245
msgid "Invalid scope !"
msgstr ""
-#: ultrablog/commands.py:230
+#: ultrablog/commands.py:253
msgid "Unknown syntax, valid syntaxes are %s"
msgstr ""
-#: ultrablog/commands.py:239
+#: ultrablog/commands.py:262
msgid "Invalid view, this command is only allowed in %s !"
msgstr ""
-#: ultrablog/commands.py:261
+#: ultrablog/commands.py:284
msgid "Not implemented yet !"
msgstr ""
-#: ultrablog/commands.py:292 ultrablog/commands.py:431
+#: ultrablog/commands.py:315 ultrablog/commands.py:456
msgid "Page NO. cannot be less than 1 !"
msgstr ""
-#: ultrablog/commands.py:293 ultrablog/commands.py:432
+#: ultrablog/commands.py:316 ultrablog/commands.py:457
msgid "Illegal page size (%s) !"
msgstr ""
-#: ultrablog/commands.py:330 ultrablog/commands.py:459
+#: ultrablog/commands.py:354 ultrablog/commands.py:494
msgid "No more posts found !"
msgstr ""
-#: ultrablog/commands.py:384
+#: ultrablog/commands.py:408
msgid "No more pages found !"
msgstr ""
-#: ultrablog/commands.py:413
+#: ultrablog/commands.py:437
msgid "No templates found !"
msgstr ""
-#: ultrablog/commands.py:490
+#: ultrablog/commands.py:549
+msgid "%d items substituted !"
+msgstr ""
+
+#: ultrablog/commands.py:563
msgid "This buffer has not been modified !"
msgstr ""
-#: ultrablog/commands.py:581
+#: ultrablog/commands.py:654
msgid "%s sent as %s !"
msgstr ""
-#: ultrablog/commands.py:656
+#: ultrablog/commands.py:729
msgid "No post found !"
msgstr ""
-#: ultrablog/commands.py:662
+#: ultrablog/commands.py:735
msgid "No page found !"
msgstr ""
-#: ultrablog/commands.py:711
+#: ultrablog/commands.py:784
msgid "No template found !"
msgstr ""
-#: ultrablog/commands.py:752
+#: ultrablog/commands.py:825
msgid "Template \"%s\" exists !"
msgstr ""
-#: ultrablog/commands.py:817
+#: ultrablog/commands.py:890
msgid "Template '%s' is not found !"
msgstr ""
-#: ultrablog/commands.py:854
+#: ultrablog/commands.py:927
msgid "Cannot find %s by key value %s !"
msgstr ""
-#: ultrablog/commands.py:858
+#: ultrablog/commands.py:931
msgid "Are you sure to delete %s %s \"%s\" ?"
msgstr ""
-#: ultrablog/commands.py:860
+#: ultrablog/commands.py:933
msgid "Deletion canceled !"
msgstr ""
-#: ultrablog/commands.py:884
+#: ultrablog/commands.py:957
msgid "%s %s \"%s\" was deleted !"
msgstr ""
-#: ultrablog/commands.py:902 ultrablog/commands.py:927
+#: ultrablog/commands.py:975 ultrablog/commands.py:1000
msgid "This is not an item !"
msgstr ""
-#: ultrablog/commands.py:998
+#: ultrablog/commands.py:1072
msgid "Cannot find key value of the current buffer !"
msgstr ""
+#: ultrablog/db.py:191
+msgid "Missing key %s in the settings list of UltraBlog.vim !"
+msgstr ""
+
#: ultrablog/util.py:40
msgid "The buffer has been changed and cannot be cleared !"
msgstr ""
@@ -183,15 +191,11 @@ msgstr ""
msgid "pending"
msgstr ""
-#: ultrablog/util.py:386
-msgid "Unknown view !"
-msgstr ""
-
-#: ultrablog/util.py:556
+#: ultrablog/util.py:560
msgid "Missing module: python-markdown or python-markdown2 !"
msgstr ""
-#: ultrablog/util.py:565
+#: ultrablog/util.py:569
msgid "Missing module: python-html2text !"
msgstr ""
View
74 plugin/locale/zh_CN.po
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2012-04-15 19:21+CST\n"
+"POT-Creation-Date: 2012-04-29 17:16+CST\n"
"PO-Revision-Date: 2012-04-15 17:10+0800\n"
"Last-Translator: <lenin.lee@gmail.com>\n"
"Language-Team: Chinese (simplified)\n"
@@ -15,126 +15,134 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
-#: ultrablog/commands.py:128
+#: ultrablog/commands.py:151 ultrablog/util.py:390
msgid "Invalid view !"
msgstr "错误的视图!"
-#: ultrablog/commands.py:130
+#: ultrablog/commands.py:153
msgid "File not exists !"
msgstr "文件不存在!"
-#: ultrablog/commands.py:196
+#: ultrablog/commands.py:219
msgid "Cannot find SQLAlchemy !"
msgstr "SQLAlchemy未安装!"
-#: ultrablog/commands.py:198
+#: ultrablog/commands.py:221
msgid "Cannot create database objects !"
msgstr "无法创建数据库对象!"
-#: ultrablog/commands.py:199
+#: ultrablog/commands.py:222
msgid "Settings of UltraBlog.vim is missing or invalid !"
msgstr "UltraBlog.vim的配置信息不正确或丢失!"
-#: ultrablog/commands.py:200
+#: ultrablog/commands.py:223
msgid "Cannot initiate API !"
msgstr "无法初始化博客接口!"
-#: ultrablog/commands.py:201
+#: ultrablog/commands.py:224
msgid "Cannot connect to database !"
msgstr "无法连接数据库!"
-#: ultrablog/commands.py:208
+#: ultrablog/commands.py:231
msgid "Unknow item type, available types are: post, page and tmpl !"
msgstr "元素类型未知,合法类型有:post, page, tmpl!"
-#: ultrablog/commands.py:222
+#: ultrablog/commands.py:245
msgid "Invalid scope !"
msgstr "未知的作用域!"
-#: ultrablog/commands.py:230
+#: ultrablog/commands.py:253
msgid "Unknown syntax, valid syntaxes are %s"
msgstr "语法类型未知,合法类型有:%s"
-#: ultrablog/commands.py:239
+#: ultrablog/commands.py:262
msgid "Invalid view, this command is only allowed in %s !"
msgstr "错误的视图,此命令只在%s中可用!"
-#: ultrablog/commands.py:261
+#: ultrablog/commands.py:284
msgid "Not implemented yet !"
msgstr "尚未实现!"
-#: ultrablog/commands.py:292 ultrablog/commands.py:431
+#: ultrablog/commands.py:315 ultrablog/commands.py:456
msgid "Page NO. cannot be less than 1 !"
msgstr "页码不能小于1!"
-#: ultrablog/commands.py:293 ultrablog/commands.py:432
+#: ultrablog/commands.py:316 ultrablog/commands.py:457
msgid "Illegal page size (%s) !"
msgstr "非法的分页行数“%s”!"
-#: ultrablog/commands.py:330 ultrablog/commands.py:459
+#: ultrablog/commands.py:354 ultrablog/commands.py:494
msgid "No more posts found !"
msgstr "找不到更多的文章!"
-#: ultrablog/commands.py:384
+#: ultrablog/commands.py:408
msgid "No more pages found !"
msgstr "找不到更多的页面!"
-#: ultrablog/commands.py:413
+#: ultrablog/commands.py:437
msgid "No templates found !"
msgstr "找不到更多的模板!"
-#: ultrablog/commands.py:490
+#: ultrablog/commands.py:549
+msgid "%d items substituted !"
+msgstr "已替换%d篇文章。"
+
+#: ultrablog/commands.py:563
msgid "This buffer has not been modified !"
msgstr "缓冲区未被修改!"
-#: ultrablog/commands.py:581
+#: ultrablog/commands.py:654
msgid "%s sent as %s !"
msgstr "%s已发布,状态:%s。"
-#: ultrablog/commands.py:656
+#: ultrablog/commands.py:729
msgid "No post found !"
msgstr "文章没找到!"
-#: ultrablog/commands.py:662
+#: ultrablog/commands.py:735
msgid "No page found !"
msgstr "页面没找到!"
-#: ultrablog/commands.py:711
+#: ultrablog/commands.py:784
msgid "No template found !"
msgstr "模板没找到!"
-#: ultrablog/commands.py:752
+#: ultrablog/commands.py:825
msgid "Template \"%s\" exists !"
msgstr "模板“%s”已存在!"
-#: ultrablog/commands.py:817
+#: ultrablog/commands.py:890
msgid "Template '%s' is not found !"
msgstr "模板“%s”没找到!"
-#: ultrablog/commands.py:854
+#: ultrablog/commands.py:927
msgid "Cannot find %s by key value %s !"
msgstr "无法找到%s(ID:%s)!"
-#: ultrablog/commands.py:858
+#: ultrablog/commands.py:931
msgid "Are you sure to delete %s %s \"%s\" ?"
msgstr "是否确认删除%s%s“%s”?"
-#: ultrablog/commands.py:860
+#: ultrablog/commands.py:933
msgid "Deletion canceled !"
msgstr "删除已取消!"
-#: ultrablog/commands.py:884
+#: ultrablog/commands.py:957
msgid "%s %s \"%s\" was deleted !"
msgstr "%s%s“%s”已删除。"
-#: ultrablog/commands.py:902 ultrablog/commands.py:927
+#: ultrablog/commands.py:975 ultrablog/commands.py:1000
msgid "This is not an item !"
msgstr "这不是一个合法的元素!"
-#: ultrablog/commands.py:998
+#: ultrablog/commands.py:1072
msgid "Cannot find key value of the current buffer !"
msgstr "无法找到当前内容的键值!"
+#: ultrablog/db.py:191
+msgid "Missing key %s in the settings list of UltraBlog.vim !"
+msgstr "UltraBlog.vim的设置中缺少选项“%s”!"
+
#: ultrablog/util.py:40
msgid "The buffer has been changed and cannot be cleared !"
msgstr "内容已被修改,无法清空!"
@@ -183,10 +191,10 @@ msgstr "私有"
msgid "pending"
msgstr "审查"
-#: ultrablog/util.py:556
+#: ultrablog/util.py:560
msgid "Missing module: python-markdown or python-markdown2 !"
msgstr "缺少模块:python-markdown或python-markdown2!"
-#: ultrablog/util.py:565
+#: ultrablog/util.py:569
msgid "Missing module: python-html2text !"
msgstr "缺少模块:python-html2text!"
View
136 plugin/locale/zh_CN.po~
@@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2012-04-15 19:07+CST\n"
+"POT-Creation-Date: 2012-04-28 10:23+CST\n"
"PO-Revision-Date: 2012-04-15 17:10+0800\n"
"Last-Translator: <lenin.lee@gmail.com>\n"
"Language-Team: Chinese (simplified)\n"
@@ -15,26 +15,142 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
-#: ultrablog/commands.py:581
+#: ultrablog/commands.py:135 ultrablog/util.py:388
+msgid "Invalid view !"
+msgstr "错误的视图!"
+
+#: ultrablog/commands.py:137
+msgid "File not exists !"
+msgstr "文件不存在!"
+
+#: ultrablog/commands.py:203
+msgid "Cannot find SQLAlchemy !"
+msgstr "SQLAlchemy未安装!"
+
+#: ultrablog/commands.py:205
+msgid "Cannot create database objects !"
+msgstr "无法创建数据库对象!"
+
+#: ultrablog/commands.py:206
+msgid "Settings of UltraBlog.vim is missing or invalid !"
+msgstr "UltraBlog.vim的配置信息不正确或丢失!"
+
+#: ultrablog/commands.py:207
+msgid "Cannot initiate API !"
+msgstr "无法初始化博客接口!"
+
+#: ultrablog/commands.py:208
+msgid "Cannot connect to database !"
+msgstr "无法连接数据库!"
+
+#: ultrablog/commands.py:215
+msgid "Unknow item type, available types are: post, page and tmpl !"
+msgstr "元素类型未知,合法类型有:post, page, tmpl!"
+
+#: ultrablog/commands.py:229
+msgid "Invalid scope !"
+msgstr "未知的作用域!"
+
+#: ultrablog/commands.py:237
+msgid "Unknown syntax, valid syntaxes are %s"
+msgstr "语法类型未知,合法类型有:%s"
+
+#: ultrablog/commands.py:246
+msgid "Invalid view, this command is only allowed in %s !"
+msgstr "错误的视图,此命令只在%s中可用!"
+
+#: ultrablog/commands.py:268
+msgid "Not implemented yet !"
+msgstr "尚未实现!"
+
+#: ultrablog/commands.py:299 ultrablog/commands.py:440
+msgid "Page NO. cannot be less than 1 !"
+msgstr "页码不能小于1!"
+
+#: ultrablog/commands.py:300 ultrablog/commands.py:441
+msgid "Illegal page size (%s) !"
+msgstr "非法的分页行数“%s”!"
+
+#: ultrablog/commands.py:338 ultrablog/commands.py:478
+msgid "No more posts found !"
+msgstr "找不到更多的文章!"
+
+#: ultrablog/commands.py:392
+msgid "No more pages found !"
+msgstr "找不到更多的页面!"
+
+#: ultrablog/commands.py:421
+msgid "No templates found !"
+msgstr "找不到更多的模板!"
+
+#: ultrablog/commands.py:536
+msgid "%d items substituted !"
+msgstr "已替换%d篇文章。"
+
+#: ultrablog/commands.py:550
+msgid "This buffer has not been modified !"
+msgstr "缓冲区未被修改!"
+
+#: ultrablog/commands.py:641
msgid "%s sent as %s !"
msgstr "%s已发布,状态:%s。"
-#: ultrablog/commands.py:854
+#: ultrablog/commands.py:716
+msgid "No post found !"
+msgstr "文章没找到!"
+
+#: ultrablog/commands.py:722
+msgid "No page found !"
+msgstr "页面没找到!"
+
+#: ultrablog/commands.py:771
+msgid "No template found !"
+msgstr "模板没找到!"
+
+#: ultrablog/commands.py:812
+msgid "Template \"%s\" exists !"
+msgstr "模板“%s”已存在!"
+
+#: ultrablog/commands.py:877
+msgid "Template '%s' is not found !"
+msgstr "模板“%s”没找到!"
+
+#: ultrablog/commands.py:914
msgid "Cannot find %s by key value %s !"
msgstr "无法找到%s(ID:%s)!"
-#: ultrablog/commands.py:858
+#: ultrablog/commands.py:918
msgid "Are you sure to delete %s %s \"%s\" ?"
msgstr "是否确认删除%s%s“%s”?"
-#: ultrablog/commands.py:860
+#: ultrablog/commands.py:920
msgid "Deletion canceled !"
msgstr "删除已取消!"
-#: ultrablog/commands.py:884
+#: ultrablog/commands.py:944
msgid "%s %s \"%s\" was deleted !"
msgstr "%s%s“%s”已删除。"
+#: ultrablog/commands.py:962 ultrablog/commands.py:987
+msgid "This is not an item !"
+msgstr "这不是一个合法的元素!"
+
+#: ultrablog/commands.py:1059
+msgid "Cannot find key value of the current buffer !"
+msgstr "无法找到当前内容的键值!"
+
+#: ultrablog/util.py:40
+msgid "The buffer has been changed and cannot be cleared !"
+msgstr "内容已被修改,无法清空!"
+
+#: ultrablog/util.py:55
+msgid "Invalid status !"
+msgstr "非法的状态!"
+
+#: ultrablog/util.py:62
+msgid "'%s' is a reserved word !"
+msgstr "“%s”是一个保留字!"
+
#: ultrablog/util.py:142
msgid "template"
msgstr "模板"
@@ -70,3 +186,11 @@ msgstr "私有"
#: ultrablog/util.py:168
msgid "pending"
msgstr "审查"
+
+#: ultrablog/util.py:558
+msgid "Missing module: python-markdown or python-markdown2 !"
+msgstr "缺少模块:python-markdown或python-markdown2!"
+
+#: ultrablog/util.py:567
+msgid "Missing module: python-html2text !"
+msgstr "缺少模块:python-html2text!"
View
BIN plugin/locale/zh_CN/LC_MESSAGES/ultrablog.mo
Binary file not shown.
View
104 plugin/ultrablog/commands.py 100644 → 100755
@@ -12,6 +12,8 @@
def __ub_exception_handler(func):
def __check(*args,**kwargs):
+ dbg_enabled = ub_get_option('ub_debug')
+ if dbg_enabled == 1: return func(*args,**kwargs)
try:
return func(*args,**kwargs)
except UBException, e:
@@ -45,6 +47,20 @@ def __check(*args, **kw):
return func(*args, **kw)
return __check
+def ub_debug(mode):
+ """Set debug mode
+ 0: Disable debug mode
+ 1: Enable debug mode
+ 2: Toggle debug status
+ """
+ if mode in [0,1]: dbg_status = mode
+ else:
+ dbg_enabled = ub_get_option('ub_debug')
+ dbg_status = (dbg_enabled == 0) and 1 or 0
+ vim.command("let g:ub_debug = %d" % dbg_status)
+ if dbg_status == 1: dbe.echo = True
+ else: dbe.echo = False
+
@__ub_exception_handler
def ub_list_items(item_type='post', scope='local', page_size=None, page_no=None):
''' List items
@@ -53,10 +69,17 @@ def ub_list_items(item_type='post', scope='local', page_size=None, page_no=None)
cmd.execute()
@__ub_exception_handler
-def ub_find(page_no, *keywords):
+def ub_search(is_regexp, page_no, *keywords):
+ ''' List posts/pages which match the keywords given
+ '''
+ cmd = UBCmdSearch(is_regexp, page_no, *keywords)
+ cmd.execute()
+
+@__ub_exception_handler
+def ub_replace(is_regexp, needle, replacement):
''' List posts/pages which match the keywords given
'''
- cmd = UBCmdFind(page_no, *keywords)
+ cmd = UBCmdReplace(is_regexp, needle, replacement)
cmd.execute()
@__ub_exception_handler
@@ -171,7 +194,7 @@ class UBCommand(object):
def __init__(self, isContentAware=False):
self.checkPrerequisites()
# Set editor mode if the corresponding option has been set
- ub_set_mode()
+ ub_set_mode(dbe)
self.isContentAware = isContentAware
self.scope = 'local'
@@ -198,7 +221,7 @@ def checkPrerequisites(self):
raise UBException(_('Cannot create database objects !'))
if cfg is None: raise UBException(_('Settings of UltraBlog.vim is missing or invalid !'))
if api is None: raise UBException(_('Cannot initiate API !'))
- if db is None: raise UBException(_('Cannot connect to database !'))
+ if dbe is None: raise UBException(_('Cannot connect to database !'))
def checkItemType(self, itemType=None):
''' Check if the item type is among the available ones
@@ -301,6 +324,7 @@ def _postExec(self):
vim.command('call UBClearUndo()')
vim.command('setl nomodified')
vim.command("setl nomodifiable")
+ vim.command("setl nohls")
vim.current.window.cursor = (2, 0)
def _listLocalPosts(self):
@@ -317,7 +341,7 @@ def _listLocalPosts(self):
)
stmt = select([ua]).limit(self.pageSize).offset(self.pageSize*(self.pageNo-1))
- conn = db.connect()
+ conn = dbe.connect()
rslt = conn.execute(stmt)
while True:
row = rslt.fetchone()
@@ -371,7 +395,7 @@ def _listLocalPages(self):
.where(tbl.c.post_id!=None).where(tbl.c.type=='page').order_by(tbl.c.post_id.desc())])
)
- conn = db.connect()
+ conn = dbe.connect()
rslt = conn.execute(ua)
while True:
row = rslt.fetchone()
@@ -417,17 +441,18 @@ def _listTemplates(self):
line = "%-24s%s"
vim.current.buffer.append([(line % (tmpl.name,tmpl.description)).encode(self.enc) for tmpl in tmpls])
-class UBCmdFind(UBCommand):
+class UBCmdSearch(UBCommand):
''' Context search
'''
- def __init__(self, pageNo, *keywords):
+ def __init__(self, isRegexp, pageNo, *keywords):
UBCommand.__init__(self)
self.pageSize = int(ub_get_option("ub_%s_pagesize" % self.scope))
self.pageNo = int(pageNo is not None and pageNo or 1)
self.keywords = keywords
+ self.isRegexp = isRegexp
def _preExec(self):
- UBCmdFind.doDefault()
+ UBCmdSearch.doDefault()
if self.pageNo<1: raise UBException(_('Page NO. cannot be less than 1 !'))
if self.pageSize<1: raise UBException(_('Illegal page size (%s) !') % self.pageSize)
@@ -438,15 +463,25 @@ def _exec(self):
conds = []
for keyword in self.keywords:
kwcond = []
- kwcond.append(tbl.c.title.like('%%%s%%' % keyword.decode(self.enc)))
- kwcond.append(tbl.c.content.like('%%%s%%' % keyword.decode(self.enc)))
+ if self.isRegexp:
+ kwcond.append(tbl.c.title.op('regexp')(keyword.decode(self.enc)))
+ kwcond.append(tbl.c.content.op('regexp')(keyword.decode(self.enc)))
+ else:
+ kwcond.append(tbl.c.title.like('%%%s%%' % keyword.decode(self.enc)))
+ kwcond.append(tbl.c.content.like('%%%s%%' % keyword.decode(self.enc)))
conds.append(or_(*kwcond))
stmt = select([tbl.c.id,case([(tbl.c.post_id>0, tbl.c.post_id)], else_=0).label('post_id'),tbl.c.status,tbl.c.title],
and_(*conds)
).limit(self.pageSize).offset(self.pageSize*(self.pageNo-1)).order_by(tbl.c.status.asc(),tbl.c.post_id.desc())
- conn = db.connect()
+ conn = dbe.connect()
+ # Hook regexp function to sqlite3 if the current mode is regexp
+ if self.isRegexp:
+ def regexp(expr, item):
+ reg = re.compile(expr)
+ return reg.search(item) is not None
+ conn.connection.create_function('REGEXP', 2, regexp)
rslt = conn.execute(stmt)
while True:
row = rslt.fetchone()
@@ -465,9 +500,10 @@ def _exec(self):
vim.command("let b:page_no=%s" % self.pageNo)
vim.command("let b:page_size=%s" % self.pageSize)
+ vim.command("let b:is_regexp=%s" % self.isRegexp)
vim.command("let b:ub_keywords=[%s]" % ','.join(["'%s'" % kw for kw in self.keywords]))
- vim.command("map <buffer> "+ub_get_option('ub_hotkey_pagedown')+" :py ub_find(%d,%s)<cr>" % (self.pageNo+1, ','.join(["'%s'" % kw for kw in self.keywords])))
- vim.command("map <buffer> "+ub_get_option('ub_hotkey_pageup')+" :py ub_find(%d,%s)<cr>" % (self.pageNo-1, ','.join(["'%s'" % kw for kw in self.keywords])))
+ vim.command("map <buffer> "+ub_get_option('ub_hotkey_pagedown')+" :py ub_search(%d,%d,%s)<cr>" % (self.isRegexp, self.pageNo+1, ','.join(["'%s'" % kw for kw in self.keywords])))
+ vim.command("map <buffer> "+ub_get_option('ub_hotkey_pageup')+" :py ub_search(%d,%d,%s)<cr>" % (self.isRegexp, self.pageNo-1, ','.join(["'%s'" % kw for kw in self.keywords])))
vim.command('call UBClearUndo()')
vim.command('setl nomodified')
vim.command("setl nomodifiable")
@@ -475,6 +511,43 @@ def _exec(self):
vim.command("let @/='\\(%s\\)'" % '\\|'.join(self.keywords))
vim.command('setl hls')
+class UBCmdReplace(UBCommand):
+ ''' Context replace
+ '''
+ def __init__(self, isRegexp, needle, replacement):
+ UBCommand.__init__(self)
+ self.isRegexp = isRegexp
+ self.needle = needle
+ self.replacement = replacement
+ self.count = 0
+
+ def _preExec(self):
+ UBCmdReplace.doDefault()
+
+ def _exec(self):
+ conn = dbe.connect()
+ # Hook regexp function to sqlite3 if the current mode is regexp
+ if self.isRegexp:
+ conn.connection.create_function('REGEXP', 2, regexp_search)
+ conn.connection.create_function('regex_replace', 3, regex_replace)
+ sql_replace = "update post set title=regex_replace(title,:needle,:replacement),content=regex_replace(content,:needle,:replacement)"
+ sql_count = "select count(*) from post where title regexp :needle or content regexp :needle"
+ rslt = conn.execute(sql_count, {'needle':self.needle.decode(self.enc)})
+ self.count = rslt.fetchone()[0]
+ else:
+ sql_replace = "update post set title=replace(title,:needle,:replacement),content=replace(content,:needle,:replacement)"
+ needle = '%%%s%%' % self.needle.decode(self.enc)
+ self.count = self.sess.query(Post).filter(or_(Post.title.like(needle),Post.content.like(needle))).count()
+ conn.execute(sql_replace, {'needle':self.needle.decode(self.enc), 'replacement':self.replacement.decode(self.enc)})
+ conn.close()
+
+ def _postExec(self):
+ UBCmdReplace.doDefault()
+ evt = UBReplaceCompleteEvent(self.count)
+ UBEventQueue.fireEvent(evt)
+ UBEventQueue.processEvents()
+ ub_echo(_('%d items substituted !') % self.count)
+
class UBCmdSave(UBCommand):
''' Save items
'''
@@ -978,7 +1051,8 @@ def _exec(self):
if self.viewName == 'search_result_list':
kws = ub_get_bufvar('ub_keywords')
pno = ub_get_bufvar('page_no')
- ub_find(pno, *kws)
+ isregexp = ub_get_bufvar('is_regexp')
+ ub_search(isregexp, pno, *kws)
elif ub_is_view_of_type('list'):
psize = ub_get_bufvar('page_size')
pno = ub_get_bufvar('page_no')
View
199 plugin/ultrablog/db.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
import xmlrpclib,socket
-import util
+import util as u
try:
import sqlalchemy
@@ -84,104 +84,101 @@ def getMetaDict(self, encoding=None):
Template = None
except:pass
-def ub_upgrade():
- if db is not None:
- conn = db.connect()
- stmt = select([Post.type]).limit(1)
- try:
- result = conn.execute(stmt)
- except OperationalError:
- sql = "alter table post add type varchar(32) not null default 'post'"
- conn.execute(sql)
-
- stmt = select([Post.status]).limit(1)
- try:
- result = conn.execute(stmt)
- except OperationalError:
- sql = "alter table post add status varchar(32) not null default 'draft'"
- conn.execute(sql)
-
- conn.close()
+def ub_upgrade(db):
+ conn = db.connect()
+ stmt = select([Post.type]).limit(1)
+ try:
+ conn.execute(stmt)
+ except OperationalError:
+ sql = "alter table post add type varchar(32) not null default 'post'"
+ conn.execute(sql)
+
+ stmt = select([Post.status]).limit(1)
+ try:
+ conn.execute(stmt)
+ except OperationalError:
+ sql = "alter table post add status varchar(32) not null default 'draft'"
+ conn.execute(sql)
+
+ conn.close()
def ub_init_template():
- if db is not None:
-
- sess = Session()
- tmpl = sess.query(Template).filter(Template.name=='default').first()
- if tmpl is None:
- tmpl = Template()
- tmpl.name = 'default'
- tmpl.description = 'The default template for previewing drafts.'
- tmpl.content = \
+ sess = Session()
+ tmpl = sess.query(Template).filter(Template.name=='default').first()
+ if tmpl is None:
+ tmpl = Template()
+ tmpl.name = 'default'
+ tmpl.description = 'The default template for previewing drafts.'
+ tmpl.content = \
'''<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>%(title)s</title>
- <style>
- body
- {
- font-family: "DejaVu Sans YuanTi","YaHei Consolas Hybrid","Microsoft YaHei";
- font-size: 14px;
- background-color: #D9DADC;
- }
-
- code
- {
- font-family: "Monaco","YaHei Consolas Hybrid";
- border: 1px solid #333;
- background-color: #DCDCDC;
- padding: 0px 3px;
- margin: 0px 5px;
- }
-
- pre
- {
- font-family: "Monaco","YaHei Consolas Hybrid";
- border: 1px solid #333;
- background-color: #B7D0DB;
- padding: 10px;
- }
-
- table,td,th {border-collapse: collapse;}
- table
- {
- border-left: 1px solid #333;
- border-bottom: 1px solid #333;
- }
- td,th
- {
- border-top: 1px solid #333;
- border-right: 1px solid #333;
- }
- th {background-color:#ebeff9;}
- td {padding: 5px;}
-
- blockquote {border: 1px dashed #333; background-color: #B7D0DB; padding: 10px;}
- img {margin-left:auto;margin-right:auto;padding:10px;border:1px solid #000;-moz-box-shadow:3px 3px 4px #000;-webkit-box-shadow:3px 3px 4px #000;box-shadow:3px 3px 4px #000;background:#fff;filter:progid:DXImageTransform.Microsoft.Shadow(Strength=4,Direction=135,Color='#000000');}
- a img{padding:10px;border:1px solid #000;-moz-box-shadow:3px 3px 4px #000;-webkit-box-shadow:3px 3px 4px #000;box-shadow:3px 3px 4px #000;background:#fff;filter:progid:DXImageTransform.Microsoft.Shadow(Strength=4,Direction=135,Color='#000000');}
-
- .container {width: 80%%;margin:0px auto;padding:20px;background-color: #FFFFFF;}
- .title {font-size: 24px; font-weight: bold;}
- .content {}
- </style>
- </head>
- <body>
- <div class="container">
- <div class="title">%(title)s</div>
- <div class="content">
- %(content)s
- </div>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>%(title)s</title>
+ <style>
+ body
+ {
+ font-family: "DejaVu Sans YuanTi","YaHei Consolas Hybrid","Microsoft YaHei";
+ font-size: 14px;
+ background-color: #D9DADC;
+ }
+
+ code
+ {
+ font-family: "Monaco","YaHei Consolas Hybrid";
+ border: 1px solid #333;
+ background-color: #DCDCDC;
+ padding: 0px 3px;
+ margin: 0px 5px;
+ }
+
+ pre
+ {
+ font-family: "Monaco","YaHei Consolas Hybrid";
+ border: 1px solid #333;
+ background-color: #B7D0DB;
+ padding: 10px;
+ }
+
+ table,td,th {border-collapse: collapse;}
+ table
+ {
+ border-left: 1px solid #333;
+ border-bottom: 1px solid #333;
+ }
+ td,th
+ {
+ border-top: 1px solid #333;
+ border-right: 1px solid #333;
+ }
+ th {background-color:#ebeff9;}
+ td {padding: 5px;}
+
+ blockquote {border: 1px dashed #333; background-color: #B7D0DB; padding: 10px;}
+ img {margin-left:auto;margin-right:auto;padding:10px;border:1px solid #000;-moz-box-shadow:3px 3px 4px #000;-webkit-box-shadow:3px 3px 4px #000;box-shadow:3px 3px 4px #000;background:#fff;filter:progid:DXImageTransform.Microsoft.Shadow(Strength=4,Direction=135,Color='#000000');}
+ a img{padding:10px;border:1px solid #000;-moz-box-shadow:3px 3px 4px #000;-webkit-box-shadow:3px 3px 4px #000;box-shadow:3px 3px 4px #000;background:#fff;filter:progid:DXImageTransform.Microsoft.Shadow(Strength=4,Direction=135,Color='#000000');}
+
+ .container {width: 80%%;margin:0px auto;padding:20px;background-color: #FFFFFF;}
+ .title {font-size: 24px; font-weight: bold;}
+ .content {}
+ </style>
+</head>
+<body>
+ <div class="container">
+ <div class="title">%(title)s</div>
+ <div class="content">
+ %(content)s
</div>
- </body>
+ </div>
+</body>
</html>'''
- sess.add(tmpl)
- sess.commit()
- sess.close()
+ sess.add(tmpl)
+ sess.commit()
+ sess.close()
-def ub_set_mode():
+def ub_set_mode(db):
'''Set editor mode according to the option ub_editor_mode
'''
- editor_mode = util.ub_get_option('ub_editor_mode')
+ editor_mode = u.ub_get_option('ub_editor_mode')
if '1' == editor_mode:
Session.configure(bind=db)
Base.metadata.create_all(db)
@@ -189,23 +186,25 @@ def ub_set_mode():
cfg = None
try:
- cfg = util.ub_get_blog_settings()
+ cfg = u.ub_get_blog_settings()
except KeyError,e:
- msg = 'Missing key %s in the settings list of UltraBlog.vim !' % str(e)
- util.ub_echoerr(msg)
+ msg = _('Missing key %s in the settings list of UltraBlog.vim !') % str(e)
+ u.ub_echoerr(msg)
except:
pass
try:
- socket.setdefaulttimeout(util.ub_get_option('ub_socket_timeout'))
+ socket.setdefaulttimeout(u.ub_get_option('ub_socket_timeout'))
api = xmlrpclib.ServerProxy(cfg.xmlrpc)
- db = sqlalchemy.create_engine("sqlite:///%s" % cfg.dbf)
+ dbe = sqlalchemy.create_engine("sqlite:///%s" % cfg.dbf)
+ dbg_enabled = u.ub_get_option('ub_debug')
+ if dbg_enabled == 1: dbe.echo = True
- Session.configure(bind=db)
- Base.metadata.create_all(db)
+ Session.configure(bind=dbe)
+ Base.metadata.create_all(dbe)
- ub_upgrade()
+ ub_upgrade(dbe)
ub_init_template()
except:
api = None
- db = None
+ dbe = None
View
1 plugin/ultrablog/events.py
@@ -15,6 +15,7 @@ class UBPostSendEvent(UBEvent): pass
class UBPostSaveEvent(UBEvent): pass
class UBViewEnterEvent(UBEvent): pass
+class UBReplaceCompleteEvent(UBEvent): pass
if __name__ == '__main__':
pass
View
17 plugin/ultrablog/listeners.py
@@ -160,6 +160,22 @@ def processEvent(evt):
vim.command('setl nowrap')
vim.command("command! -buffer -nargs=0 UBRefresh exec('py ub_refresh_current_view()')")
+class UBReplaceCompleteListener(UBListener):
+ ''' Listener for context replacement event
+ 1. Refresh the current view if it is an list view of this post
+ 2. Mark all list views of posts/pages outdated
+ '''
+ eventType = UBReplaceCompleteEvent
+
+ @staticmethod
+ def processEvent(evt):
+ if evt.srcObj <= 0: return
+ for nr in ub_get_buffers(['post_edit','page_edit','post_list','page_list','search_result_list']):
+ if nr == ub_get_bufnr('%'):
+ ub_refresh_current_view()
+ else:
+ ub_set_view_outdated(nr)
+
UBEventQueue.registerListener(UBDebugListener)
UBEventQueue.registerListener(UBTmplDelListener)
UBEventQueue.registerListener(UBTmplSaveListener)
@@ -168,6 +184,7 @@ def processEvent(evt):
UBEventQueue.registerListener(UBPostSendListener)
UBEventQueue.registerListener(UBPostSaveListener)
UBEventQueue.registerListener(UBViewEnterListener)
+UBEventQueue.registerListener(UBReplaceCompleteListener)
if __name__ == '__main__':
pass
View
23 plugin/ultrablog/util.py 100644 → 100755
@@ -227,6 +227,8 @@ def __get_positive(val, default):
val = val is None and '<c-pagedown>' or val
elif opt == 'ub_hotkey_pageup':
val = val is None and '<c-pageup>' or val
+ elif opt == 'ub_hotkey_save_current_item':
+ val = val is None and '<c-s>' or val
elif opt == 'ub_tmpl_img_url':
val = val is None and "markdown###![%(file)s][]\n[%(file)s]:%(url)s" or val
elif opt == 'ub_default_template':
@@ -239,6 +241,8 @@ def __get_positive(val, default):
val = __get_positive(val, 30)
elif opt == 'ub_socket_timeout':
val = __get_positive(val, 10)
+ elif opt == 'ub_debug':
+ val = __get_positive(val, 0)
if deal:
if opt == 'ub_tmpl_img_url':
@@ -605,5 +609,20 @@ def ub_echo(msg):
cmd = '''echo "%s"''' % msg.replace('"', "'")
vim.command(cmd)
-if __name__ == '__main__':
- pass
+def raw(text):
+ """Returns a raw string representation of text"""
+ escape_dict={'\a':r'\a', '\b':r'\b', '\c':r'\c', '\f':r'\f', '\n':r'\n',
+ '\r':r'\r', '\t':r'\t', '\v':r'\v', '\'':r'\'', '\"':r'\"',
+ '\0':r'\0', '\1':r'\1', '\2':r'\2', '\3':r'\3', '\4':r'\4',
+ '\5':r'\5', '\6':r'\6', '\7':r'\7', '\8':r'\8', '\9':r'\9'}
+ return "".join([escape_dict.get(char,char) for char in text])
+
+def regex_replace(string, expr, repl):
+ """Do substitutions on the string for repls matching the expr"""
+ r = re.compile(raw(expr))
+ return r.sub(repl, string)
+
+def regexp_search(expr, item):
+ """Check if the item has a sub-string which matches the expr"""
+ reg = re.compile(expr)
+ return reg.search(item) is not None

No commit comments for this range

Something went wrong with that request. Please try again.