formol 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -58,14 +58,60 @@ When I would have read travis documentation, I'll test it on more platforms / db
58
58
 
59
59
  ## Installation
60
60
 
61
- As long as formol is in pre-alpha version, it won't be packaged as a gem.
62
- It should be installable as a rails plugin but I didn't try it.
61
+ You can now install formol as a gem.
62
+
63
+ To install 0.0.4 (actual gem pushed)
64
+
65
+ ```ruby
66
+ #in your Gemfile
67
+
68
+ gem 'formol'
69
+ ```
70
+
71
+ To install 0.0.5 (actual master revision)
72
+
73
+ ```ruby
74
+ #in your Gemfile
75
+
76
+ gem 'formol', :git => 'https://github.com/mulasse/formol'
77
+ ```
78
+
79
+ then, execute `rails g formol:install`
80
+
81
+ You could have an issue saying that you're call method 'user class' on nil. That's because I load an observer in Formol::Engine.
82
+ I have no solution against this at the moment. Every tip is welcome.
83
+
84
+ Once `formol:install` has run, you should do the following things:
85
+
86
+ * run `rake db:migrate`
87
+ * add `<%= include_formol_javascripts %>` and `<%= include_formol_stylesheets %>` in the head section of your application layout
88
+ * add `include Formol::Integration::User` in your `User` model
89
+ * add one or more text-formatter gems into your gemfile (actually, only 'formol-markdown')
90
+ * edit initializer file and change `config.text_formatter` if you want something else than markdown
91
+
92
+ Formol expect your 'User' model to provide a method/property called `display_name`.
93
+ If your model hasn't it already, create this method and return whatever you want (nickname, firstname + lastname ...)
94
+
95
+ If you want to use syntax-highlighting, add a `stylesheet_link_tag` with `pygments/one_of_pyments_stylesheets` as param in your application layout.
96
+ You can find all pygments stylesheets in `app/assets/pygments`. This will be improved in the future.
97
+
98
+ Formol relies on jquery, jquery-ui and jquery_ujs.
99
+ You should have them in your application.css or application layout.
100
+
101
+ Without jquery-ui, sort categories / forums and change forum's categories won't be available in admin.
102
+
103
+ NOTICE:
104
+
105
+ 0.0.4 & 0.0.5 are unstable. Almost all functionalities are tested BUT application is not complete.
106
+ You should not use Formol in production for now.
63
107
 
64
108
  ## Features
65
109
 
66
110
  * Administration
67
111
  * categories
68
112
  * forums
113
+ * Forums
114
+ * mark all topics as read
69
115
  * Topics
70
116
  * locking topics
71
117
  * viewing all topics for a forum
@@ -81,9 +127,10 @@ It should be installable as a rails plugin but I didn't try it.
81
127
  * quoting
82
128
  * display user's signature
83
129
  * RTE
130
+ * gravatars (based on User#email with default avatar)
131
+ * avatars (bringed by your own)
84
132
  * Text formatting
85
- * markdown
86
- * syntax highlighting
133
+ * markdown + syntax highlighting (gem 'formol-markdown')
87
134
  * User preferences
88
135
  * display signatures
89
136
  * display avatars
@@ -93,7 +140,27 @@ It should be installable as a rails plugin but I didn't try it.
93
140
  * Misc
94
141
  * install generator
95
142
  * gemspec
96
- * basic styles
143
+ * basic style
144
+
145
+ ## Help on avatars
146
+
147
+ If you provide your own system of avatar storage, you'll need to provide `avatar_url` in your User model.
148
+
149
+ An example, with paperclip:
150
+
151
+ ```ruby
152
+ class User < ActiveRecord::Base
153
+ has_attached_file :avatar, :styles => { :thumb => '100x100>' }
154
+
155
+ def avatar_url
156
+ avatar.url(:thumb)
157
+ end
158
+ end
159
+ ```
160
+
161
+ Formol works well with 100x100 avatars (according to basic style)
162
+
163
+ NOTICE: formol will look first for `avatar_url`, then for `email` and then fallback to default avatar
97
164
 
98
165
  ## Preview
99
166
 
@@ -127,7 +194,6 @@ Others:
127
194
 
128
195
  ## Coming next
129
196
 
130
- * Mark all topics as read (actually have no scaling solution)
131
197
  * Soft delete topics (i'm not sure now since all tests failed because soft deletion doesn't trigger destroy callbacks)
132
198
  * Theme support
133
199
  * Generator (devise views)
@@ -135,8 +201,6 @@ Others:
135
201
  * Selenium tests
136
202
  * More translations (french of course and more)
137
203
  * Permissions management (by admin)
138
- * Gravatars
139
- * Avatar uploading
140
204
 
141
205
  ## Boring legal stuff
142
206
 
@@ -10,6 +10,14 @@ module Formol
10
10
  respond_with(forum)
11
11
  end
12
12
 
13
+ def mark_as_read
14
+ formol_authorize!(current_formol_user, :read_forum)
15
+
16
+ forum.mark_as_read(current_formol_user) if current_formol_user
17
+
18
+ respond_with(forum)
19
+ end
20
+
13
21
  protected
14
22
 
15
23
  def forum
@@ -72,6 +72,38 @@ module Formol
72
72
 
73
73
  respond_with(topic, :location => forum)
74
74
  end
75
+
76
+ def pin
77
+ formol_authorize!(current_formol_user, :pin_topic)
78
+
79
+ topic.pin_topic!
80
+
81
+ respond_with(topic, :location => [forum, topic])
82
+ end
83
+
84
+ def unpin
85
+ formol_authorize!(current_formol_user, :pin_topic)
86
+
87
+ topic.unpin_topic!
88
+
89
+ respond_with(topic, :location => [forum, topic])
90
+ end
91
+
92
+ def lock
93
+ formol_authorize!(current_formol_user, :lock_topic)
94
+
95
+ topic.lock_topic!
96
+
97
+ respond_with(topic, :location => [forum, topic])
98
+ end
99
+
100
+ def unlock
101
+ formol_authorize!(current_formol_user, :lock_topic)
102
+
103
+ topic.unlock_topic!
104
+
105
+ respond_with(topic, :location => [forum, topic])
106
+ end
75
107
 
76
108
  protected
77
109
 
@@ -15,5 +15,9 @@ module Formol
15
15
 
16
16
  klasses.join(' ')
17
17
  end
18
+
19
+ def display_mark_as_read?(user, forum)
20
+ formol_authorized?(user, :read_forum) && (user && !forum.read?(user))
21
+ end
18
22
  end
19
23
  end
@@ -23,5 +23,28 @@ module Formol
23
23
 
24
24
  (s && user ? user.preference.display_signatures? : s)
25
25
  end
26
+
27
+ def avatar_for(user)
28
+ img = if user.respond_to?(:avatar_url) && user.avatar_url.present?
29
+ user.avatar_url
30
+ elsif user.respond_to?(:email) && user.email.present?
31
+ require 'digest/md5' unless defined?(Digest::MD5)
32
+
33
+ email_h = Digest::MD5.hexdigest(user.email.to_s.strip.downcase)
34
+ options = { :s => 100, :d => default_avatar }
35
+
36
+ "http://www.gravatar.com/avatar/#{email_h}?#{options.to_param}"
37
+ else
38
+ default_avatar
39
+ end
40
+
41
+ image_tag(img, :alt => user.display_name)
42
+ end
43
+
44
+ def default_avatar
45
+ img = Formol.config.default_avatar
46
+
47
+ img && URI(img).absolute? ? img : request.protocol + request.host_with_port + path_to_image(img)
48
+ end
26
49
  end
27
50
  end
@@ -23,5 +23,33 @@ module Formol
23
23
  formol_authorized?(user, :vote_poll, topic) &&
24
24
  !poll.voted?(user)
25
25
  end
26
+
27
+ def display_edit_topic?(user, topic)
28
+ !topic.locked? && formol_authorized?(user, :edit_topic, topic)
29
+ end
30
+
31
+ def display_subscribe_topic?(user, topic)
32
+ !topic.locked? && formol_authorized?(user, :subscribe_topic, topic)
33
+ end
34
+
35
+ def display_reply_topic?(user, topic)
36
+ !topic.locked? && formol_authorized?(user, :create_post, topic)
37
+ end
38
+
39
+ def display_pin_topic?(user, topic)
40
+ !topic.locked? && !topic.pinned? && formol_authorized?(user, :pin_topic)
41
+ end
42
+
43
+ def display_unpin_topic?(user, topic)
44
+ !topic.locked? && topic.pinned? && formol_authorized?(user, :pin_topic)
45
+ end
46
+
47
+ def display_lock_topic?(user, topic)
48
+ !topic.locked? && formol_authorized?(user, :lock_topic)
49
+ end
50
+
51
+ def display_unlock_topic?(user, topic)
52
+ topic.locked? && formol_authorized?(user, :lock_topic)
53
+ end
26
54
  end
27
55
  end
@@ -73,5 +73,16 @@ module Formol
73
73
  def unregister_last_post
74
74
  update_attributes!(:last_post => posts.order('formol_posts.id').last)
75
75
  end
76
+
77
+ # Mark all unread topics as read for a given user
78
+ def mark_as_read(user)
79
+ topics.unread(user).each do |unread|
80
+ unread.track_for_user!(user)
81
+ end
82
+ end
83
+
84
+ def read?(user)
85
+ topics.unread(user).blank?
86
+ end
76
87
  end
77
88
  end
@@ -119,13 +119,8 @@ module Formol
119
119
  return true if quote_id.blank?
120
120
 
121
121
  q = topic.posts.find(quote_id)
122
- formatter = Formol.config.formatter.new
123
-
124
- # Extract and agnostize it
125
- content_with_quote = "> **#{q.user.display_name} #{I18n.t('.wrote')}:**\n>\n"
126
- content_with_quote << formatter.quote(q.content)
127
122
 
128
- self.content = content_with_quote
123
+ self.content = Formol.config.formatter.new.quote(q.user.display_name, q.content)
129
124
  self.content << "\n\n" #use '<<' to skip normalize_attribute
130
125
  self.content
131
126
  end
@@ -5,7 +5,7 @@ module Formol
5
5
 
6
6
  #Security
7
7
  attr_protected :forum_id, :user_id, :first_post_id, :last_post_id,
8
- :posts_count, :views_count
8
+ :posts_count, :views_count, :pinned, :locked
9
9
 
10
10
  #Virtual attributes
11
11
  attr_accessor :attach_poll
@@ -38,6 +38,8 @@ module Formol
38
38
  validates :posts, :presence => true
39
39
  validates :first_post, :presence => true
40
40
 
41
+ validate :validates_not_locked
42
+
41
43
  #Normalization
42
44
  normalize_attribute :title, :with => [:squish, :blank]
43
45
 
@@ -80,6 +82,22 @@ module Formol
80
82
 
81
83
  #Business methods
82
84
 
85
+ def pin_topic!
86
+ update_attribute(:pinned, true)
87
+ end
88
+
89
+ def unpin_topic!
90
+ update_attribute(:pinned, false)
91
+ end
92
+
93
+ def lock_topic!
94
+ update_attribute(:locked, true)
95
+ end
96
+
97
+ def unlock_topic!
98
+ update_attribute(:locked, false)
99
+ end
100
+
83
101
  # Increments views counter
84
102
  def view!
85
103
  # Use class method instead of instance to avoid concurrence problems
@@ -181,5 +199,10 @@ module Formol
181
199
  def reject_poll_if_needed
182
200
  self.poll = nil if poll && !attach_poll
183
201
  end
202
+
203
+ # add an error on base if topic is locked
204
+ def validates_not_locked
205
+ errors[:base] << I18n.t(:'activerecord.attributes.topic.base.locked') if locked?
206
+ end
184
207
  end
185
208
  end
@@ -10,6 +10,9 @@
10
10
  <% if formol_authorized?(current_formol_user, :create_topic) %>
11
11
  <li class="new_topic"><%= link_to t('.new'), new_forum_topic_path(@forum) %></li>
12
12
  <% end %>
13
+ <% if display_mark_as_read?(current_formol_user, @forum) %>
14
+ <li class="mark_as_read"><%= link_to t('.mark_as_read'), mark_as_read_forum_path(@forum), :method => :put %></li>
15
+ <% end %>
13
16
  </ul>
14
17
 
15
18
  <%= render 'formol/topics/list', :forum => @forum, :topics => @topics %>
@@ -12,7 +12,7 @@
12
12
  <span class="display_name"><%= post.user.display_name %></span>
13
13
  <% if display_avatars?(current_formol_user) %>
14
14
  <figure>
15
- <img alt="<%= post.user.display_name %>" src="/images/emule.png" />
15
+ <%= avatar_for(post.user) %>
16
16
  </figure>
17
17
  <% end %>
18
18
  <span class="posts_count"><%= t('.user_posts') %>: <%= post.user.formol_posts_count %></span>
@@ -1,4 +1,5 @@
1
1
  <%= semantic_form_for [@forum, @topic] do |form| %>
2
+ <%= form.semantic_errors :base %>
2
3
  <%= form.inputs do %>
3
4
  <%= form.input :title %>
4
5
  <% end %>
@@ -10,10 +11,6 @@
10
11
  <%= render 'formol/polls/form', :form => poll_form, :topic => @topic %>
11
12
  <% end %>
12
13
  <% end %>
13
- <%= form.inputs :name => t('.options') do %>
14
- <%= form.input :pinned %>
15
- <%= form.input :locked %>
16
- <% end %>
17
14
  <%= form.buttons do %>
18
15
  <%= form.commit_button %>
19
16
  <% end %>
@@ -4,15 +4,27 @@
4
4
  <h2><%= t('.topic') %>: <%= @topic.title %></h2>
5
5
 
6
6
  <ul class="topic_tools">
7
- <% if formol_authorized?(current_formol_user, :edit_topic, @topic) %>
7
+ <% if display_edit_topic?(current_formol_user, @topic) %>
8
8
  <li class="edit"><%= link_to t('.edit'), edit_forum_topic_path(@forum, @topic) %></li>
9
9
  <% end %>
10
- <% if formol_authorized?(current_formol_user, :subscribe_topic, @topic) %>
10
+ <% if display_subscribe_topic?(current_formol_user, @topic) %>
11
11
  <li class="subscribe"><%= link_to_subscription(@topic, current_formol_user) %></li>
12
12
  <% end %>
13
- <% if formol_authorized?(current_formol_user, :create_post, @topic) %>
13
+ <% if display_reply_topic?(current_formol_user, @topic) %>
14
14
  <li class="new_post"><%= link_to t('.new_post'), new_topic_post_path(@topic) %></li>
15
15
  <% end %>
16
+ <% if display_pin_topic?(current_formol_user, @topic) %>
17
+ <li class="pin_topic"><%= link_to t('.pin_topic'), pin_forum_topic_path(@forum, @topic), :method => :put %></li>
18
+ <% end %>
19
+ <% if display_unpin_topic?(current_formol_user, @topic) %>
20
+ <li class="unpin_topic"><%= link_to t('.unpin_topic'), unpin_forum_topic_path(@forum, @topic), :method => :delete %></li>
21
+ <% end %>
22
+ <% if display_lock_topic?(current_formol_user, @topic) %>
23
+ <li class="lock_topic"><%= link_to t('.lock_topic'), lock_forum_topic_path(@forum, @topic), :method => :put %></li>
24
+ <% end %>
25
+ <% if display_unlock_topic?(current_formol_user, @topic) %>
26
+ <li class="unlock_topic"><%= link_to t('.unlock_topic'), unlock_forum_topic_path(@forum, @topic), :method => :delete %></li>
27
+ <% end %>
16
28
  </ul>
17
29
 
18
30
  <% if @topic.poll %>
@@ -10,4 +10,5 @@ en:
10
10
 
11
11
  show:
12
12
  forum: forum
13
- new: new topic
13
+ new: new topic
14
+ mark_as_read: mark all as read
@@ -1,6 +1,8 @@
1
1
  en:
2
2
  formol:
3
3
  posts:
4
+ wrote: wrote
5
+
4
6
  last_post:
5
7
  go_to_last: go to last message
6
8
  by: by
@@ -7,6 +7,10 @@ en:
7
7
  edit: edit topic
8
8
  subscribe: subscribe
9
9
  unsubscribe: unsubscribe
10
+ pin_topic: pin
11
+ unpin_topic: unpin
12
+ lock_topic: lock
13
+ unlock_topic: unlock
10
14
 
11
15
  topic:
12
16
  created_by: created by
data/config/routes.rb CHANGED
@@ -2,7 +2,18 @@ Formol::Engine.routes.draw do
2
2
  resources :categories, :only => [:index, :show]
3
3
 
4
4
  resources :forums, :only => [:show] do
5
- resources :topics, :except => [:index]
5
+ member do
6
+ put 'mark_as_read'
7
+ end
8
+
9
+ resources :topics, :except => [:index] do
10
+ member do
11
+ put 'lock'
12
+ put 'pin'
13
+ delete 'unlock'
14
+ delete 'unpin'
15
+ end
16
+ end
6
17
  end
7
18
 
8
19
  resources :topics do
data/lib/formol.rb CHANGED
@@ -3,6 +3,9 @@ require 'formol_'
3
3
 
4
4
  module Formol
5
5
  mattr_reader :config
6
+ mattr_reader :formatters
7
+
8
+ @@formatters = {}
6
9
 
7
10
  class << self
8
11
  def configure(&block)
@@ -29,7 +32,14 @@ module Formol
29
32
 
30
33
  # set formatter
31
34
  def set_formatter
32
- config.formatter = Formol::Formatters::Redcarpet::Formatter
35
+ unless formatters.has_key?(config.text_formatter)
36
+ raise <<STR
37
+ You have chosen an invalid text formatter (#{config.text_formatter}).
38
+ When setting a text_formatter, don't forget to add the corresponding gem to your Gemfile.
39
+ STR
40
+ end
41
+
42
+ config.formatter = formatters[config.text_formatter]
33
43
  end
34
44
 
35
45
  # load config.yml located inside main app
data/lib/formol/config.rb CHANGED
@@ -3,10 +3,15 @@ module Formol
3
3
  :current_user_helper_method,
4
4
  :formatter,
5
5
  :email_from,
6
- :text_formatter)
6
+ :text_formatter,
7
+ :default_avatar)
7
8
 
8
9
  def user
9
10
  @user ||= user_class.constantize
10
11
  end
12
+
13
+ def default_avatar
14
+ @default_avatar || 'formol/default_avatar.png'
15
+ end
11
16
  end
12
17
  end
@@ -18,4 +18,11 @@ Formol.configure do
18
18
  #
19
19
  # actually, only subscriptions send emails
20
20
  config.email_from = 'noreply@example.com'
21
+
22
+ # Formol relies on gravatar for avatars
23
+ # <%= user_class %> needs to respond to 'email' method for that
24
+ # Formol provides a default avatar but you could not like it
25
+ # If you wanna change it, uncomment the following line
26
+ # you can set a relative path as you used it in image_tag() or an absolute path
27
+ # config.default_avatar = 'formol/default_avatar.png'
21
28
  end
@@ -8,16 +8,12 @@ module Formol
8
8
  module SpecialRights
9
9
  # a user can edit a topic if he wrotes it
10
10
  def able_to_edit_topic?(topic)
11
- has_right?(:edit_topic) || (!topic.locked? && topic.user_id == user.id)
11
+ has_right?(:edit_topic) || topic.user_id == user.id
12
12
  end
13
13
 
14
14
  # a user can edit a post if he wrotes it
15
15
  def able_to_edit_post?(post)
16
- has_right?(:edit_post) || (!post.topic.locked? && post.user_id == user.id)
17
- end
18
-
19
- def able_to_create_post?(topic)
20
- has_right?(:create_post) && !topic.locked?
16
+ has_right?(:edit_post) || post.user_id == user.id
21
17
  end
22
18
  end
23
19
  end
@@ -2,7 +2,7 @@ module Formol
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 4
5
+ TINY = 5
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -6,6 +6,12 @@ module Formol
6
6
 
7
7
  javascript_include_tag path if path.start_with?('formol')
8
8
  end
9
+
10
+ def include_formol_stylesheets
11
+ path = controller.controller_path
12
+
13
+ stylesheet_link_tag path if path.start_with?('formol')
14
+ end
9
15
  end
10
16
  end
11
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-16 00:00:00.000000000Z
12
+ date: 2012-01-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: formtastic
16
- requirement: &85011220 !ruby/object:Gem::Requirement
16
+ requirement: &79556670 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *85011220
24
+ version_requirements: *79556670
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: attribute_normalizer
27
- requirement: &85010740 !ruby/object:Gem::Requirement
27
+ requirement: &79556380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *85010740
35
+ version_requirements: *79556380
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: will_paginate
38
- requirement: &85010170 !ruby/object:Gem::Requirement
38
+ requirement: &79555940 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *85010170
46
+ version_requirements: *79555940
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: ranked-model
49
- requirement: &85009840 !ruby/object:Gem::Requirement
49
+ requirement: &79555500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *85009840
57
+ version_requirements: *79555500
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: default_value_for
60
- requirement: &84457580 !ruby/object:Gem::Requirement
60
+ requirement: &79555040 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,29 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *84457580
69
- - !ruby/object:Gem::Dependency
70
- name: pygments.rb
71
- requirement: &84457100 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :runtime
78
- prerelease: false
79
- version_requirements: *84457100
80
- - !ruby/object:Gem::Dependency
81
- name: redcarpet
82
- requirement: &84456660 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :runtime
89
- prerelease: false
90
- version_requirements: *84456660
68
+ version_requirements: *79555040
91
69
  description: Formol is a forum engine for rails 3.1. It provides most of common features
92
70
  you can wait from a forum.
93
71
  email:
@@ -96,6 +74,7 @@ executables: []
96
74
  extensions: []
97
75
  extra_rdoc_files: []
98
76
  files:
77
+ - app/assets/images/formol/default_avatar.png
99
78
  - app/assets/images/formol/unread.png
100
79
  - app/assets/images/formol/read.png
101
80
  - app/assets/stylesheets/formol/topics.css.scss
@@ -310,8 +289,6 @@ files:
310
289
  - lib/formol/controllers/auth.rb
311
290
  - lib/formol/rails/engine.rb
312
291
  - lib/formol/view_helpers.rb
313
- - lib/formol/formatters/redcarpet/syntax_highlighter.rb
314
- - lib/formol/formatters/redcarpet/formatter.rb
315
292
  - lib/formol/version.rb
316
293
  - lib/formol/integration/user.rb
317
294
  - lib/formol/formatters.rb
@@ -1,36 +0,0 @@
1
- require 'redcarpet'
2
- require 'pygments.rb'
3
-
4
- module Formol
5
- module Formatters
6
- module Redcarpet
7
- class Formatter
8
- def initialize
9
- @renderer = SyntaxHighlighter.new(:hard_wrap => true,
10
- :filter_html => true)
11
- @processor = ::Redcarpet::Markdown.new(@renderer, :fenced_code_blocks => true,
12
- :no_intra_emphasis => true,
13
- :autolink => true,
14
- :space_after_headers => false,
15
- :superscript => false)
16
- end
17
-
18
- def to_html(text)
19
- @processor.render(text).html_safe
20
- end
21
-
22
- def quote(text)
23
- quoted_text = ""
24
-
25
- text.split("\n").each_with_index do |l|
26
- quoted_text << '> ' if (l.strip.blank? || l.start_with?('>'))
27
- quoted_text << l
28
- quoted_text << "\n"
29
- end
30
-
31
- quoted_text
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,23 +0,0 @@
1
- require 'redcarpet'
2
- require 'pygments.rb'
3
-
4
- module Formol
5
- module Formatters
6
- module Redcarpet
7
- class SyntaxHighlighter < ::Redcarpet::Render::XHTML
8
- def block_code(code, language)
9
- title_block(language) + Pygments.highlight(code, :lexer => language,
10
- :options => {
11
- :linenos => 'inline'
12
- })
13
- end
14
-
15
- private
16
-
17
- def title_block(language)
18
- %{<div class="highlight_title #{language.downcase}">#{language.downcase.capitalize}</div>}
19
- end
20
- end
21
- end
22
- end
23
- end