Skip to content
Browse files

Added support for Queryposts.com and changed the word ordering to mak…

…e more sense for searches
  • Loading branch information...
1 parent d23f3b6 commit f6b01b089cc21f66b3cd09ae4c60e0cecd984bc7 @Tarendai Tarendai committed Feb 18, 2013
Showing with 73 additions and 1 deletion.
  1. +2 −0 .gitignore
  2. +9 −1 Context.sublime-menu
  3. +12 −0 Default.sublime-commands
  4. +8 −0 Main.sublime-menu
  5. +42 −0 WordPressCodex.py
View
2 .gitignore
@@ -0,0 +1,2 @@
+
+*.pyc
View
10 Context.sublime-menu
@@ -1,10 +1,18 @@
[
{
"command": "wordpress_codex_search_selection",
- "caption": "WordPress Codex Search"
+ "caption": "Search WordPress Codex"
},
{
"command": "wordpress_codex_open_selection",
"caption": "WordPress Function Reference"
+ },
+ {
+ "command": "query_posts_search_selection",
+ "caption": "Search QueryPosts"
+ },
+ {
+ "command": "query_posts_open_selection",
+ "caption": "QueryPosts Function Reference"
}
]
View
12 Default.sublime-commands
@@ -10,5 +10,17 @@
{
"caption": "WordPress Codex: Search from Input",
"command": "wordpress_codex_search_from_input"
+ },
+ {
+ "caption": "WP Queryposts: Search Selection",
+ "command": "query_posts_search_selection"
+ },
+ {
+ "caption": "WP QueryPosts: Open Function Reference",
+ "command": "query_posts_codex_open_selection"
+ },
+ {
+ "caption": "WP Queryposts: Search from Input",
+ "command": "query_posts_search_from_input"
}
]
View
8 Main.sublime-menu
@@ -18,6 +18,14 @@
{
"command": "wordpress_codex_search_from_input",
"caption": "Search From Input"
+ },
+ {
+ "command": "query_posts_search_selection",
+ "caption": "Search Selection"
+ },
+ {
+ "command": "query_posts_search_from_input",
+ "caption": "Search From Input"
}
]
}
View
42 WordPressCodex.py
@@ -16,10 +16,18 @@ def SearchWpCodexFor(text):
url = 'http://wordpress.org/search/' + text.replace(' ','%20')
webbrowser.open_new_tab(url)
+def SearchQPFor(text):
+ url = 'http://queryposts.com/?s=' + text.replace(' ','%20')
+ webbrowser.open_new_tab(url)
+
def OpenWpFunctionReference(text):
url = 'http://codex.wordpress.org/Function_Reference/' + text.replace(' ','%20')
webbrowser.open_new_tab(url)
+def OpenQPFunctionReference(text):
+ url = 'http://queryposts.com/function/' + text.replace(' ','%20')
+ webbrowser.open_new_tab(url)
+
class WordpressCodexOpenSelectionCommand(sublime_plugin.TextCommand):
def run(self, edit):
for selection in self.view.sel():
@@ -52,4 +60,38 @@ def on_change(self, input):
pass
def on_cancel(self):
+ pass
+# query_posts_search_selection
+class QueryPostsOpenSelectionCommand(sublime_plugin.TextCommand):
+ def run(self, edit):
+ for selection in self.view.sel():
+ # if the user didn't select anything, search the currently highlighted word
+ if selection.empty():
+ selection = self.view.word(selection)
+
+ text = self.view.substr(selection)
+ OpenQPFunctionReference(text)
+
+class QueryPostsSearchSelectionCommand(sublime_plugin.TextCommand):
+ def run(self, edit):
+ for selection in self.view.sel():
+ # if the user didn't select anything, search the currently highlighted word
+ if selection.empty():
+ selection = self.view.word(selection)
+
+ text = self.view.substr(selection)
+ SearchQPFor(text)
+
+class QueryPostsSearchFromInputCommand(sublime_plugin.WindowCommand):
+ def run(self):
+ # Get the search item
+ self.window.show_input_panel('Search QueryPosts.com for', '',
+ self.on_done, self.on_change, self.on_cancel)
+ def on_done(self, input):
+ SearchQPFor(input)
+
+ def on_change(self, input):
+ pass
+
+ def on_cancel(self):
pass

0 comments on commit f6b01b0

Please sign in to comment.
Something went wrong with that request. Please try again.