Skip to content

Commit 41db545

Browse files
committed
#3 Add WYSIWYG editor
1 parent 9077f0e commit 41db545

File tree

7 files changed

+32
-2
lines changed

7 files changed

+32
-2
lines changed

Gemfile.lock

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ PATH
22
remote: .
33
specs:
44
kebapage (0.0.1)
5+
bootstrap-sass
6+
bootstrap-wysihtml5-rails
57
friendly_id
68
haml (~> 4.0.2)
79
haml-rails
@@ -38,6 +40,10 @@ GEM
3840
tzinfo (~> 0.3.37)
3941
arel (4.0.1)
4042
atomic (1.1.14)
43+
bootstrap-sass (3.0.3.0)
44+
sass (~> 3.2)
45+
bootstrap-wysihtml5-rails (0.3.1.23)
46+
railties (>= 3.0)
4147
builder (3.1.4)
4248
erubis (2.7.0)
4349
friendly_id (5.0.2)
@@ -78,6 +84,7 @@ GEM
7884
rake (>= 0.8.7)
7985
thor (>= 0.18.1, < 2.0)
8086
rake (10.1.1)
87+
sass (3.2.13)
8188
sprockets (2.10.1)
8289
hike (~> 1.2)
8390
multi_json (~> 1.0)

app/assets/javascripts/kebapage/application.js

+4
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
1111
// about supported directives.
1212
//
13+
//= require jquery
14+
//= require jquery_ujs
15+
//= reuqire bootstrap
16+
//= require bootstrap-wysihtml5
1317
//= require_tree .
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
// Place all the behaviors and hooks related to the matching controller here.
22
// All this logic will automatically be available in application.js.
3+
4+
$('.wysihtml5').each(function(i, elem) {
5+
$(elem).wysihtml5();
6+
});
7+
8+
$(document).on('page:load', function(){
9+
window['rangy'].initialized = false;
10+
});

app/assets/stylesheets/kebapage/application.css

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
* You're free to add application-wide styles to this file and they'll appear at the top of the
99
* compiled file, but it's generally better to create a new file per style scope.
1010
*
11+
*= require bootstrap-wysihtml5
1112
*= require_self
1213
*= require_tree .
1314
*/
15+
16+
@import "bootstrap";

app/views/kebapage/static_pages/_form.html.haml

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
=stylesheet_link_tag "kebapage/application"
2+
13
.panel.panel-default
24
.panel-heading
35
%i.icon-edit.icon-large
@@ -11,8 +13,10 @@
1113

1214
.form-group
1315
= f.label I18n.t('kebapage.content'), class: 'control-label'
14-
= f.text_area :content, class: 'form-control', placeholder: I18n.t('kebapage.content_placeholder'), rows: 4
16+
= f.text_area :content, class: 'form-control wysihtml5', placeholder: I18n.t('kebapage.content_placeholder'), rows: 15
1517

1618
.form-actions
1719
%button.btn.btn-default{type: 'submit'} #{I18n.t('kebapage.submit')}
18-
%a.btn{href: static_pages_path} #{I18n.t('kebapage.cancel')}
20+
%a.btn{href: static_pages_path} #{I18n.t('kebapage.cancel')}
21+
22+
=javascript_include_tag "kebapage/application"

kebapage.gemspec

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Gem::Specification.new do |s|
2121
s.add_dependency "i18n", "~> 0.6.9"
2222
s.add_dependency "haml-rails"
2323
s.add_dependency "friendly_id"
24+
s.add_dependency "bootstrap-sass"
25+
s.add_dependency "bootstrap-wysihtml5-rails"
2426

2527
s.add_development_dependency "sqlite3"
2628
end

lib/kebapage.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
require "kebapage/engine"
22
require "friendly_id"
3+
require "bootstrap-sass"
4+
require "bootstrap-wysihtml5-rails"
35

46
module Kebapage
57
end

0 commit comments

Comments
 (0)