-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRedaxoapi.py
executable file
·51 lines (35 loc) · 1.39 KB
/
Redaxoapi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Original Version for CakePHP written by Jad Bitar (@jadb / www.jadbitar.com)
# ripped of by jdlx for Redaxo API Searches..
# available commands
# redaxoapi_search_selection
# redaxoapi_search_from_input
# changelog
# Jad Bitar - first implementation of search selection and search from input
# SETTINGS: Redaxo Version - currently available: "4.2.1" , "4.3.1" , "4.3.2" , "4.4.1", "5.x.x"
rex_version = '4.4.1'
import sublime
import sublime_plugin
import subprocess
import webbrowser
def SearchFor(text):
url = 'http://docs.redaxo.com/en/' + rex_version + '/search.php?query=' + text.replace(' ', '%20')
webbrowser.open_new_tab(url)
class RedaxoapiSearchSelectionCommand(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():
text = self.view.word(selection)
text = self.view.substr(selection)
SearchFor(text)
class RedaxoapiSearchFromInputCommand(sublime_plugin.WindowCommand):
def run(self):
# Get the search item
self.window.show_input_panel('Search Redaxo API for', '',
self.on_done, self.on_change, self.on_cancel)
def on_done(self, input):
SearchFor(input)
def on_change(self, input):
pass
def on_cancel(self):
pass