read-only-gollum 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/Gemfile +4 -0
  2. data/HISTORY.md +102 -0
  3. data/Home.md +3 -0
  4. data/LICENSE +21 -0
  5. data/README.md +477 -0
  6. data/Rakefile +142 -0
  7. data/bin/read-only-gollum +126 -0
  8. data/docs/sanitization.md +32 -0
  9. data/lib/gollum.rb +41 -0
  10. data/lib/gollum/blob_entry.rb +78 -0
  11. data/lib/gollum/committer.rb +218 -0
  12. data/lib/gollum/file.rb +64 -0
  13. data/lib/gollum/frontend/app.rb +225 -0
  14. data/lib/gollum/frontend/public/css/dialog.css +141 -0
  15. data/lib/gollum/frontend/public/css/editor.css +537 -0
  16. data/lib/gollum/frontend/public/css/gollum.css +660 -0
  17. data/lib/gollum/frontend/public/css/ie7.css +69 -0
  18. data/lib/gollum/frontend/public/css/template.css +381 -0
  19. data/lib/gollum/frontend/public/images/icon-sprite.png +0 -0
  20. data/lib/gollum/frontend/public/javascript/editor/gollum.editor.js +1096 -0
  21. data/lib/gollum/frontend/public/javascript/editor/langs/asciidoc.js +167 -0
  22. data/lib/gollum/frontend/public/javascript/editor/langs/creole.js +104 -0
  23. data/lib/gollum/frontend/public/javascript/editor/langs/markdown.js +211 -0
  24. data/lib/gollum/frontend/public/javascript/editor/langs/org.js +173 -0
  25. data/lib/gollum/frontend/public/javascript/editor/langs/pod.js +111 -0
  26. data/lib/gollum/frontend/public/javascript/editor/langs/rdoc.js +74 -0
  27. data/lib/gollum/frontend/public/javascript/editor/langs/textile.js +175 -0
  28. data/lib/gollum/frontend/public/javascript/gollum.dialog.js +263 -0
  29. data/lib/gollum/frontend/public/javascript/gollum.js +161 -0
  30. data/lib/gollum/frontend/public/javascript/gollum.placeholder.js +54 -0
  31. data/lib/gollum/frontend/public/javascript/jquery.color.js +123 -0
  32. data/lib/gollum/frontend/public/javascript/jquery.js +7179 -0
  33. data/lib/gollum/frontend/templates/compare.mustache +38 -0
  34. data/lib/gollum/frontend/templates/create.mustache +17 -0
  35. data/lib/gollum/frontend/templates/edit.mustache +17 -0
  36. data/lib/gollum/frontend/templates/editor.mustache +116 -0
  37. data/lib/gollum/frontend/templates/error.mustache +8 -0
  38. data/lib/gollum/frontend/templates/history.mustache +58 -0
  39. data/lib/gollum/frontend/templates/layout.mustache +28 -0
  40. data/lib/gollum/frontend/templates/page.mustache +37 -0
  41. data/lib/gollum/frontend/templates/pages.mustache +35 -0
  42. data/lib/gollum/frontend/templates/search.mustache +36 -0
  43. data/lib/gollum/frontend/templates/searchbar.mustache +10 -0
  44. data/lib/gollum/frontend/views/compare.rb +94 -0
  45. data/lib/gollum/frontend/views/create.rb +48 -0
  46. data/lib/gollum/frontend/views/edit.rb +52 -0
  47. data/lib/gollum/frontend/views/editable.rb +13 -0
  48. data/lib/gollum/frontend/views/error.rb +7 -0
  49. data/lib/gollum/frontend/views/history.rb +44 -0
  50. data/lib/gollum/frontend/views/layout.rb +20 -0
  51. data/lib/gollum/frontend/views/page.rb +57 -0
  52. data/lib/gollum/frontend/views/pages.rb +19 -0
  53. data/lib/gollum/frontend/views/search.rb +20 -0
  54. data/lib/gollum/git_access.rb +248 -0
  55. data/lib/gollum/markup.rb +489 -0
  56. data/lib/gollum/page.rb +430 -0
  57. data/lib/gollum/pagination.rb +61 -0
  58. data/lib/gollum/sanitization.rb +174 -0
  59. data/lib/gollum/tex.rb +89 -0
  60. data/lib/gollum/web_sequence_diagram.rb +43 -0
  61. data/lib/gollum/wiki.rb +636 -0
  62. data/read-only-gollum.gemspec +224 -0
  63. data/templates/formatting.html +92 -0
  64. data/test/examples/empty.git/HEAD +1 -0
  65. data/test/examples/empty.git/config +5 -0
  66. data/test/examples/empty.git/description +1 -0
  67. data/test/examples/empty.git/hooks/applypatch-msg.sample +15 -0
  68. data/test/examples/empty.git/hooks/commit-msg.sample +24 -0
  69. data/test/examples/empty.git/hooks/post-commit.sample +8 -0
  70. data/test/examples/empty.git/hooks/post-receive.sample +15 -0
  71. data/test/examples/empty.git/hooks/post-update.sample +8 -0
  72. data/test/examples/empty.git/hooks/pre-applypatch.sample +14 -0
  73. data/test/examples/empty.git/hooks/pre-commit.sample +46 -0
  74. data/test/examples/empty.git/hooks/pre-rebase.sample +169 -0
  75. data/test/examples/empty.git/hooks/prepare-commit-msg.sample +36 -0
  76. data/test/examples/empty.git/hooks/update.sample +128 -0
  77. data/test/examples/empty.git/info/exclude +6 -0
  78. data/test/examples/empty.git/objects/info/.gitkeep +0 -0
  79. data/test/examples/empty.git/objects/pack/.gitkeep +0 -0
  80. data/test/examples/empty.git/refs/heads/.gitkeep +0 -0
  81. data/test/examples/lotr.git/COMMIT_EDITMSG +1 -0
  82. data/test/examples/lotr.git/HEAD +1 -0
  83. data/test/examples/lotr.git/ORIG_HEAD +1 -0
  84. data/test/examples/lotr.git/config +12 -0
  85. data/test/examples/lotr.git/description +1 -0
  86. data/test/examples/lotr.git/index +0 -0
  87. data/test/examples/lotr.git/info/exclude +6 -0
  88. data/test/examples/lotr.git/logs/HEAD +3 -0
  89. data/test/examples/lotr.git/logs/refs/heads/master +3 -0
  90. data/test/examples/lotr.git/objects/06/131480411710c92a82fe2d1e76932c70feb2e5 +0 -0
  91. data/test/examples/lotr.git/objects/0a/de1e2916346d4c1f2fb63b863fd3c16808fe44 +0 -0
  92. data/test/examples/lotr.git/objects/0e/d8cbe0a25235bd867e65193c7d837c66b328ef +3 -0
  93. data/test/examples/lotr.git/objects/12/629d666c5e3178f82f533f543d61b53dc78c0b +0 -0
  94. data/test/examples/lotr.git/objects/1d/b89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 +2 -0
  95. data/test/examples/lotr.git/objects/24/49c2681badfd3c189e8ed658dacffe8ba48fe5 +0 -0
  96. data/test/examples/lotr.git/objects/25/4bdc1ba27d8b8a794538a8522d9a2b56ec2dd9 +0 -0
  97. data/test/examples/lotr.git/objects/2c/b9156ad383914561a8502fc70f5a1d887e48ad +4 -0
  98. data/test/examples/lotr.git/objects/5d/cac289a8603188d2c5caf481dcba2985126aaa +0 -0
  99. data/test/examples/lotr.git/objects/60/f12f4254f58801b9ee7db7bca5fa8aeefaa56b +0 -0
  100. data/test/examples/lotr.git/objects/71/4323c104239440a5c66ab12a67ed07a83c404f +0 -0
  101. data/test/examples/lotr.git/objects/84/0ec5b1ba1320e8ec443f28f99566f615d5af10 +0 -0
  102. data/test/examples/lotr.git/objects/93/6b83ee0dd8837adb82511e40d5e4ebe59bb675 +0 -0
  103. data/test/examples/lotr.git/objects/94/523d7ae48aeba575099dd12926420d8fd0425d +2 -0
  104. data/test/examples/lotr.git/objects/96/97dc65e095658bbd1b8e8678e08881e86d32f1 +0 -0
  105. data/test/examples/lotr.git/objects/a3/1ca2a7c352c92531a8b99815d15843b259e814 +0 -0
  106. data/test/examples/lotr.git/objects/a6/59b3763b822dd97544621fd0beef162ea37b14 +4 -0
  107. data/test/examples/lotr.git/objects/a8/ad3c09dd842a3517085bfadd37718856dee813 +0 -0
  108. data/test/examples/lotr.git/objects/aa/b61fe89d56f8614c0a8151da34f939dcedfa68 +0 -0
  109. data/test/examples/lotr.git/objects/bc/4b5fc0ce2c2ba3acef6647e4f67256ee45ab60 +0 -0
  110. data/test/examples/lotr.git/objects/c3/b43e9f08966b088e7a0192e436b7a884542e05 +0 -0
  111. data/test/examples/lotr.git/objects/dc/596d6b2dd89ab05c66f4abd7d5eb706bc17f19 +0 -0
  112. data/test/examples/lotr.git/objects/ec/da3205bee14520aab5a7bb307392064b938e83 +0 -0
  113. data/test/examples/lotr.git/objects/f4/84ebb1f40f8eb20d1bcd8d1d71934d2b8ae961 +0 -0
  114. data/test/examples/lotr.git/objects/fa/e7ef5344202bba4129abdc13060d9297d99465 +3 -0
  115. data/test/examples/lotr.git/objects/info/packs +2 -0
  116. data/test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.idx +0 -0
  117. data/test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.pack +0 -0
  118. data/test/examples/lotr.git/packed-refs +2 -0
  119. data/test/examples/lotr.git/refs/heads/master +1 -0
  120. data/test/examples/lotr.git/refs/remotes/origin/HEAD +1 -0
  121. data/test/examples/page_file_dir.git/COMMIT_EDITMSG +1 -0
  122. data/test/examples/page_file_dir.git/HEAD +1 -0
  123. data/test/examples/page_file_dir.git/config +6 -0
  124. data/test/examples/page_file_dir.git/description +1 -0
  125. data/test/examples/page_file_dir.git/index +0 -0
  126. data/test/examples/page_file_dir.git/info/exclude +6 -0
  127. data/test/examples/page_file_dir.git/logs/HEAD +1 -0
  128. data/test/examples/page_file_dir.git/logs/refs/heads/master +1 -0
  129. data/test/examples/page_file_dir.git/objects/0c/7d27db1f575263efdcab3dc650f4502a2dbcbf +0 -0
  130. data/test/examples/page_file_dir.git/objects/22/b404803c966dd92865614d86ff22ca12e50c1e +0 -0
  131. data/test/examples/page_file_dir.git/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99 +0 -0
  132. data/test/examples/page_file_dir.git/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6 +0 -0
  133. data/test/examples/page_file_dir.git/objects/5b/43e14e0a15fb6f08feab1773d1c0991e9f71e2 +0 -0
  134. data/test/examples/page_file_dir.git/refs/heads/master +1 -0
  135. data/test/examples/revert.git/COMMIT_EDITMSG +1 -0
  136. data/test/examples/revert.git/HEAD +1 -0
  137. data/test/examples/revert.git/config +12 -0
  138. data/test/examples/revert.git/description +1 -0
  139. data/test/examples/revert.git/index +0 -0
  140. data/test/examples/revert.git/info/exclude +6 -0
  141. data/test/examples/revert.git/logs/HEAD +2 -0
  142. data/test/examples/revert.git/logs/refs/heads/master +2 -0
  143. data/test/examples/revert.git/objects/20/2ced67cea93c7b6bd2928aa1daef8d1d55a20d +0 -0
  144. data/test/examples/revert.git/objects/41/76394bfa11222363c66ce7e84b5f154095b6d9 +0 -0
  145. data/test/examples/revert.git/objects/6a/69f92020f5df77af6e8813ff1232493383b708 +0 -0
  146. data/test/examples/revert.git/objects/b4/785957bc986dc39c629de9fac9df46972c00fc +0 -0
  147. data/test/examples/revert.git/objects/f4/03b791119f8232b7cb0ba455c624ac6435f433 +0 -0
  148. data/test/examples/revert.git/objects/info/packs +2 -0
  149. data/test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.idx +0 -0
  150. data/test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.pack +0 -0
  151. data/test/examples/revert.git/packed-refs +2 -0
  152. data/test/examples/revert.git/refs/heads/master +1 -0
  153. data/test/examples/revert.git/refs/remotes/origin/HEAD +1 -0
  154. data/test/examples/yubiwa.git/HEAD +1 -0
  155. data/test/examples/yubiwa.git/config +5 -0
  156. data/test/examples/yubiwa.git/description +1 -0
  157. data/test/examples/yubiwa.git/info/exclude +6 -0
  158. data/test/examples/yubiwa.git/objects/10/fa2ddc4e3b4009d8a453aace10bd6148c1ad00 +0 -0
  159. data/test/examples/yubiwa.git/objects/52/4b82874327ea7cbf730389964ba7cb3de966de +0 -0
  160. data/test/examples/yubiwa.git/objects/58/3fc201cb457fb3f1480f3e1e5999b119633835 +0 -0
  161. data/test/examples/yubiwa.git/objects/87/bc1dd46ab3d3874d4e898d45dd512cc20a7cc8 +1 -0
  162. data/test/examples/yubiwa.git/objects/89/64ed1b4e21aa90e831763bbce9034bfda81b70 +0 -0
  163. data/test/examples/yubiwa.git/objects/9f/f6dd0660da5fba2d3374adb2b84fa653bb538b +0 -0
  164. data/test/examples/yubiwa.git/objects/ac/e97abf2b177815a1972d7db22f229f58c83309 +0 -0
  165. data/test/examples/yubiwa.git/objects/b1/f443863a4816628807fbf86141ebef055dda34 +0 -0
  166. data/test/examples/yubiwa.git/refs/heads/master +1 -0
  167. data/test/helper.rb +66 -0
  168. data/test/test_app.rb +169 -0
  169. data/test/test_committer.rb +64 -0
  170. data/test/test_file.rb +27 -0
  171. data/test/test_git_access.rb +52 -0
  172. data/test/test_markup.rb +628 -0
  173. data/test/test_page.rb +166 -0
  174. data/test/test_page_revert.rb +45 -0
  175. data/test/test_wiki.rb +462 -0
  176. metadata +470 -0
@@ -0,0 +1,263 @@
1
+ /**
2
+ * gollum.dialog.js
3
+ *
4
+ * Used for dialogs. Duh.
5
+ *
6
+ */
7
+
8
+ (function($) {
9
+
10
+ var Dialog = {
11
+
12
+ debugOn: false,
13
+ markupCreated: false,
14
+ markup: '',
15
+
16
+ attachEvents: function( evtOK ) {
17
+ $('#gollum-dialog-action-ok').click(function( e ) {
18
+ Dialog.eventOK( e, evtOK );
19
+ });
20
+ $('#gollum-dialog-action-cancel').click( Dialog.eventCancel );
21
+ $('#gollum-dialog-dialog input[type="text"]').keydown(function( e ) {
22
+ if ( e.keyCode == 13 ) {
23
+ Dialog.eventOK( e, evtOK );
24
+ }
25
+ });
26
+ },
27
+
28
+ detachEvents: function() {
29
+ $('#gollum-dialog-action-ok').unbind('click');
30
+ $('#gollum-dialog-action-cancel').unbind('click');
31
+ },
32
+
33
+ createFieldMarkup: function( fieldArray ) {
34
+ var fieldMarkup = '<fieldset>';
35
+ for ( var i=0; i < fieldArray.length; i++ ) {
36
+ if ( typeof fieldArray[i] == 'object' ) {
37
+ fieldMarkup += '<div class="field">';
38
+ switch ( fieldArray[i].type ) {
39
+
40
+ // only text is supported for now
41
+ case 'text':
42
+ fieldMarkup += Dialog.createFieldText( fieldArray[i] );
43
+ break;
44
+
45
+ default:
46
+ break;
47
+
48
+ }
49
+ fieldMarkup += '</div>';
50
+ }
51
+
52
+ }
53
+ fieldMarkup += '</fieldset>';
54
+ return fieldMarkup;
55
+ },
56
+
57
+ createFieldText: function( fieldAttributes ) {
58
+ var html = '';
59
+
60
+ if ( fieldAttributes.name ) {
61
+ html += '<label';
62
+ if ( fieldAttributes.id ) {
63
+ html += ' for="' + fieldAttributes.name + '"';
64
+ }
65
+ html += '>' + fieldAttributes.name + '</label>';
66
+ }
67
+
68
+ html += '<input type="text"';
69
+
70
+ if ( fieldAttributes.id ) {
71
+ html += ' name="' + fieldAttributes.id + '"'
72
+ if ( fieldAttributes.type == 'code' ) {
73
+ html+= ' class="code"';
74
+ }
75
+ html += ' id="gollum-dialog-dialog-generated-field-' +
76
+ fieldAttributes.id + '">';
77
+ }
78
+
79
+ return html;
80
+ },
81
+
82
+ createMarkup: function( title, body ) {
83
+ Dialog.markupCreated = true;
84
+ if ($.facebox) {
85
+ return '<div id="gollum-dialog-dialog">' +
86
+ '<div id="gollum-dialog-dialog-title"><h4>' +
87
+ title +'</h4></div>' +
88
+ '<div id="gollum-dialog-dialog-body">' + body + '</div>' +
89
+ '<div id="gollum-dialog-dialog-buttons">' +
90
+ '<a href="#" title="Cancel" id="gollum-dialog-action-cancel" ' +
91
+ 'class="gollum-minibutton">Cancel</a>' +
92
+ '<a href="#" title="OK" id="gollum-dialog-action-ok" '+
93
+ 'class="gollum-minibutton">OK</a>' +
94
+ '</div>' +
95
+ '</div>';
96
+ } else {
97
+ return '<div id="gollum-dialog-dialog">' +
98
+ '<div id="gollum-dialog-dialog-inner">' +
99
+ '<div id="gollum-dialog-dialog-bg">' +
100
+ '<div id="gollum-dialog-dialog-title"><h4>' +
101
+ title +'</h4></div>' +
102
+ '<div id="gollum-dialog-dialog-body">' + body + '</div>' +
103
+ '<div id="gollum-dialog-dialog-buttons">' +
104
+ '<a href="#" title="Cancel" id="gollum-dialog-action-cancel" ' +
105
+ 'class="minibutton">Cancel</a>' +
106
+ '<a href="#" title="OK" id="gollum-dialog-action-ok" '+
107
+ 'class="minibutton">OK</a>' +
108
+ '</div>' +
109
+ '</div>' +
110
+ '</div>' +
111
+ '</div>';
112
+ }
113
+ },
114
+
115
+ eventCancel: function( e ) {
116
+ e.preventDefault();
117
+ debug('Cancelled dialog.');
118
+ Dialog.hide();
119
+ },
120
+
121
+ eventOK: function( e, evtOK ) {
122
+ e.preventDefault();
123
+
124
+ var results = [];
125
+ // get the results from each field and build them into the object
126
+ $('#gollum-dialog-dialog-body input').each(function() {
127
+ results[$(this).attr('name')] = $(this).val();
128
+ });
129
+
130
+ // pass them to evtOK if it exists (which it should)
131
+ if ( evtOK &&
132
+ typeof evtOK == 'function' ) {
133
+ evtOK( results );
134
+ }
135
+ Dialog.hide();
136
+ },
137
+
138
+ hide: function() {
139
+ if ( $.facebox ) {
140
+ Dialog.markupCreated = false;
141
+ $(document).trigger('close.facebox');
142
+ Dialog.detachEvents();
143
+ } else {
144
+ if ( $.browser.msie ) {
145
+ $('#gollum-dialog-dialog').hide().removeClass('active');
146
+ $('select').css('visibility', 'visible');
147
+ } else {
148
+ $('#gollum-dialog-dialog').animate({ opacity: 0 }, {
149
+ duration: 200,
150
+ complete: function() {
151
+ $('#gollum-dialog-dialog').removeClass('active');
152
+ }
153
+ });
154
+ }
155
+ }
156
+ },
157
+
158
+ init: function( argObject ) {
159
+ var title = '';
160
+ var body = '';
161
+
162
+ // bail out if necessary
163
+ if ( !argObject ||
164
+ typeof argObject != 'object' ) {
165
+ debug('Editor Dialog: Cannot init; invalid init object');
166
+ return;
167
+ }
168
+
169
+ if ( argObject.body && typeof argObject.body == 'string' ) {
170
+ body = '<p>' + argObject.body + '</p>';
171
+ }
172
+
173
+ // alright, build out fields
174
+ if ( argObject.fields && typeof argObject.fields == 'object' ) {
175
+ body += Dialog.createFieldMarkup( argObject.fields );
176
+ }
177
+
178
+ if ( argObject.title && typeof argObject.title == 'string' ) {
179
+ title = argObject.title;
180
+ }
181
+
182
+ if ( Dialog.markupCreated ) {
183
+ if ($.facebox) {
184
+ $(document).trigger('close.facebox');
185
+ } else {
186
+ $('#gollum-dialog-dialog').remove();
187
+ }
188
+ }
189
+
190
+ Dialog.markup = Dialog.createMarkup( title, body );
191
+
192
+ if ($.facebox) {
193
+ $(document).bind('reveal.facebox', function() {
194
+ if ( argObject.OK &&
195
+ typeof argObject.OK == 'function' ) {
196
+ Dialog.attachEvents( argObject.OK );
197
+ $($('#facebox input[type="text"]').get(0)).focus();
198
+ }
199
+ });
200
+ } else {
201
+ $('body').append( Dialog.markup );
202
+ if ( argObject.OK &&
203
+ typeof argObject.OK == 'function' ) {
204
+ Dialog.attachEvents( argObject.OK );
205
+ }
206
+ }
207
+
208
+ Dialog.show();
209
+ },
210
+
211
+ show: function() {
212
+ if ( !Dialog.markupCreated ) {
213
+ debug('Dialog: No markup to show. Please use init first.');
214
+ } else {
215
+ debug('Showing dialog');
216
+ if ($.facebox) {
217
+ $.facebox( Dialog.markup );
218
+ } else {
219
+ if ( $.browser.msie ) {
220
+ $('#gollum-dialog.dialog').addClass('active');
221
+ Dialog.position();
222
+ $('select').css('visibility', 'hidden');
223
+ } else {
224
+ $('#gollum-dialog.dialog').css('display', 'none');
225
+ $('#gollum-dialog-dialog').animate({ opacity: 0 }, {
226
+ duration: 0,
227
+ complete: function() {
228
+ $('#gollum-dialog-dialog').css('display', 'block');
229
+ Dialog.position(); // position this thing
230
+ $('#gollum-dialog-dialog').animate({ opacity: 1 }, {
231
+ duration: 500
232
+ });
233
+ }
234
+ });
235
+ }
236
+ }
237
+ }
238
+ },
239
+
240
+ position: function() {
241
+ var dialogHeight = $('#gollum-dialog-dialog-inner').height();
242
+ $('#gollum-dialog-dialog-inner')
243
+ .css('height', dialogHeight + 'px')
244
+ .css('margin-top', -1 * parseInt( dialogHeight / 2 ));
245
+ }
246
+ };
247
+
248
+ if ($.facebox) {
249
+ $(document).bind('reveal.facebox', function() {
250
+ $('#facebox img.close_image').remove();
251
+ });
252
+ }
253
+
254
+ var debug = function(m) {
255
+ if ( Dialog.debugOn
256
+ && typeof console != 'undefined' ) {
257
+ console.log( m );
258
+ }
259
+ };
260
+
261
+ $.GollumDialog = Dialog;
262
+
263
+ })(jQuery);
@@ -0,0 +1,161 @@
1
+ // ua
2
+ $(document).ready(function() {
3
+ var nodeSelector = {
4
+ node1: null,
5
+ node2: null,
6
+
7
+ selectNodeRange: function( n1, n2 ) {
8
+ if ( nodeSelector.node1 && nodeSelector.node2 ) {
9
+ $('#wiki-history td.selected').removeClass('selected');
10
+ nodeSelector.node1.addClass('selected');
11
+ nodeSelector.node2.addClass('selected');
12
+
13
+ // swap the nodes around if they went in reverse
14
+ if ( nodeSelector.nodeComesAfter( nodeSelector.node1,
15
+ nodeSelector.node2 ) ) {
16
+ var n = nodeSelector.node1;
17
+ nodeSelector.node1 = nodeSelector.node2;
18
+ nodeSelector.node2 = n;
19
+ }
20
+
21
+ var s = true;
22
+ var $nextNode = nodeSelector.node1.next();
23
+ while ( $nextNode ) {
24
+ $nextNode.addClass('selected');
25
+ if ( $nextNode[0] == nodeSelector.node2[0] ) {
26
+ break;
27
+ }
28
+ $nextNode = $nextNode.next();
29
+ }
30
+ }
31
+ },
32
+
33
+ nodeComesAfter: function ( n1, n2 ) {
34
+ var s = false;
35
+ $(n1).prevAll().each(function() {
36
+ if ( $(this)[0] == $(n2)[0] ) {
37
+ s = true;
38
+ }
39
+ });
40
+ return s;
41
+ },
42
+
43
+ checkNode: function( nodeCheckbox ) {
44
+ var $nodeCheckbox = nodeCheckbox;
45
+ var $node = $(nodeCheckbox).parent().parent();
46
+ // if we're unchecking
47
+ if ( !$nodeCheckbox.is(':checked') ) {
48
+
49
+ // remove the range, since we're breaking it
50
+ $('#wiki-history tr.selected').each(function() {
51
+ if ( $(this).find('td.checkbox input').is(':checked') ) {
52
+ return;
53
+ }
54
+ $(this).removeClass('selected');
55
+ });
56
+
57
+ // no longer track this
58
+ if ( $node[0] == nodeSelector.node1[0] ) {
59
+ nodeSelector.node1 = null;
60
+ if ( nodeSelector.node2 ) {
61
+ nodeSelector.node1 = nodeSelector.node2;
62
+ nodeSelector.node2 = null;
63
+ }
64
+ } else if ( $node[0] == nodeSelector.node2[0] ) {
65
+ nodeSelector.node2 = null;
66
+ }
67
+
68
+ } else {
69
+ if ( !nodeSelector.node1 ) {
70
+ nodeSelector.node1 = $node;
71
+ nodeSelector.node1.addClass('selected');
72
+ } else if ( !nodeSelector.node2 ) {
73
+ // okay, we don't have a node 2 but have a node1
74
+ nodeSelector.node2 = $node;
75
+ nodeSelector.node2.addClass('selected');
76
+ nodeSelector.selectNodeRange( nodeSelector.node1,
77
+ nodeSelector.node2 );
78
+ } else {
79
+ // we have two selected already
80
+ $nodeCheckbox[0].checked = false;
81
+ }
82
+ }
83
+ }
84
+ };
85
+
86
+ // ua detection
87
+ if ($.browser.mozilla) {
88
+ $('body').addClass('ff');
89
+ } else if ($.browser.webkit) {
90
+ $('body').addClass('webkit');
91
+ } else if ($.browser.msie) {
92
+ $('body').addClass('ie');
93
+ if ($.browser.version == "7.0") {
94
+ $('body').addClass('ie7');
95
+ } else if ($.browser.version == "8.0") {
96
+ $('body').addClass('ie8');
97
+ }
98
+ }
99
+
100
+ if ($('#minibutton-new-page').length) {
101
+ $('#minibutton-new-page').removeClass('jaws');
102
+ $('#minibutton-new-page').click(function(e) {
103
+ e.preventDefault();
104
+ $.GollumDialog.init({
105
+ title: 'Create New Page',
106
+ fields: [
107
+ {
108
+ id: 'name',
109
+ name: 'Page Name',
110
+ type: 'text'
111
+ }
112
+ ],
113
+ OK: function( res ) {
114
+ var n = 'New Page';
115
+ if ( res['name'] )
116
+ var n = res['name'];
117
+ n = encodeURIComponent( n );
118
+ window.location = '/' + n;
119
+ }
120
+ });
121
+ });
122
+ }
123
+
124
+ if ($('#wiki-wrapper').hasClass('history')) {
125
+ $('#wiki-history td.checkbox input').each(function() {
126
+ $(this).click(function() {
127
+ nodeSelector.checkNode($(this));
128
+ });
129
+ if ( $(this).is(':checked') ) {
130
+ nodeSelector.checkNode($(this));
131
+ }
132
+ });
133
+
134
+ if ($('.history a.action-compare-revision').length) {
135
+ $('.history a.action-compare-revision').click(function() {
136
+ $("#version-form").submit();
137
+ });
138
+ }
139
+ }
140
+
141
+ if ($('#searchbar a#search-submit').length) {
142
+ $.GollumPlaceholder.add($('#searchbar #search-query'));
143
+ $('#searchbar a#search-submit').click(function(e) {
144
+ e.preventDefault();
145
+ $('#searchbar #search-form')[0].submit();
146
+ });
147
+ $('#searchbar #search-form').submit(function(e) {
148
+ $.GollumPlaceholder.clearAll();
149
+ $(this).unbind('submit');
150
+ $(this).submit();
151
+ });
152
+ }
153
+
154
+ if ($('#gollum-revert-form').length &&
155
+ $('.gollum-revert-button').length ) {
156
+ $('a.gollum-revert-button').click(function(e) {
157
+ e.preventDefault();
158
+ $('#gollum-revert-form').submit();
159
+ });
160
+ }
161
+ });
@@ -0,0 +1,54 @@
1
+ (function($) {
2
+
3
+ var Placeholder = {
4
+
5
+ _PLACEHOLDERS : [],
6
+
7
+ _p : function( $field ) {
8
+
9
+ this.fieldObject = $field;
10
+ this.placeholderText = $field.val();
11
+ var placeholderText = $field.val();
12
+
13
+ $field.addClass('ph');
14
+
15
+ $field.blur(function() {
16
+ if ( $(this).val() == '' ) {
17
+ $(this).val( placeholderText );
18
+ $(this).addClass('ph');
19
+ }
20
+ });
21
+
22
+ $field.focus(function() {
23
+ $(this).removeClass('ph');
24
+ if ( $(this).val() == placeholderText ) {
25
+ $(this).val('');
26
+ } else {
27
+ $(this)[0].select();
28
+ }
29
+ });
30
+
31
+ },
32
+
33
+ add : function( $field ) {
34
+ Placeholder._PLACEHOLDERS.push( new Placeholder._p( $field ) );
35
+ },
36
+
37
+ clearAll: function() {
38
+ for ( var i=0; i < Placeholder._PLACEHOLDERS.length; i++ ) {
39
+ if ( Placeholder._PLACEHOLDERS[i].fieldObject.val() ==
40
+ Placeholder._PLACEHOLDERS[i].placeholderText ) {
41
+ Placeholder._PLACEHOLDERS[i].fieldObject.val('');
42
+ }
43
+ }
44
+ },
45
+
46
+ exists : function() {
47
+ return ( _PLACEHOLDERS.length );
48
+ }
49
+
50
+ };
51
+
52
+ $.GollumPlaceholder = Placeholder;
53
+
54
+ })(jQuery);