rwiki 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. data/Capfile +2 -0
  2. data/Gemfile +30 -0
  3. data/Rakefile +22 -65
  4. data/VERSION +1 -1
  5. data/config.ru +11 -0
  6. data/config/config.yml.example +1 -0
  7. data/config/deploy.rb +37 -0
  8. data/features/create_page.feature +30 -20
  9. data/features/delete_page.feature +23 -18
  10. data/features/display_page.feature +10 -11
  11. data/features/editor.feature +45 -0
  12. data/features/history.feature +46 -0
  13. data/features/rename_page.feature +42 -37
  14. data/features/step_definitions/common_steps.rb +19 -47
  15. data/features/step_definitions/common_transforms.rb +5 -0
  16. data/features/step_definitions/dialog_box_steps.rb +16 -0
  17. data/features/step_definitions/history_steps.rb +11 -0
  18. data/features/step_definitions/tab_panel_steps.rb +27 -0
  19. data/features/step_definitions/tree_panel_steps.rb +42 -0
  20. data/features/step_definitions/wait_steps.rb +21 -0
  21. data/features/support/env.rb +6 -0
  22. data/features/tab_panel.feature +47 -0
  23. data/features/tree_panel.feature +14 -15
  24. data/lib/rwiki.rb +1 -0
  25. data/lib/rwiki/app.rb +14 -2
  26. data/lib/rwiki/models/folder.rb +1 -1
  27. data/lib/rwiki/models/node.rb +11 -1
  28. data/lib/rwiki/models/page.rb +1 -1
  29. data/public/favicon.ico +0 -0
  30. data/public/images/compressed.png +0 -0
  31. data/public/images/css.png +0 -0
  32. data/public/images/file.png +0 -0
  33. data/public/images/html.png +0 -0
  34. data/public/images/icon_word.png +0 -0
  35. data/public/images/image.png +0 -0
  36. data/public/images/javascript.png +0 -0
  37. data/public/images/pdf.png +0 -0
  38. data/public/images/php.png +0 -0
  39. data/public/images/presentation.png +0 -0
  40. data/public/images/ruby.png +0 -0
  41. data/public/images/shellscript.png +0 -0
  42. data/public/images/stylesheet.png +0 -0
  43. data/public/images/text.png +0 -0
  44. data/public/images/wordprocessing.png +0 -0
  45. data/public/javascripts/Rwiki.js +71 -29
  46. data/public/javascripts/Rwiki/EditorPanel.js +5 -37
  47. data/public/javascripts/Rwiki/EditorPanel/Editor.js +8 -44
  48. data/public/javascripts/Rwiki/EditorWindow.js +66 -0
  49. data/public/javascripts/Rwiki/FuzzyFinderDialog.js +61 -0
  50. data/public/javascripts/Rwiki/NavigationPanel.js +25 -0
  51. data/public/javascripts/Rwiki/NodeManager.js +2 -0
  52. data/public/javascripts/Rwiki/TabPanel.js +39 -2
  53. data/public/javascripts/Rwiki/TreePanel.js +39 -26
  54. data/public/javascripts/Rwiki/TreePanel/Menu.js +1 -1
  55. data/public/javascripts/Rwiki/TreePanel/Node.js +46 -0
  56. data/public/javascripts/vendor/ext/adapter/ext/ext-base-debug.js +836 -710
  57. data/public/javascripts/vendor/ext/adapter/ext/ext-base.js +5 -5
  58. data/public/javascripts/vendor/ext/adapter/jquery/ext-jquery-adapter-debug.js +47 -700
  59. data/public/javascripts/vendor/ext/adapter/jquery/ext-jquery-adapter.js +5 -5
  60. data/public/javascripts/vendor/ext/adapter/prototype/ext-prototype-adapter-debug.js +45 -698
  61. data/public/javascripts/vendor/ext/adapter/prototype/ext-prototype-adapter.js +5 -5
  62. data/public/javascripts/vendor/ext/adapter/yui/ext-yui-adapter-debug.js +39 -696
  63. data/public/javascripts/vendor/ext/adapter/yui/ext-yui-adapter.js +5 -5
  64. data/public/javascripts/vendor/ext/ext-all-debug-w-comments.js +17932 -12860
  65. data/public/javascripts/vendor/ext/ext-all-debug.js +11674 -8102
  66. data/public/javascripts/vendor/ext/ext-all.js +6 -6
  67. data/public/javascripts/vendor/ext/ux/StatusBar.js +418 -0
  68. data/public/resources/ext/charts.swf +0 -0
  69. data/public/resources/ext/css/debug.css +4 -4
  70. data/public/resources/ext/css/ext-all-notheme.css +204 -52
  71. data/public/resources/ext/css/ext-all.css +234 -54
  72. data/public/resources/ext/css/reset-min.css +4 -4
  73. data/public/resources/ext/css/structure/borders.css +4 -4
  74. data/public/resources/ext/css/structure/box.css +4 -4
  75. data/public/resources/ext/css/structure/button.css +7 -7
  76. data/public/resources/ext/css/structure/combo.css +4 -4
  77. data/public/resources/ext/css/structure/core.css +15 -5
  78. data/public/resources/ext/css/structure/date-picker.css +4 -4
  79. data/public/resources/ext/css/structure/dd.css +4 -4
  80. data/public/resources/ext/css/structure/debug.css +4 -4
  81. data/public/resources/ext/css/structure/dialog.css +6 -9
  82. data/public/resources/ext/css/structure/editor.css +4 -4
  83. data/public/resources/ext/css/structure/form.css +14 -4
  84. data/public/resources/ext/css/structure/grid.css +15 -5
  85. data/public/resources/ext/css/structure/layout.css +7 -7
  86. data/public/resources/ext/css/structure/list-view.css +4 -4
  87. data/public/resources/ext/css/structure/menu.css +13 -6
  88. data/public/resources/ext/css/structure/panel-reset.css +4 -4
  89. data/public/resources/ext/css/structure/panel.css +70 -22
  90. data/public/resources/ext/css/structure/pivotgrid.css +65 -0
  91. data/public/resources/ext/css/structure/progress.css +4 -4
  92. data/public/resources/ext/css/structure/qtips.css +4 -4
  93. data/public/resources/ext/css/structure/reset.css +11 -5
  94. data/public/resources/ext/css/structure/resizable.css +4 -4
  95. data/public/resources/ext/css/structure/slider.css +4 -4
  96. data/public/resources/ext/css/structure/tabs.css +13 -8
  97. data/public/resources/ext/css/structure/toolbar.css +5 -5
  98. data/public/resources/ext/css/structure/tree.css +11 -11
  99. data/public/resources/ext/css/structure/window.css +5 -5
  100. data/public/resources/ext/css/theme-access/borders.css +4 -4
  101. data/public/resources/ext/css/theme-access/box.css +4 -4
  102. data/public/resources/ext/css/theme-access/button.css +4 -4
  103. data/public/resources/ext/css/theme-access/combo.css +4 -4
  104. data/public/resources/ext/css/theme-access/core.css +4 -4
  105. data/public/resources/ext/css/theme-access/date-picker.css +4 -4
  106. data/public/resources/ext/css/theme-access/dd.css +4 -4
  107. data/public/resources/ext/css/theme-access/debug.css +4 -4
  108. data/public/resources/ext/css/theme-access/dialog.css +4 -4
  109. data/public/resources/ext/css/theme-access/editor.css +4 -4
  110. data/public/resources/ext/css/theme-access/form.css +4 -4
  111. data/public/resources/ext/css/theme-access/grid.css +4 -4
  112. data/public/resources/ext/css/theme-access/layout.css +4 -4
  113. data/public/resources/ext/css/theme-access/list-view.css +8 -4
  114. data/public/resources/ext/css/theme-access/menu.css +4 -4
  115. data/public/resources/ext/css/theme-access/panel.css +4 -4
  116. data/public/resources/ext/css/theme-access/progress.css +4 -4
  117. data/public/resources/ext/css/theme-access/qtips.css +4 -4
  118. data/public/resources/ext/css/theme-access/resizable.css +4 -4
  119. data/public/resources/ext/css/theme-access/slider.css +4 -4
  120. data/public/resources/ext/css/theme-access/tabs.css +4 -4
  121. data/public/resources/ext/css/theme-access/toolbar.css +4 -4
  122. data/public/resources/ext/css/theme-access/tree.css +4 -4
  123. data/public/resources/ext/css/theme-access/window.css +5 -5
  124. data/public/resources/ext/css/theme-gray/borders.css +4 -4
  125. data/public/resources/ext/css/theme-gray/box.css +4 -4
  126. data/public/resources/ext/css/theme-gray/button.css +4 -4
  127. data/public/resources/ext/css/theme-gray/combo.css +4 -4
  128. data/public/resources/ext/css/theme-gray/core.css +6 -4
  129. data/public/resources/ext/css/theme-gray/date-picker.css +4 -4
  130. data/public/resources/ext/css/theme-gray/dd.css +4 -4
  131. data/public/resources/ext/css/theme-gray/debug.css +4 -4
  132. data/public/resources/ext/css/theme-gray/dialog.css +4 -4
  133. data/public/resources/ext/css/theme-gray/editor.css +4 -4
  134. data/public/resources/ext/css/theme-gray/form.css +4 -4
  135. data/public/resources/ext/css/theme-gray/grid.css +10 -6
  136. data/public/resources/ext/css/theme-gray/layout.css +4 -4
  137. data/public/resources/ext/css/theme-gray/list-view.css +5 -5
  138. data/public/resources/ext/css/theme-gray/menu.css +4 -4
  139. data/public/resources/ext/css/theme-gray/panel.css +4 -4
  140. data/public/resources/ext/css/theme-gray/pivotgrid.css +28 -0
  141. data/public/resources/ext/css/theme-gray/progress.css +4 -4
  142. data/public/resources/ext/css/theme-gray/qtips.css +4 -4
  143. data/public/resources/ext/css/theme-gray/resizable.css +4 -4
  144. data/public/resources/ext/css/theme-gray/slider.css +4 -4
  145. data/public/resources/ext/css/theme-gray/tabs.css +4 -4
  146. data/public/resources/ext/css/theme-gray/toolbar.css +4 -4
  147. data/public/resources/ext/css/theme-gray/tree.css +4 -4
  148. data/public/resources/ext/css/theme-gray/window.css +4 -4
  149. data/public/resources/ext/css/visual/borders.css +4 -4
  150. data/public/resources/ext/css/visual/box.css +4 -4
  151. data/public/resources/ext/css/visual/button.css +4 -4
  152. data/public/resources/ext/css/visual/combo.css +4 -4
  153. data/public/resources/ext/css/visual/core.css +6 -4
  154. data/public/resources/ext/css/visual/date-picker.css +4 -4
  155. data/public/resources/ext/css/visual/dd.css +4 -4
  156. data/public/resources/ext/css/visual/debug.css +4 -4
  157. data/public/resources/ext/css/visual/dialog.css +4 -4
  158. data/public/resources/ext/css/visual/editor.css +4 -4
  159. data/public/resources/ext/css/visual/form.css +4 -4
  160. data/public/resources/ext/css/visual/grid.css +8 -4
  161. data/public/resources/ext/css/visual/layout.css +4 -4
  162. data/public/resources/ext/css/visual/list-view.css +4 -4
  163. data/public/resources/ext/css/visual/menu.css +4 -4
  164. data/public/resources/ext/css/visual/panel.css +4 -4
  165. data/public/resources/ext/css/visual/pivotgrid.css +28 -0
  166. data/public/resources/ext/css/visual/progress.css +4 -4
  167. data/public/resources/ext/css/visual/qtips.css +4 -4
  168. data/public/resources/ext/css/visual/resizable.css +4 -4
  169. data/public/resources/ext/css/visual/slider.css +4 -4
  170. data/public/resources/ext/css/visual/tabs.css +4 -4
  171. data/public/resources/ext/css/visual/toolbar.css +5 -5
  172. data/public/resources/ext/css/visual/tree.css +4 -4
  173. data/public/resources/ext/css/visual/window.css +4 -4
  174. data/public/resources/ext/css/xtheme-access.css +9 -5
  175. data/public/resources/ext/css/xtheme-blue.css +34 -6
  176. data/public/resources/ext/css/xtheme-gray.css +35 -7
  177. data/public/resources/ext/css/yourtheme.css +11 -5
  178. data/public/resources/ext/images/access/panel/tool-sprites.gif +0 -0
  179. data/public/resources/ext/images/default/grid/grid3-rowheader.gif +0 -0
  180. data/public/resources/ext/images/default/grid/refresh-disabled.gif +0 -0
  181. data/public/resources/ext/images/default/panel/tool-sprites.gif +0 -0
  182. data/public/resources/ext/images/gray/grid/sort-hd.gif +0 -0
  183. data/public/resources/ext/images/gray/panel/tool-sprites.gif +0 -0
  184. data/public/resources/ext/images/gray/window/left-corners.png +0 -0
  185. data/public/resources/ext/images/gray/window/left-right.png +0 -0
  186. data/public/resources/ext/images/gray/window/right-corners.png +0 -0
  187. data/public/resources/ext/images/gray/window/top-bottom.png +0 -0
  188. data/public/stylesheets/coderay.css +3 -0
  189. data/public/stylesheets/markitup.css +19 -0
  190. data/public/stylesheets/style.css +1 -1
  191. data/run_tests.sh +1 -0
  192. data/rwiki.gemspec +56 -37
  193. data/test/fixtures/pages/Info/dummy +0 -0
  194. data/test/rwiki/models/test_folder.rb +4 -4
  195. data/vendor/.gitkeep +0 -0
  196. data/views/layout.erb +13 -5
  197. metadata +78 -69
  198. data/.idea/projectCodeStyle.xml +0 -80
  199. data/.rvmrc +0 -1
  200. data/public/javascripts/Rwiki/SidePanel.js +0 -26
  201. data/public/javascripts/Rwiki/Toolbar.js +0 -31
  202. data/public/javascripts/Rwiki/Viewport.js +0 -10
  203. data/tmp/ExtDesigner/MyViewport.js +0 -18
  204. data/tmp/ExtDesigner/MyViewport.ui.js +0 -29
  205. data/tmp/ExtDesigner/Rwiki.EditorPanel.js +0 -19
  206. data/tmp/ExtDesigner/Rwiki.EditorPanel.ui.js +0 -27
  207. data/tmp/ExtDesigner/Rwiki.MainPanel.js +0 -19
  208. data/tmp/ExtDesigner/Rwiki.MainPanel.ui.js +0 -29
  209. data/tmp/ExtDesigner/Rwiki.TabPane.PageTab.js +0 -19
  210. data/tmp/ExtDesigner/Rwiki.TabPane.PageTab.ui.js +0 -19
  211. data/tmp/ExtDesigner/Rwiki.TabPanel.js +0 -19
  212. data/tmp/ExtDesigner/Rwiki.TabPanel.ui.js +0 -27
  213. data/tmp/ExtDesigner/Rwiki.TreePanel.js +0 -19
  214. data/tmp/ExtDesigner/Rwiki.TreePanel.ui.js +0 -27
  215. data/tmp/ExtDesigner/Rwiki.Viewport.js +0 -18
  216. data/tmp/ExtDesigner/Rwiki.Viewport.ui.js +0 -30
  217. data/tmp/ExtDesigner/rwiki.xds +0 -192
  218. data/tmp/ExtDesigner/xds_includeOrder.txt +0 -12
  219. data/tmp/ExtDesigner/xds_index.html +0 -26
  220. data/tmp/ExtDesigner/xds_index.js +0 -19
@@ -6,6 +6,7 @@ require 'json/pure'
6
6
  require 'redcloth'
7
7
  require 'sinatra'
8
8
  require 'sinatra/base'
9
+ require 'fuzzy_file_finder'
9
10
 
10
11
  module Rwiki
11
12
 
@@ -2,10 +2,12 @@ module Rwiki
2
2
  class App < Sinatra::Base
3
3
  include Models
4
4
 
5
- set :raise_errors, false
6
- set :show_exceptions, false
7
5
  set :root, File.join(File.dirname(__FILE__), '../..')
8
6
 
7
+ disable :raise_errors
8
+ disable :show_exceptions
9
+ disable :logging
10
+
9
11
  error NodeNotFoundError do
10
12
  message = request.env['sinatra.error'].message
11
13
  { :success => false, :message => message }.to_json
@@ -55,6 +57,7 @@ module Rwiki
55
57
 
56
58
  result = node.to_hash
57
59
  result[:parentPath] = parent_folder.path
60
+
58
61
  result.to_json
59
62
  end
60
63
 
@@ -67,6 +70,7 @@ module Rwiki
67
70
 
68
71
  result = node.to_hash
69
72
  result[:oldPath] = path
73
+
70
74
  result.to_json
71
75
  end
72
76
 
@@ -81,6 +85,7 @@ module Rwiki
81
85
  result = node.to_hash
82
86
  result[:oldPath] = path
83
87
  result[:success] = true
88
+
84
89
  result.to_json
85
90
  end
86
91
 
@@ -91,5 +96,12 @@ module Rwiki
91
96
 
92
97
  { :path => node.path }.to_json
93
98
  end
99
+
100
+ get '/fuzzy_finder' do
101
+ query = params[:query]
102
+ matches = Node.fuzzy_finder(query)
103
+
104
+ { :results => matches, :count => matches.size }.to_json
105
+ end
94
106
  end
95
107
  end
@@ -28,7 +28,7 @@ module Rwiki::Models
28
28
  new_page_full_path = self.class.full_path_for(new_page_path)
29
29
  raise Rwiki::NodeError.new("#{new_page_path} already exists") if File.exists?(new_page_full_path)
30
30
 
31
- FileUtils.touch(new_page_full_path)
31
+ File.open(new_page_full_path, 'w') { |f| f.write("h1. #{name.gsub(/\.txt$/, '')}\n\n") }
32
32
  return Page.new(new_page_path)
33
33
  end
34
34
 
@@ -15,6 +15,16 @@ module Rwiki::Models
15
15
  def working_path=(path)
16
16
  @@working_path = path
17
17
  end
18
+
19
+ def fuzzy_finder(query)
20
+ @finder ||= FuzzyFileFinder.new(full_path_for('.'))
21
+ matches = @finder.find(query).sort_by { |m| [-m[:score], m[:path]] }
22
+ matches.each do |m|
23
+ m[:path] = '.' + m[:path].gsub(full_path_for('.'), '')
24
+ end
25
+
26
+ return matches
27
+ end
18
28
  end
19
29
 
20
30
  def self.new_from_path(path)
@@ -32,7 +42,7 @@ module Rwiki::Models
32
42
  end
33
43
 
34
44
  def parent_folder
35
- return Folder.new(File.dirname(@path))
45
+ Folder.new(File.dirname(@path))
36
46
  end
37
47
 
38
48
  def delete
@@ -65,7 +65,7 @@ module Rwiki::Models
65
65
  @raw_content = raw_content.gsub(CODE_REGEXP) do
66
66
  code = $3 || ''
67
67
  lang = $2
68
- "<notextile>#{CodeRay.scan(code.strip, lang).html(:line_numbers => :table).div(:css => :class)}</notextile>"
68
+ "<notextile>#{CodeRay.scan(code.strip, lang).html.div(:css => :class)}</notextile>"
69
69
  end
70
70
  end
71
71
 
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -14,58 +14,100 @@ Rwiki.captureEvents = function(observable) {
14
14
 
15
15
  Rwiki.init = function() {
16
16
 
17
+ // TabPanel history
18
+ Ext.History.init();
19
+
20
+ var firstLoad = true;
21
+
17
22
  // TODO find better solution
18
- Rwiki.ajaxCallInProgress = false;
19
- $(document).ajaxStart(function() {
20
- Rwiki.ajaxCallInProgress = true;
21
- }).ajaxStop(function() {
22
- Rwiki.ajaxCallInProgress = false;
23
- });
23
+ Rwiki.ajaxCallCompleted = true;
24
+ Rwiki.treeLoaded = false;
24
25
 
25
- var toolbar = new Rwiki.Toolbar();
26
26
  var treePanel = new Rwiki.TreePanel();
27
27
  Rwiki.treePanel = treePanel;
28
- var treePanelContextMenu = new Rwiki.TreePanel.Menu();
29
- treePanel.setContextMenu(treePanelContextMenu);
30
28
  var nodeManager = Rwiki.NodeManager.getInstance();
31
29
 
30
+ nodeManager.on('rwiki:beforePageLoad', function() {
31
+ Rwiki.ajaxCallCompleted = false;
32
+ });
33
+
34
+ nodeManager.on('rwiki:pageLoaded', function() {
35
+ Rwiki.ajaxCallCompleted = true;
36
+ });
37
+
38
+ treePanel.getLoader().on('load', function() {
39
+ Rwiki.treeLoaded = true;
40
+ Rwiki.treePanel.openNodeFromLocationHash();
41
+ });
42
+
32
43
  treePanel.relayEvents(nodeManager,
33
- ['rwiki:folderCreated', 'rwiki:pageCreated', 'rwiki:nodeRenamed', 'rwiki:nodeDeleted']);
44
+ ['rwiki:pageLoaded', 'rwiki:folderCreated', 'rwiki:pageCreated', 'rwiki:nodeRenamed', 'rwiki:nodeDeleted']);
34
45
 
35
46
  var tabPanel = new Rwiki.TabPanel();
47
+ Rwiki.tabPanel = tabPanel;
36
48
  tabPanel.relayEvents(nodeManager,
37
49
  ['rwiki:pageLoaded', 'rwiki:folderCreated', 'rwiki:pageCreated', 'rwiki:pageSaved', 'rwiki:nodeRenamed', 'rwiki:nodeDeleted']);
38
50
  tabPanel.relayEvents(treePanel, ['pageSelected']);
39
51
 
40
52
  var editorPanel = new Rwiki.EditorPanel();
41
- editorPanel.relayEvents(nodeManager,
42
- ['rwiki:pageLoaded', 'rwiki:nodeRenamed', 'rwiki:nodeDeleted', 'rwiki:lastPageClosed']);
43
- editorPanel.relayEvents(toolbar, ['editorToggled']);
53
+ editorPanel.relayEvents(Rwiki.NodeManager.getInstance(), ['rwiki:pageLoaded']);
44
54
 
45
- // Create layout
55
+ var window = new Rwiki.EditorWindow(editorPanel);
46
56
 
47
- var sidePanel = new Rwiki.SidePanel({
48
- items: [treePanel]
49
- });
57
+ function showEditor(path) {
58
+ if (!window.isVisible()) {
59
+ window.setPagePath(path);
60
+ window.show();
61
+ }
62
+ }
50
63
 
51
- sidePanel.relayEvents(toolbar, ['treeToggled']);
64
+ tabPanel.on('rwiki:editPage', function(path) {
65
+ showEditor(path);
66
+ });
52
67
 
53
- var pageAndEditorPanel = new Ext.Panel({
54
- layout: 'border',
55
- region: 'center',
56
- items: [tabPanel, editorPanel]
68
+ // Handle this change event in order to restore the UI to the appropriate history state
69
+ Ext.History.on('change', function() {
70
+ Rwiki.treePanel.openNodeFromLocationHash();
57
71
  });
58
72
 
59
- var mainPanel = new Ext.Panel({
60
- layout: 'border',
61
- region: 'center',
62
- tbar: toolbar,
63
- items: [sidePanel, pageAndEditorPanel]
73
+ // Create layout
74
+
75
+ var navigationPanel = new Rwiki.NavigationPanel({
76
+ items: [treePanel]
64
77
  });
65
78
 
66
- var app = new Rwiki.Viewport({
67
- items: [mainPanel]
79
+ var app = new Ext.Viewport({
80
+ layout: 'border',
81
+ plain: true,
82
+ renderTo: Ext.getBody(),
83
+ items: [navigationPanel, tabPanel]
68
84
  });
69
85
 
70
86
  app.show();
87
+
88
+ // map one key by key code
89
+ var map = new Ext.KeyMap(document, [{
90
+ key: "e",
91
+ alt: true,
92
+ stopEvent: true,
93
+ fn: function() {
94
+ tabPanel.onEditPage();
95
+ }
96
+ }, {
97
+ key: "t",
98
+ ctrl: true,
99
+ stopEvent: true,
100
+ fn: function() {
101
+ tabPanel.onFuzzyFinder();
102
+ }
103
+ }, {
104
+ key: "w",
105
+ ctrl: true,
106
+ stopEvent: true,
107
+ fn: function() {
108
+ var tab = tabPanel.getActiveTab();
109
+ tabPanel.remove(tab);
110
+ }
111
+ }]);
112
+
71
113
  };
@@ -3,13 +3,8 @@ Ext.ns('Rwiki');
3
3
  Rwiki.EditorPanel = Ext.extend(Ext.Panel, {
4
4
  constructor: function() {
5
5
  Ext.apply(this, {
6
- region: 'east',
7
6
  contentEl: 'editor-container',
8
7
  header: false,
9
- collapseMode: 'mini',
10
- split: true,
11
- collapsible: true,
12
- collapsed: true,
13
8
  height: 400,
14
9
 
15
10
  listeners: {
@@ -23,17 +18,13 @@ Rwiki.EditorPanel = Ext.extend(Ext.Panel, {
23
18
  });
24
19
 
25
20
  Rwiki.EditorPanel.superclass.constructor.apply(this, arguments);
26
- this.editor = new Rwiki.EditorPanel.Editor($('textarea#editor'));
21
+ this.editor = new Rwiki.EditorPanel.Editor();
27
22
  },
28
23
 
29
24
  initEvents: function() {
30
25
  Rwiki.EditorPanel.superclass.initEvents.apply(this, arguments);
31
26
 
32
27
  this.on('rwiki:pageLoaded', this.onPageLoaded);
33
- this.on('rwiki:nodeRenamed', this.onNodeRenamed);
34
- this.on('rwiki:nodeDeleted', this.onNodeDeleted);
35
- this.on('rwiki:lastPageClosed', this.onLastPageClosed);
36
- this.on('editorToggled', this.onEditorToggled);
37
28
  },
38
29
 
39
30
  onPageLoaded: function(data) {
@@ -41,34 +32,11 @@ Rwiki.EditorPanel = Ext.extend(Ext.Panel, {
41
32
  this.editor.setContent(data.rawContent);
42
33
  },
43
34
 
44
- onNodeRenamed: function(data) {
45
- var oldPath = data.oldPath;
46
- var currentPagePath = this.editor.getPagePath();
47
- if (currentPagePath == null) return;
48
-
49
- var isPage = oldPath.match(new RegExp('\.txt$'));
50
- var currentPageWasChanged = isPage && oldPath == currentPagePath;
51
- var parentPathWasChanged = Rwiki.NodeManager.getInstance().isParent(oldPath, currentPagePath);
52
-
53
- if (currentPageWasChanged) {
54
- this.editor.setPagePath(data.path);
55
- } else if (parentPathWasChanged) {
56
- var newPath = currentPagePath.replace(oldPath, data.path);
57
- this.editor.setPagePath(newPath);
58
- }
59
- },
60
-
61
- onNodeDeleted: function(data) {
62
- if (data.path == this.editor.getPagePath()) {
63
- this.editor.clearContent();
64
- }
65
- },
66
-
67
- onLastPageClosed: function() {
68
- this.editor.clearContent();
35
+ getPagePath: function() {
36
+ return this.editor.getPagePath();
69
37
  },
70
38
 
71
- onEditorToggled: function() {
72
- this.toggleCollapse();
39
+ getRawContent: function() {
40
+ return this.editor.getContent();
73
41
  }
74
42
  });
@@ -1,36 +1,10 @@
1
1
  Ext.ns('Rwiki.EditorPanel');
2
2
 
3
3
  Rwiki.EditorPanel.Editor = Ext.extend(Ext.util.Observable, {
4
- constructor: function(container) {
4
+ constructor: function() {
5
5
  Rwiki.EditorPanel.Editor.superclass.constructor.apply(this, arguments);
6
-
7
- this.container = container;
8
- this.enabled = false;
9
-
10
- // hack for FF, clear text area on load
11
- this.container.val('');
12
-
6
+ this.container = $('textarea#editor');
13
7
  this.initMarkItUp();
14
- this.initEvents();
15
- },
16
-
17
- initEvents: function() {
18
- var self = this;
19
-
20
- this.container.bind('keydown', function() {
21
- return self.enabled;
22
- });
23
-
24
- var timeout = null;
25
- this.container.bind('keyup', function() {
26
- if (!self.enabled) return;
27
-
28
- clearTimeout(timeout);
29
- var callback = function() {
30
- self.savePage();
31
- };
32
- timeout = setTimeout(callback, 500);
33
- });
34
8
  },
35
9
 
36
10
  initMarkItUp: function() {
@@ -60,28 +34,18 @@ Rwiki.EditorPanel.Editor = Ext.extend(Ext.util.Observable, {
60
34
  {separator:'---------------' },
61
35
  {name:'Quotes', openWith:'bq(!(([![Class]!]))!). '},
62
36
  {separator:'---------------' },
63
- {name:'Code', openWith:'<code>\n', closeWith:'\n</code>'},
64
- {name:'Ruby Code', openWith:'<code lang="ruby">\n', closeWith:'\n</code>'},
65
- {name:'JavaScript Code', openWith:'<code lang="javascript">\n', closeWith:'\n</code>'},
66
- {name:'HTML Code', openWith:'<code lang="html">\n', closeWith:'\n</code>'},
67
- {name:'Css Code', openWith:'<code lang="css">\n', closeWith:'\n</code>'}
37
+ {name:'Code', openWith:'<code>\n', closeWith:'\n</code>', className: 'insert-code'},
38
+ {name:'Ruby Code', openWith:'<code lang="ruby">\n', closeWith:'\n</code>', className: 'insert-code ruby'},
39
+ {name:'JavaScript Code', openWith:'<code lang="javascript">\n', closeWith:'\n</code>', className: 'insert-code javascript'},
40
+ {name:'HTML Code', openWith:'<code lang="html">\n', closeWith:'\n</code>', className: 'insert-code html'},
41
+ {name:'Css Code', openWith:'<code lang="css">\n', closeWith:'\n</code>', className: 'insert-code css'}
68
42
  ],
69
- resizeHandle: false,
70
- afterInsert: function() {
71
- self.savePage();
72
- }
43
+ resizeHandle: false
73
44
  };
74
45
 
75
46
  this.container.markItUp(textileSettings);
76
47
  },
77
48
 
78
- savePage: function() {
79
- var path = this.getPagePath();
80
- var rawContent = this.getContent();
81
-
82
- Rwiki.NodeManager.getInstance().savePage(path, rawContent);
83
- },
84
-
85
49
  clearContent: function() {
86
50
  this.container.val('');
87
51
  this.disable();
@@ -0,0 +1,66 @@
1
+ Ext.ns('Rwiki');
2
+
3
+ Rwiki.EditorWindow = Ext.extend(Ext.Window, {
4
+ constructor: function(editorPanel) {
5
+ Ext.apply(this, {
6
+ maximizable: true,
7
+ modal: true,
8
+ width: 750,
9
+ height: 500,
10
+ minWidth: 300,
11
+ minHeight: 200,
12
+ layout: 'fit',
13
+ plain: true,
14
+ bodyStyle: 'padding: 5px;',
15
+ buttonAlign: 'center',
16
+ items: editorPanel,
17
+ buttons: [
18
+ {
19
+ text: 'Save',
20
+ scope: this,
21
+ handler: this.onSaveButton
22
+ },
23
+ {
24
+ text: 'Save and continue',
25
+ scope: this,
26
+ handler: this.onSaveAndContinueButton
27
+ },
28
+ {
29
+ text: 'Cancel',
30
+ scope: this,
31
+ handler: this.onCancelButton
32
+ }
33
+ ]
34
+ });
35
+
36
+ Rwiki.EditorWindow.superclass.constructor.apply(this, arguments);
37
+ this.editorPanel = editorPanel;
38
+ },
39
+
40
+ setPagePath: function(path) {
41
+ this.pagePath = path;
42
+ this.setTitle('Editing page ' + path);
43
+ },
44
+
45
+ show: function() {
46
+ Rwiki.NodeManager.getInstance().loadPage(this.pagePath);
47
+ Rwiki.EditorWindow.superclass.show.apply(this, arguments);
48
+ },
49
+
50
+ onSaveButton: function() {
51
+ Rwiki.NodeManager.getInstance().savePage(this.pagePath, this.editorPanel.getRawContent());
52
+ this.hide();
53
+ },
54
+
55
+ onSaveAndContinueButton: function() {
56
+ Rwiki.NodeManager.getInstance().savePage(this.pagePath, this.editorPanel.getRawContent());
57
+ },
58
+
59
+ onCancelButton: function() {
60
+ this.hide();
61
+ },
62
+
63
+ close: function() {
64
+ this.hide();
65
+ }
66
+ });