rwiki 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -16,19 +16,16 @@ Feature: Delete a page
16
16
  Then I should not see the node titled "home"
17
17
 
18
18
  @javascript
19
- Scenario: Delete a page when tab is open
20
- When I click the node with path "./home.txt"
21
- And I double click the node with path "./folder"
22
- And I double click the node with path "./folder/subfolder"
23
- And I click the node with path "./folder/subfolder/ruby.txt"
19
+ Scenario: Delete a page when a tab is open
20
+ When I open the page for the tree node with path "./home.txt"
21
+ And I open the page for the tree node with path "./folder/subfolder/ruby.txt"
24
22
  And I right click the node with path "./home.txt"
25
23
  And I follow "Delete node"
26
24
  Then I should see dialog box titled "Confirm"
27
25
 
28
26
  When I press "Yes" within the dialog box
29
27
  Then I should not see the node titled "home"
30
- And I should have the following open tabs:
31
- | ruby |
28
+ And I should see active tab titled "ruby"
32
29
  And I should see page title "Rwiki ./folder/subfolder/ruby.txt"
33
30
 
34
31
  When I right click the node with path "./folder/subfolder/ruby.txt"
@@ -4,32 +4,30 @@ Feature: Display a page
4
4
  Given I open the application
5
5
 
6
6
  @javascript
7
- Scenario: Display the home.txt page
8
- When I click the node with path "./home.txt"
7
+ Scenario Outline: Display the page
8
+ When I open the page for the tree node with path "<path>"
9
+ Then I should see active tab titled "<title>"
10
+ And I should see generated content for the node with path "<path>"
9
11
 
10
- Then I should have the following open tabs:
11
- | home |
12
- And I should see page title "Rwiki ./home.txt"
13
- And I should see generated content for the node with path "./home.txt"
14
-
15
- @javascript
16
- Scenario: Display the ./folder/test.txt page
17
- When I double click the node with path "./folder"
18
- And I click the node with path "./folder/test.txt"
19
-
20
- Then I should have the following open tabs:
21
- | test |
22
- And I should see page title "Rwiki ./folder/test.txt"
23
- And I should see generated content for the node with path "./folder/test.txt"
12
+ Examples:
13
+ | path | title |
14
+ | ./home.txt | home |
15
+ | ./test.txt | test |
16
+ | ./folder/test.txt | test |
17
+ | ./folder/test 1.txt | test 1 |
18
+ | ./folder/test 2.txt | test 2 |
19
+ | ./folder/subfolder/ruby.txt | ruby |
24
20
 
25
21
  @javascript
26
- Scenario: Display the several page
27
- When I click the node with path "./home.txt"
28
- And I double click the node with path "./folder"
29
- And I click the node with path "./folder/test.txt"
22
+ Scenario: Display the several pages
23
+ When I open the page for the tree node with path "./home.txt"
24
+ And I open the page for the tree node with path "./folder/test.txt"
25
+ And I open the page for the tree node with path "./folder/subfolder/ruby.txt"
30
26
 
31
27
  Then I should have the following open tabs:
32
28
  | home |
33
29
  | test |
34
- And I should see page title "Rwiki ./folder/test.txt"
35
- And I should see generated content for the node with path "./folder/test.txt"
30
+ | ruby |
31
+ Then I should see active tab titled "ruby"
32
+ And I should see page title "Rwiki ./folder/subfolder/ruby.txt"
33
+ And I should see generated content for the node with path "./folder/subfolder/ruby.txt"
@@ -5,6 +5,13 @@ Feature: Tree Panel
5
5
 
6
6
  @javascript
7
7
  Scenario: Find a page
8
+ Given this scenario is pending
9
+
8
10
  When I press "Find page"
9
11
  And I fill in the input with "test" within the dialog box
10
-
12
+ And I select the first search result
13
+
14
+ Then I should have the following open tabs:
15
+ | home |
16
+ And I should see page title "Rwiki ./test.txt"
17
+ And I should see generated content for the node with path "./test.txt"
@@ -14,38 +14,49 @@ Feature: History
14
14
  And I should see generated content for the node with path "./home.txt"
15
15
 
16
16
  @javascript
17
- Scenario: After reload the application last opened page should be loaded
18
- When I double click the node with path "./folder"
19
- And I click the node with path "./folder/test.txt"
17
+ Scenario Outline: After reload the application last opened page should be loaded
18
+ When I open the page for the tree node with path "<path>"
20
19
  And I reload the application
21
20
 
22
- Then I should have the following open tabs:
23
- | test |
24
- And I should see page title "Rwiki ./folder/test.txt"
25
- And I should see generated content for the node with path "./folder/test.txt"
26
- And the node with path "./folder/test.txt" should be selected
21
+ Then I should see active tab titled "<title>"
22
+ And I should see page title "Rwiki <path>"
23
+ And I should see generated content for the node with path "<path>"
24
+ And the node with path "<path>" should be selected
25
+
26
+ Examples:
27
+ | path | title |
28
+ | ./home.txt | home |
29
+ | ./test.txt | test |
30
+ | ./folder/test.txt | test |
31
+ | ./folder/test 1.txt | test 1 |
32
+ | ./folder/test 2.txt | test 2 |
33
+ | ./folder/subfolder/ruby.txt | ruby |
27
34
 
28
35
  @javascript
29
36
  Scenario: Browser history
30
- When I double click the node with path "./folder"
31
- And I click the node with path "./folder/test.txt"
32
- And I click the node with path "./test.txt"
33
- And I click the node with path "./home.txt"
37
+ When I open the page for the tree node with path "./folder/test.txt"
38
+ And I open the page for the tree node with path "./test.txt"
39
+ And I open the page for the tree node with path "./home.txt"
40
+ Then I should see active tab titled "home"
34
41
 
35
- When I press the browser back button
42
+ And I press the browser back button
36
43
  Then the node with path "./test.txt" should be selected
37
44
  And I should see generated content for the node with path "./test.txt"
45
+ And I should see active tab titled "test"
38
46
 
39
47
  When I press the browser back button
40
48
  Then the node with path "./folder/test.txt" should be selected
41
49
  And I should see generated content for the node with path "./folder/test.txt"
50
+ And I should see active tab titled "test"
42
51
 
43
52
  When I press the browser forward button
44
53
  Then the node with path "./test.txt" should be selected
45
54
  And I should see generated content for the node with path "./test.txt"
55
+ And I should see active tab titled "test"
46
56
 
47
57
  When I create a new page title "A new page" for the node with path "./Info"
48
58
  And I press the browser back button
49
59
  And I press the browser forward button
50
60
  Then the node with path "./Info/A new page.txt" should be selected
51
61
  And I should see generated content for the node with path "./Info/A new page.txt"
62
+ And I should see active tab titled "A new page"
@@ -86,5 +86,3 @@ Feature: Rename a node
86
86
  And I double click the node with path "./The new folder name"
87
87
  And I click the node with path "./The new folder name/test.txt"
88
88
  And I should see generated content for the node with path "./The new folder name/test.txt"
89
-
90
-
@@ -3,6 +3,10 @@ Then /^I enter the break point$/ do
3
3
  p 'debugger'
4
4
  end
5
5
 
6
+ Given /^this scenario is pending$/ do
7
+ pending # always
8
+ end
9
+
6
10
  When /^I open the application$/ do
7
11
  When %Q{I go to the home page}
8
12
  end
@@ -1,6 +1,13 @@
1
1
  When /^I fill in the input with "([^"]*)" within the dialog box$/ do |text|
2
- field = find('div.x-window input')
2
+ input_selector = 'div.x-window input'
3
+
4
+ field = find(input_selector)
3
5
  field.set(text)
6
+
7
+ # fire keyup event for trigger the autocomplete
8
+ Capybara.current_session.execute_script <<-JS
9
+ $("#{input_selector}").focus().trigger($.Event('keyup'));
10
+ JS
4
11
  end
5
12
 
6
13
  When /^I press "([^"]*)" within the dialog box$/ do |button|
@@ -0,0 +1,4 @@
1
+ When /^I select the first search result$/ do
2
+ search_result = page.find('div.search-item:first')
3
+ search_result.click
4
+ end
@@ -17,6 +17,10 @@ When /^I click tab for page "([^"]*)"$/ do |path|
17
17
  tab.click
18
18
  end
19
19
 
20
+ Then /^I should see active tab titled "([^"]*)"$/ do |title|
21
+ page.find('li.x-tab-strip-active').text.should == title
22
+ end
23
+
20
24
  Then /^I should have the following open tabs:$/ do |table|
21
25
  actual_table = table(tableish("div.x-tab-panel ul li[@class!='x-tab-edge']", "a.x-tab-right"))
22
26
  table.diff!(actual_table)
@@ -1,3 +1,26 @@
1
+ When /^I expand the parent for the node with path "([^"]*)"$/ do |path|
2
+ parts = path.split('/')[0..-2]
3
+ parts.each_index do |i|
4
+ partial_path = parts[0..i].join('/')
5
+
6
+ # check if node is expanded
7
+ is_expanded = Capybara.current_session.evaluate_script <<-JS
8
+ node = Rwiki.treePanel.findNodeByPath('#{partial_path}').isExpanded();
9
+ JS
10
+
11
+ unless is_expanded
12
+ Then %{I double click the node with path "#{partial_path}"}
13
+ end
14
+ end
15
+ end
16
+
17
+ When /^I open the page for the tree node with path "([^"]*)"$/ do |path|
18
+ When %{I expand the parent for the node with path "#{path}"}
19
+ And %{I click the node with path "#{path}"}
20
+ And %{I should see page title "Rwiki #{path}"}
21
+ And %{I should see generated content for the node with path "#{path}"}
22
+ end
23
+
1
24
  Then /^I should see the node titled "([^"]*)"$/ do |title|
2
25
  Then %{I should see "#{title}" within "div#tree"}
3
26
  end
@@ -11,7 +11,7 @@ Given /^I wait for load the tree$/ do
11
11
  end
12
12
  end
13
13
 
14
- Given /^I wait for load an ajax call complete$/ do
14
+ Given /^I wait for an ajax call complete$/ do
15
15
  timeout = 10
16
16
  wait_until(timeout) do
17
17
  Capybara.current_session.evaluate_script <<-JS
@@ -9,12 +9,11 @@ require File.expand_path(File.join(File.dirname(__FILE__), '../../test/tmpdir_he
9
9
  Rwiki::App.set(:environment, :test)
10
10
 
11
11
  Capybara.default_selector = :css
12
+
13
+ require 'selenium/webdriver'
12
14
  Capybara.register_driver :selenium do |app|
13
- Capybara::Driver::Selenium
14
15
  profile = Selenium::WebDriver::Firefox::Profile.new
15
- # profile.add_extension(File.expand_path("features/support/firebug-1.6.1-fx.xpi"))
16
-
17
- Capybara::Driver::Selenium.new(app, { :browser => :firefox, :profile => profile })
16
+ Capybara::Driver::Selenium.new(app, :profile => profile)
18
17
  end
19
18
 
20
19
  World do
@@ -27,7 +26,7 @@ World do
27
26
 
28
27
  AfterStep do
29
28
  Given %Q{I wait for load the tree}
30
- And %Q{I wait for load an ajax call complete}
29
+ And %Q{I wait for an ajax call complete}
31
30
  end
32
31
 
33
32
  Before do
@@ -5,8 +5,8 @@ Feature: Tab Panel
5
5
 
6
6
  @javascript
7
7
  Scenario: Close a tab
8
- When I click the node with path "./home.txt"
9
- And I click the node with path "./test.txt"
8
+ When I open the page for the tree node with path "./home.txt"
9
+ And I open the page for the tree node with path "./test.txt"
10
10
 
11
11
  Then I should have the following open tabs:
12
12
  | home |
@@ -22,9 +22,9 @@ Feature: Tab Panel
22
22
  Then I should have no open tabs
23
23
 
24
24
  @javascript
25
- Scenario: Switching a tabs
26
- When I click the node with path "./home.txt"
27
- And I click the node with path "./test.txt"
25
+ Scenario: Switching the tabs
26
+ When I open the page for the tree node with path "./home.txt"
27
+ And I open the page for the tree node with path "./test.txt"
28
28
  Then I should see "This is a test"
29
29
 
30
30
  When I click tab for page "./home.txt"
@@ -17,8 +17,10 @@ module Rwiki::Models
17
17
  end
18
18
 
19
19
  def fuzzy_finder(query)
20
- finder = FuzzyFileFinder.new(full_path_for('.'))
21
- matches = finder.find(query).sort_by { |m| [-m[:score], m[:path]] }
20
+ @finder ||= FuzzyFileFinder.new(full_path_for('.'))
21
+ @finder.rescan!
22
+
23
+ matches = @finder.find(query).sort_by { |m| [-m[:score], m[:path]] }
22
24
  matches.each do |m|
23
25
  m[:path] = '.' + m[:path].gsub(full_path_for('.'), '')
24
26
  end
@@ -23,46 +23,41 @@ Rwiki.init = function() {
23
23
  Rwiki.ajaxCallCompleted = true;
24
24
  Rwiki.treeLoaded = false;
25
25
 
26
- var treePanel = new Rwiki.TreePanel();
27
- Rwiki.treePanel = treePanel;
26
+ Rwiki.treePanel = new Rwiki.TreePanel();
28
27
  var nodeManager = Rwiki.NodeManager.getInstance();
29
28
 
30
29
  nodeManager.on('rwiki:beforePageLoad', function() {
31
30
  Rwiki.ajaxCallCompleted = false;
31
+ Rwiki.statusBar.showBusy();
32
32
  });
33
33
 
34
34
  nodeManager.on('rwiki:pageLoaded', function() {
35
35
  Rwiki.ajaxCallCompleted = true;
36
+ Rwiki.statusBar.clearStatus({useDefaults: true});
36
37
  });
37
38
 
38
- treePanel.getLoader().on('load', function() {
39
+ Rwiki.statusBar = new Ext.ux.StatusBar({
40
+ statusAlign: 'right',
41
+ defaultText: 'Ready',
42
+ iconCls: 'x-status-valid'
43
+ });
44
+
45
+ Rwiki.treePanel.getLoader().on('load', function() {
39
46
  Rwiki.treeLoaded = true;
40
47
  Rwiki.treePanel.openNodeFromLocationHash();
41
48
  });
42
49
 
43
- treePanel.relayEvents(nodeManager,
44
- ['rwiki:pageLoaded', 'rwiki:folderCreated', 'rwiki:pageCreated', 'rwiki:nodeRenamed', 'rwiki:nodeDeleted']);
45
-
46
- var tabPanel = new Rwiki.TabPanel();
47
- Rwiki.tabPanel = tabPanel;
48
- tabPanel.relayEvents(nodeManager,
49
- ['rwiki:pageLoaded', 'rwiki:folderCreated', 'rwiki:pageCreated', 'rwiki:pageSaved', 'rwiki:nodeRenamed', 'rwiki:nodeDeleted']);
50
- tabPanel.relayEvents(treePanel, ['pageSelected']);
51
-
52
- var editorPanel = new Rwiki.EditorPanel();
53
- editorPanel.relayEvents(Rwiki.NodeManager.getInstance(), ['rwiki:pageLoaded']);
54
-
55
- var window = new Rwiki.EditorWindow(editorPanel);
50
+ Rwiki.tabPanel = new Rwiki.TabPanel({
51
+ bbar: Rwiki.statusBar
52
+ });
53
+ Rwiki.tabPanel.relayEvents(Rwiki.treePanel, ['rwiki:pageSelected']);
56
54
 
57
- function showEditor(path) {
58
- if (!window.isVisible()) {
59
- window.setPagePath(path);
60
- window.show();
55
+ var editorWindow = new Rwiki.EditorWindow();
56
+ Rwiki.tabPanel.on('rwiki:editPage', function(path) {
57
+ if (!editorWindow.isVisible()) {
58
+ editorWindow.setPagePath(path);
59
+ editorWindow.show();
61
60
  }
62
- }
63
-
64
- tabPanel.on('rwiki:editPage', function(path) {
65
- showEditor(path);
66
61
  });
67
62
 
68
63
  // Handle this change event in order to restore the UI to the appropriate history state
@@ -73,14 +68,14 @@ Rwiki.init = function() {
73
68
  // Create layout
74
69
 
75
70
  var navigationPanel = new Rwiki.NavigationPanel({
76
- items: [treePanel]
71
+ items: [Rwiki.treePanel]
77
72
  });
78
73
 
79
74
  var app = new Ext.Viewport({
80
75
  layout: 'border',
81
76
  plain: true,
82
77
  renderTo: Ext.getBody(),
83
- items: [navigationPanel, tabPanel]
78
+ items: [navigationPanel, Rwiki.tabPanel]
84
79
  });
85
80
 
86
81
  app.show();
@@ -91,22 +86,22 @@ Rwiki.init = function() {
91
86
  alt: true,
92
87
  stopEvent: true,
93
88
  fn: function() {
94
- tabPanel.onEditPage();
89
+ Rwiki.tabPanel.onEditPage();
95
90
  }
96
91
  }, {
97
92
  key: "t",
98
93
  ctrl: true,
99
94
  stopEvent: true,
100
95
  fn: function() {
101
- tabPanel.onFuzzyFinder();
96
+ Rwiki.tabPanel.onFuzzyFinder();
102
97
  }
103
98
  }, {
104
99
  key: "w",
105
100
  ctrl: true,
106
101
  stopEvent: true,
107
102
  fn: function() {
108
- var tab = tabPanel.getActiveTab();
109
- tabPanel.remove(tab);
103
+ var tab = Rwiki.tabPanel.getActiveTab();
104
+ Rwiki.tabPanel.remove(tab);
110
105
  }
111
106
  }]);
112
107
 
@@ -24,12 +24,15 @@ Rwiki.EditorPanel = Ext.extend(Ext.Panel, {
24
24
  initEvents: function() {
25
25
  Rwiki.EditorPanel.superclass.initEvents.apply(this, arguments);
26
26
 
27
+ this.relayEvents(Rwiki.NodeManager.getInstance(), ['rwiki:pageLoaded']);
27
28
  this.on('rwiki:pageLoaded', this.onPageLoaded);
28
29
  },
29
30
 
30
- onPageLoaded: function(data) {
31
- this.editor.setPagePath(data.path);
32
- this.editor.setContent(data.rawContent);
31
+ onPageLoaded: function(page) {
32
+ this.editor.setPagePath(page.getPath());
33
+ this.editor.setContent(page.getRawContent());
34
+
35
+ Ext.get('editor-container').unmask();
33
36
  },
34
37
 
35
38
  getPagePath: function() {
@@ -1,7 +1,9 @@
1
1
  Ext.ns('Rwiki');
2
2
 
3
3
  Rwiki.EditorWindow = Ext.extend(Ext.Window, {
4
- constructor: function(editorPanel) {
4
+ constructor: function() {
5
+ this.editorPanel = new Rwiki.EditorPanel();
6
+
5
7
  Ext.apply(this, {
6
8
  maximizable: true,
7
9
  modal: true,
@@ -13,7 +15,7 @@ Rwiki.EditorWindow = Ext.extend(Ext.Window, {
13
15
  plain: true,
14
16
  bodyStyle: 'padding: 5px;',
15
17
  buttonAlign: 'center',
16
- items: editorPanel,
18
+ items: this.editorPanel,
17
19
  buttons: [
18
20
  {
19
21
  text: 'Save',
@@ -37,7 +39,6 @@ Rwiki.EditorWindow = Ext.extend(Ext.Window, {
37
39
  });
38
40
 
39
41
  Rwiki.EditorWindow.superclass.constructor.apply(this, arguments);
40
- this.editorPanel = editorPanel;
41
42
  },
42
43
 
43
44
  setPagePath: function(path) {
@@ -48,15 +49,21 @@ Rwiki.EditorWindow = Ext.extend(Ext.Window, {
48
49
  show: function() {
49
50
  Rwiki.NodeManager.getInstance().loadPage(this.pagePath);
50
51
  Rwiki.EditorWindow.superclass.show.apply(this, arguments);
52
+
53
+ Ext.get('editor-container').mask('Loading the page...');
51
54
  },
52
55
 
53
- onSaveButton: function() {
56
+ savePage: function() {
54
57
  Rwiki.NodeManager.getInstance().savePage(this.pagePath, this.editorPanel.getRawContent());
58
+ },
59
+
60
+ onSaveButton: function() {
61
+ this.savePage();
55
62
  this.hide();
56
63
  },
57
64
 
58
65
  onSaveAndContinueButton: function() {
59
- Rwiki.NodeManager.getInstance().savePage(this.pagePath, this.editorPanel.getRawContent());
66
+ this.savePage();
60
67
  },
61
68
 
62
69
  onCancelButton: function() {
@@ -0,0 +1,37 @@
1
+ Ext.ns('Rwiki');
2
+
3
+ Rwiki.Node = function(data) {
4
+ this._data = data;
5
+ };
6
+
7
+ Rwiki.Node.prototype = {
8
+
9
+ getData: function() {
10
+ return this._data;
11
+ },
12
+
13
+ getHtmlContent: function() {
14
+ return this._data.htmlContent;
15
+ },
16
+
17
+ getRawContent: function() {
18
+ return this._data.rawContent;
19
+ },
20
+
21
+ getPath: function() {
22
+ return this._data.path;
23
+ },
24
+
25
+ getParentPath: function() {
26
+ return this._data.parentPath;
27
+ },
28
+
29
+ getBaseName: function() {
30
+ return this.getPath().split('/').pop();
31
+ },
32
+
33
+ getTitle: function() {
34
+ return this.getBaseName().replace(new RegExp('\.txt$'), '');
35
+ }
36
+
37
+ };
@@ -22,10 +22,12 @@ Rwiki.NodeManager = Ext.extend(Ext.util.Observable, {
22
22
  );
23
23
  },
24
24
 
25
- loadPage: function(path) {
25
+ loadPage: function(path) {
26
26
  var self = this;
27
- self.fireEvent('rwiki:beforePageLoad', path);
28
-
27
+
28
+ var page = new Rwiki.Node({ path: path });
29
+ self.fireEvent('rwiki:beforePageLoad', page);
30
+
29
31
  $.ajax({
30
32
  type: 'GET',
31
33
  url: '/node',
@@ -34,7 +36,8 @@ Rwiki.NodeManager = Ext.extend(Ext.util.Observable, {
34
36
  path: path
35
37
  },
36
38
  success: function(data) {
37
- self.fireEvent('rwiki:pageLoaded', data);
39
+ page = new Rwiki.Node(data);
40
+ self.fireEvent('rwiki:pageLoaded', page);
38
41
  }
39
42
  });
40
43
  },
@@ -70,7 +73,8 @@ Rwiki.NodeManager = Ext.extend(Ext.util.Observable, {
70
73
  isFolder: false
71
74
  },
72
75
  success: function(data) {
73
- self.fireEvent('rwiki:pageCreated', data);
76
+ var page = new Rwiki.Node(data);
77
+ self.fireEvent('rwiki:pageCreated', page);
74
78
  }
75
79
  });
76
80
  },
@@ -87,7 +91,8 @@ Rwiki.NodeManager = Ext.extend(Ext.util.Observable, {
87
91
  rawContent: rawContent
88
92
  },
89
93
  success: function(data) {
90
- self.fireEvent('rwiki:pageSaved', data);
94
+ var page = new Rwiki.Node(data);
95
+ self.fireEvent('rwiki:pageSaved', page);
91
96
  }
92
97
  });
93
98
  },
@@ -104,7 +109,8 @@ Rwiki.NodeManager = Ext.extend(Ext.util.Observable, {
104
109
  newName: newName
105
110
  },
106
111
  success: function(data) {
107
- self.fireEvent('rwiki:nodeRenamed', data);
112
+ var page = new Rwiki.Node(data);
113
+ self.fireEvent('rwiki:nodeRenamed', page);
108
114
  }
109
115
  });
110
116
  },
@@ -135,7 +141,8 @@ Rwiki.NodeManager = Ext.extend(Ext.util.Observable, {
135
141
  newParentPath: newParentPath
136
142
  },
137
143
  success: function(data) {
138
- self.fireEvent('rwiki:nodeRenamed', data);
144
+ var page = new Rwiki.Node(data);
145
+ self.fireEvent('rwiki:nodeRenamed', page);
139
146
  }
140
147
  });
141
148
 
@@ -37,32 +37,40 @@ Rwiki.TabPanel = Ext.extend(Ext.TabPanel, {
37
37
 
38
38
  this.addEvents('rwiki:editPage');
39
39
 
40
- this.on('pageSelected', this.onPageSelected),
40
+ this.on('rwiki:pageSelected', this.onPageSelected),
41
41
  this.on('tabchange', this.onTabChange);
42
42
 
43
43
  this.on('rwiki:pageCreated', this.onPageCreated);
44
44
  this.on('rwiki:pageLoaded', this.onPageLoaded);
45
45
  this.on('rwiki:pageSaved', this.onPageSaved);
46
- this.on('rwiki:nodeRenamed', this.onNodeRanamed);
46
+ this.on('rwiki:nodeRenamed', this.onNodeRenamed);
47
47
  this.on('rwiki:nodeDeleted', this.onNodeDeleted);
48
+
49
+ this.relayEvents(Rwiki.NodeManager.getInstance(), [
50
+ 'rwiki:pageLoaded',
51
+ 'rwiki:folderCreated',
52
+ 'rwiki:pageCreated',
53
+ 'rwiki:pageSaved',
54
+ 'rwiki:nodeRenamed',
55
+ 'rwiki:nodeDeleted']);
48
56
  },
49
57
 
50
- findOrCreatePageTab: function(path) {
51
- var tab = this.findTabByPagePath(path);
58
+ findOrCreatePageTab: function(page) {
59
+ var tab = this.findTabByPagePath(page.getPath());
52
60
 
53
61
  if (!tab) {
54
- tab = this.createPageTab(path);
62
+ tab = this.createPageTab(page);
55
63
  }
56
64
 
57
65
  return tab;
58
66
  },
59
67
 
60
- createPageTab: function(path, title) {
68
+ createPageTab: function(page) {
61
69
  var tab = new Rwiki.TabPanel.PageTab({
62
- title: title
70
+ title: page.getTitle()
63
71
  });
64
72
 
65
- tab.setPagePath(path);
73
+ tab.setPagePath(page.getPath());
66
74
  this.add(tab);
67
75
 
68
76
  return tab;
@@ -81,47 +89,51 @@ Rwiki.TabPanel = Ext.extend(Ext.TabPanel, {
81
89
  });
82
90
  },
83
91
 
84
- onPageSelected: function(path) {
85
- var tab = this.findOrCreatePageTab(path);
92
+ onPageSelected: function(page) {
93
+ var tab = this.findOrCreatePageTab(page);
86
94
  tab.show();
87
95
  },
88
96
 
89
97
  onTabChange: function(panel, tab) {
90
98
  if (tab) {
99
+ if (tab.isLoading()) {
100
+ return;
101
+ }
102
+
91
103
  Ext.History.add(tab.getPagePath());
92
104
  document.title = 'Rwiki ' + tab.getPagePath();
93
105
  Rwiki.NodeManager.getInstance().loadPage(tab.getPagePath());
106
+ tab.setIsLoading(true);
94
107
  } else {
95
108
  document.title = 'Rwiki';
96
109
  Rwiki.NodeManager.getInstance().fireEvent('rwiki:lastPageClosed');
97
110
  }
98
111
  },
99
112
 
100
- onPageCreated: function(data) {
101
- var tab = this.createPageTab(data.path, data.text);
113
+ onPageCreated: function(page) {
114
+ var tab = this.createPageTab(page);
102
115
  tab.show();
103
116
  },
104
117
 
105
- onPageLoaded: function(data) {
106
- var tab = this.findOrCreatePageTab(data.path);
107
- var title = data.baseName.replace(new RegExp('\.txt$'), '');
108
-
109
- tab.setTitle(title);
110
- tab.setContent(data.htmlContent);
118
+ onPageLoaded: function(page) {
119
+ var tab = this.findOrCreatePageTab(page);
120
+
121
+ tab.setTitle(page.getTitle());
122
+ tab.setContent(page.getHtmlContent());
111
123
  tab.show();
124
+
125
+ tab.setIsLoading(false);
112
126
  },
113
127
 
114
- onPageSaved: function(data) {
115
- var tab = this.findTabByPagePath(data.path);
128
+ onPageSaved: function(page) {
129
+ var tab = this.findTabByPagePath(page.getPath());
116
130
  if (tab == null) return;
117
131
 
118
- tab.setContent(data.htmlContent);
132
+ tab.setContent(page.getHtmlContent());
119
133
  },
120
134
 
121
- onNodeRanamed: function(data) {
122
- var oldPath = data.oldPath;
123
- var path = data.path;
124
-
135
+ onNodeRenamed: function(page) {
136
+ var oldPath = page.getData().oldPath;
125
137
  var currentTab = this.getActiveTab();
126
138
 
127
139
  var tab = null;
@@ -130,18 +142,17 @@ Rwiki.TabPanel = Ext.extend(Ext.TabPanel, {
130
142
  tab = this.findTabByPagePath(oldPath);
131
143
  if (tab == null) return;
132
144
 
133
- tab.setPagePath(path);
134
- var title = data.baseName.replace(new RegExp('\.txt$'), '');
135
- tab.setTitle(title);
145
+ tab.setPagePath(page.getPath());
146
+ tab.setTitle(page.getTitle());
136
147
 
137
148
  if (tab == currentTab) {
138
- document.title = 'Rwiki ' + path;
149
+ document.title = 'Rwiki ' + page.getPath();
139
150
  }
140
151
  } else {
141
152
  var tabs = this.findTabsByParentPath(oldPath);
142
153
  for (var i = 0; i < tabs.length; i++) {
143
154
  tab = tabs[i];
144
- var newPath = tab.getPagePath().replace(oldPath, path);
155
+ var newPath = tab.getPagePath().replace(oldPath, page.getPath());
145
156
  tab.setPagePath(newPath);
146
157
 
147
158
  if (tab == currentTab) {
@@ -175,7 +186,7 @@ Rwiki.TabPanel = Ext.extend(Ext.TabPanel, {
175
186
  var currentTab = this.getActiveTab();
176
187
  if (currentTab) {
177
188
  var path = currentTab.getPagePath();
178
- window.open('/node/print?path=' + path, 'mywindow', 'width=800,height=600')
189
+ window.open('/node/print?path=' + path, 'Rwiki ' + path, 'width=800,height=600,scrollbars=yes')
179
190
  }
180
191
  }
181
192
  });
@@ -11,6 +11,21 @@ Rwiki.TabPanel.PageTab = Ext.extend(Ext.Container, {
11
11
  Rwiki.TabPanel.PageTab.superclass.constructor.apply(this, arguments);
12
12
  },
13
13
 
14
+ isLoading: function() {
15
+ return this._isLoading;
16
+ },
17
+
18
+ setIsLoading: function(isLoading) {
19
+ this._isLoading = isLoading;
20
+
21
+ if (isLoading) {
22
+ this.mask = new Ext.LoadMask(Ext.get(this.id), {msg: 'Loading the Page...'});
23
+ this.mask.show();
24
+ } else if (this.mask) {
25
+ this.mask.hide();
26
+ }
27
+ },
28
+
14
29
  getPagePath: function() {
15
30
  return this.path;
16
31
  },
@@ -19,11 +34,8 @@ Rwiki.TabPanel.PageTab = Ext.extend(Ext.Container, {
19
34
  this.path = path;
20
35
  },
21
36
 
22
- /**
23
- * Update the page content.
24
- */
25
37
  setContent: function(htmlContent) {
26
- pageContainer = this.getPageContainer();
38
+ var pageContainer = this.getPageContainer();
27
39
  pageContainer.html(htmlContent);
28
40
  },
29
41
 
@@ -38,7 +38,7 @@ Rwiki.TreePanel = Ext.extend(Ext.tree.TreePanel, {
38
38
  this.root.expand();
39
39
 
40
40
  new Ext.tree.TreeSorter(this, {
41
- folderSort: false
41
+ folderSort: true
42
42
  });
43
43
 
44
44
  var self = this;
@@ -55,7 +55,7 @@ Rwiki.TreePanel = Ext.extend(Ext.tree.TreePanel, {
55
55
  self.filter.filterTree(text);
56
56
  });
57
57
 
58
- this.addEvents('pageSelected');
58
+ this.addEvents('rwiki:pageSelected');
59
59
  },
60
60
 
61
61
  initEvents: function() {
@@ -69,6 +69,13 @@ Rwiki.TreePanel = Ext.extend(Ext.tree.TreePanel, {
69
69
  this.on('rwiki:nodeRenamed', this.onNodeRenamed);
70
70
  this.on('rwiki:nodeDeleted', this.onNodeDeleted);
71
71
  this.on('beforemovenode', this.onBeforeMoveNode);
72
+
73
+ this.relayEvents(Rwiki.NodeManager.getInstance(), [
74
+ 'rwiki:pageLoaded',
75
+ 'rwiki:folderCreated',
76
+ 'rwiki:pageCreated',
77
+ 'rwiki:nodeRenamed',
78
+ 'rwiki:nodeDeleted']);
72
79
  },
73
80
 
74
81
  onContextMenu: function(node, e) {
@@ -83,13 +90,12 @@ Rwiki.TreePanel = Ext.extend(Ext.tree.TreePanel, {
83
90
 
84
91
  onClick: function(node) {
85
92
  if (!node.isLeaf()) return;
86
-
87
- var path = node.getPath();
88
- this.fireEvent('pageSelected', path);
93
+ var page = new Rwiki.Node({ path: node.getPath() });
94
+ this.fireEvent('rwiki:pageSelected', page);
89
95
  },
90
96
 
91
- onPageLoaded: function(data) {
92
- var node = this.findNodeByPath(data.path);
97
+ onPageLoaded: function(page) {
98
+ var node = this.findNodeByPath(page.getPath());
93
99
  if (node) {
94
100
  node.select();
95
101
  }
@@ -109,27 +115,25 @@ Rwiki.TreePanel = Ext.extend(Ext.tree.TreePanel, {
109
115
  parentNode.appendChild(node);
110
116
  },
111
117
 
112
- onPageCreated: function(data) {
113
- var node = new Rwiki.TreePanel.Node({
114
- baseName: data.baseName,
115
- text: data.baseName.replace(new RegExp('\.txt$'), ''),
118
+ onPageCreated: function(page) {
119
+ var treeNode = new Rwiki.TreePanel.Node({
120
+ baseName: page.getBaseName(),
121
+ text: page.getTitle(),
116
122
  cls: 'page',
117
123
  expandable: false,
118
124
  leaf: true
119
125
  });
120
126
 
121
- var parentNode = this.findNodeByPath(data.parentPath);
127
+ var parentNode = this.findNodeByPath(page.getParentPath());
122
128
  parentNode.expand();
123
- parentNode.appendChild(node);
124
- node.select();
129
+ parentNode.appendChild(treeNode);
130
+ treeNode.select();
125
131
  },
126
132
 
127
- onNodeRenamed: function(data) {
128
- var node = this.findNodeByPath(data.oldPath);
129
- node.setBaseName(data.baseName);
130
-
131
- var title = data.baseName.replace(new RegExp('\.txt$'), '');
132
- node.setText(title);
133
+ onNodeRenamed: function(page) {
134
+ var treeNode = this.findNodeByPath(page.getData().oldPath);
135
+ treeNode.setBaseName(page.getBaseName());
136
+ treeNode.setText(page.getTitle());
133
137
  },
134
138
 
135
139
  onNodeDeleted: function(data) {
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rwiki}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Łukasz Bandzarewicz"]
12
- s.date = %q{2011-01-24}
12
+ s.date = %q{2011-01-31}
13
13
  s.default_executable = %q{rwiki}
14
14
  s.description = %q{Personal wiki based on ExtJS}
15
15
  s.email = %q{lucassus@gmail.com}
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
40
40
  "features/step_definitions/common_steps.rb",
41
41
  "features/step_definitions/common_transforms.rb",
42
42
  "features/step_definitions/dialog_box_steps.rb",
43
+ "features/step_definitions/fuzzy_finder_steps.rb",
43
44
  "features/step_definitions/history_steps.rb",
44
45
  "features/step_definitions/tab_panel_steps.rb",
45
46
  "features/step_definitions/tree_panel_steps.rb",
@@ -1086,6 +1087,7 @@ Gem::Specification.new do |s|
1086
1087
  "public/javascripts/Rwiki/EditorWindow.js",
1087
1088
  "public/javascripts/Rwiki/FuzzyFinderDialog.js",
1088
1089
  "public/javascripts/Rwiki/NavigationPanel.js",
1090
+ "public/javascripts/Rwiki/Node.js",
1089
1091
  "public/javascripts/Rwiki/NodeManager.js",
1090
1092
  "public/javascripts/Rwiki/TabPanel.js",
1091
1093
  "public/javascripts/Rwiki/TabPanel/PageTab.js",
@@ -32,6 +32,7 @@
32
32
  <script type="text/javascript" src="/javascripts/Rwiki/EditorPanel/Editor.js"></script>
33
33
  <script type="text/javascript" src="/javascripts/Rwiki/FuzzyFinderDialog.js"></script>
34
34
  <script type="text/javascript" src="/javascripts/Rwiki/NodeManager.js"></script>
35
+ <script type="text/javascript" src="/javascripts/Rwiki/Node.js"></script>
35
36
  <script type="text/javascript" src="/javascripts/Rwiki/TabPanel.js"></script>
36
37
  <script type="text/javascript" src="/javascripts/Rwiki/TabPanel/PageTab.js"></script>
37
38
  <script type="text/javascript" src="/javascripts/Rwiki/TreePanel.js"></script>
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3
9
- version: 0.2.3
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - "\xC5\x81ukasz Bandzarewicz"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-24 00:00:00 +01:00
17
+ date: 2011-01-31 00:00:00 +01:00
18
18
  default_executable: rwiki
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -282,6 +282,7 @@ files:
282
282
  - features/step_definitions/common_steps.rb
283
283
  - features/step_definitions/common_transforms.rb
284
284
  - features/step_definitions/dialog_box_steps.rb
285
+ - features/step_definitions/fuzzy_finder_steps.rb
285
286
  - features/step_definitions/history_steps.rb
286
287
  - features/step_definitions/tab_panel_steps.rb
287
288
  - features/step_definitions/tree_panel_steps.rb
@@ -1328,6 +1329,7 @@ files:
1328
1329
  - public/javascripts/Rwiki/EditorWindow.js
1329
1330
  - public/javascripts/Rwiki/FuzzyFinderDialog.js
1330
1331
  - public/javascripts/Rwiki/NavigationPanel.js
1332
+ - public/javascripts/Rwiki/Node.js
1331
1333
  - public/javascripts/Rwiki/NodeManager.js
1332
1334
  - public/javascripts/Rwiki/TabPanel.js
1333
1335
  - public/javascripts/Rwiki/TabPanel/PageTab.js
@@ -2349,7 +2351,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
2349
2351
  requirements:
2350
2352
  - - ">="
2351
2353
  - !ruby/object:Gem::Version
2352
- hash: 1194724360297676042
2354
+ hash: -2476446300087577750
2353
2355
  segments:
2354
2356
  - 0
2355
2357
  version: "0"