chiliproject_side_by_side_wiki_edit 0.1.0

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ === 0.1.0 2012-09-28
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Joris Kraak
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,15 @@
1
+ .gitignore
2
+ Gemfile
3
+ History.txt
4
+ LICENSE
5
+ Manifest.txt
6
+ README.md
7
+ Rakefile
8
+ assets/javascripts/side_by_side_edit.js
9
+ chiliproject_side_by_side_wiki_edit.gemspec
10
+ init.rb
11
+ lib/chiliproject_side_by_side_wiki_edit.rb
12
+ lib/chiliproject_side_by_side_wiki_edit/hooks/view_wiki_edit_hook.rb
13
+ lib/chiliproject_side_by_side_wiki_edit/version.rb
14
+ lib/tasks/chiliproject_side_by_side_wiki_edit_tasks.rb
15
+ rails/init.rb
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # ChiliProject - Side by side wiki edit plugin
2
+
3
+ * http://github.com/bauglir/chiliproject_side_by_side_wiki_edit/
4
+
5
+ This plugin adds a checkbox on wiki edit pages to put the editor and the
6
+ preview window side by side.
7
+
8
+ The layout of the page is completely handled client-side. Rendering of
9
+ the preview is handled by ChiliProject itself server-side. This allows
10
+ liquid macros and such to work properly
11
+
12
+ ## Installation
13
+
14
+ In your 'Gemfile', add:
15
+ ```
16
+ gem chiliproject_side_by_side_wiki_edit
17
+ ```
18
+
19
+ Then run either `bundle install` or `bundle update` depending on your situation.
20
+
21
+ Next, in your 'Rakefile', add:
22
+ ```
23
+ require 'tasks/chiliproject_side_by_side_wiki_edit_tasks'
24
+ ```
25
+
26
+ Run the installation task
27
+ ```
28
+ RAILS_ENV=production rake chiliproject_side_by_side_wiki_edit:install
29
+ ```
30
+
31
+ Finally cycle your application server to enable the plugin
32
+
33
+ ## LICENSE:
34
+
35
+ Refer to the [LICENSE](https://github.com/bauglir/chiliproject_side_by_side_wiki_edit/blob/master/LICENSE) file
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,46 @@
1
+ jQuery(function() {
2
+ var $ = jQuery;
3
+ var editor = $('textarea.wiki-edit');
4
+ var preview = $('div#preview');
5
+ var preview_link = $('input[name=commit]').next();
6
+
7
+ var disable = function() {
8
+ editor.parentsUntil('p').parent().removeAttr('style');
9
+ preview.removeAttr('style');
10
+ $('#content').append(preview);
11
+ };
12
+
13
+ var enable = function() {
14
+ var editorParent = editor.parentsUntil('p').parent();
15
+
16
+ editorParent.css('width', '49%').before(preview);
17
+ preview.css({ 'float': 'right', 'width': '49%', 'margin-top': '5ex', 'overflow-y': 'scroll' });
18
+ preview.height(editor.height() + 5);
19
+
20
+ editor.scroll(preview, scroll_preview);
21
+ editor.scroll();
22
+
23
+ if($('fieldset.preview').length === 0) {
24
+ preview_link.click();
25
+ }
26
+ };
27
+
28
+ var scroll_preview = function(event) {
29
+ var source_position = this.scrollTop / (this.scrollHeight - $(this).innerHeight());
30
+ var target = $(event.data);
31
+
32
+ target.scrollTop(source_position * (target[0].scrollHeight - target.innerHeight()));
33
+ }
34
+
35
+ var toggle_mode = function() {
36
+ if(this.checked) {
37
+ enable();
38
+ } else {
39
+ disable();
40
+ }
41
+ }
42
+
43
+ preview_link.after($('<label for="side_by_side_mode">Show editor and preview side-by-side</label>'))
44
+ .after($('<input id="side_by_side_mode" type="checkbox" />'));
45
+ $('#side_by_side_mode').on('click', toggle_mode);
46
+ });
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/chiliproject_side_by_side_wiki_edit/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Joris Kraak"]
6
+ gem.email = ["me@joriskraak.nl"]
7
+ gem.description = %q{Allows side by side editor/preview functionality for ChiliProject wiki pages}
8
+ gem.summary = %q{This plugin adds a checkbox to the edit page for ChiliProject wiki pages, which allows a user to switch between the default behavior and a side by side editor/preview mode}
9
+ gem.homepage = "http://github.com/bauglir/chiliproject_side_by_side_wiki_edit"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "chiliproject_side_by_side_wiki_edit"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = ChiliprojectSideBySideWikiEdit::VERSION
17
+ end
data/init.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'redmine'
2
+
3
+ Redmine::Plugin.register :chiliproject_side_by_side_wiki_edit do
4
+ name 'Chiliproject Side By Side Wiki Edit plugin'
5
+ author 'Joris Kraak'
6
+ description 'This plugin enables an option to show the preview of a wiki page, side-by-side with the wiki editor'
7
+ version ChiliprojectSideBySideWikiEdit::VERSION
8
+ url 'http://github.com/bauglir/chiliproject_side_by_side_wiki_edit'
9
+ author_url 'http://majorfail.com'
10
+ end
11
+
12
+ require 'chiliproject_side_by_side_wiki_edit/hooks/view_wiki_edit_hook'
@@ -0,0 +1,4 @@
1
+ require "chiliproject_side_by_side_wiki_edit/version"
2
+
3
+ module ChiliprojectSideBySideWikiEdit
4
+ end
@@ -0,0 +1,11 @@
1
+ module ChiliprojectSideBySideWikiEdit
2
+ module Hooks
3
+ class ViewWikiEditHook < Redmine::Hook::ViewListener
4
+ def view_layouts_base_html_head(context = {})
5
+ if context[:controller] && context[:controller].is_a?(WikiController) && (context[:controller].action_name == 'edit')
6
+ javascript_include_tag '/plugin_assets/chiliproject_side_by_side_wiki_edit/javascripts/side_by_side_edit.js'
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module ChiliprojectSideBySideWikiEdit
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,73 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+
4
+ class ChiliprojectSideBySideWikiEditTasks < Rake::TaskLib
5
+ def initialize
6
+ define
7
+ end
8
+
9
+ def define
10
+ namespace :chiliproject_side_by_side_wiki_edit do
11
+ desc "Install ChiliprojectSideBySideWikiEdit plugin (include assets, etc)"
12
+ task :install => [:symlink_assets]
13
+
14
+ desc "Uninstalls ChiliprojectSideBySideWikiEdit plugin (removes database modifications, removes assets, etc)"
15
+ task :uninstall => [:environment] do
16
+ puts "Removing link to ChiliprojectSideBySideWikiEdit assets (stylesheets, js, etc)..."
17
+ remove_symlink asset_destination_dir
18
+ puts post_uninstall_steps
19
+ end
20
+
21
+ task :symlink_assets => [:environment] do
22
+ # HACK: Symlinks the files from plugindir/assets to the appropriate place in
23
+ # the rails application
24
+ puts "Symlinking assets (stylesheets, etc)..."
25
+ add_symlink asset_source_dir, asset_destination_dir
26
+ end
27
+ end
28
+ end
29
+
30
+ private
31
+ def application_root
32
+ File.expand_path(RAILS_ROOT)
33
+ end
34
+
35
+ def gem_root
36
+ @gem_root ||= File.expand_path(File.dirname(__FILE__) + "/../..")
37
+ end
38
+
39
+ def asset_destination_dir
40
+ @destination_dir ||= File.expand_path("#{application_root}/public/plugin_assets/chiliproject_side_by_side_wiki_edit")
41
+ end
42
+
43
+ def asset_source_dir
44
+ @source_dir ||= File.expand_path(gem_root + "/assets")
45
+ end
46
+
47
+ def remove_symlink(symlink_file)
48
+ system("unlink #{symlink_file}") if File.exists?(symlink_file)
49
+ end
50
+
51
+ def add_symlink(source, destination)
52
+ remove_symlink destination
53
+ system("ln -s #{source} #{destination}")
54
+ end
55
+
56
+ def post_uninstall_steps
57
+ [
58
+ "!!!!! MANUAL STEPS !!!!!",
59
+ "\t1. In your 'Gemfile', remove:",
60
+ "\t\tgem 'chiliproject_side_by_side_wiki_edit'",
61
+ "",
62
+ "\t2. In your 'Rakefile', remove:",
63
+ "\t\trequire 'tasks/chiliproject_side_by_side_wiki_edit_tasks'",
64
+ "",
65
+ "\t3. Run 'bundle' (or 'bundle install') to update your Gemfile.lock",
66
+ "",
67
+ "\t4. Cycle your application server (mongrel, unicorn, etc)",
68
+ "\n",
69
+ ].join("\n")
70
+ end
71
+ end
72
+
73
+ ChiliprojectSideBySideWikiEditTasks.new
data/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/../init"
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chiliproject_side_by_side_wiki_edit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Joris Kraak
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-28 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Allows side by side editor/preview functionality for ChiliProject wiki
15
+ pages
16
+ email:
17
+ - me@joriskraak.nl
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - History.txt
25
+ - LICENSE
26
+ - Manifest.txt
27
+ - README.md
28
+ - Rakefile
29
+ - assets/javascripts/side_by_side_edit.js
30
+ - chiliproject_side_by_side_wiki_edit.gemspec
31
+ - init.rb
32
+ - lib/chiliproject_side_by_side_wiki_edit.rb
33
+ - lib/chiliproject_side_by_side_wiki_edit/hooks/view_wiki_edit_hook.rb
34
+ - lib/chiliproject_side_by_side_wiki_edit/version.rb
35
+ - lib/tasks/chiliproject_side_by_side_wiki_edit_tasks.rb
36
+ - rails/init.rb
37
+ homepage: http://github.com/bauglir/chiliproject_side_by_side_wiki_edit
38
+ licenses: []
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ segments:
50
+ - 0
51
+ hash: 1310505938391298615
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ segments:
59
+ - 0
60
+ hash: 1310505938391298615
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.23
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: This plugin adds a checkbox to the edit page for ChiliProject wiki pages,
67
+ which allows a user to switch between the default behavior and a side by side editor/preview
68
+ mode
69
+ test_files: []