allow embedded images in story text, but still not in comments
This commit is contained in:
parent
cb5e05c461
commit
b7e5447c1d
|
@ -251,7 +251,7 @@ class Story < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def generated_markeddown_description
|
def generated_markeddown_description
|
||||||
Markdowner.to_html(self.description)
|
Markdowner.to_html(self.description, allow_images = true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def description=(desc)
|
def description=(desc)
|
||||||
|
|
|
@ -27,5 +27,14 @@
|
||||||
text</pre></td>
|
text</pre></td>
|
||||||
<td>prefix text with at least <tt> 3 spaces</tt></td>
|
<td>prefix text with at least <tt> 3 spaces</tt></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<% if defined?(allow_images) && allow_images %>
|
||||||
|
<tr>
|
||||||
|
<td>(inline image)</td>
|
||||||
|
<td><tt>![alt text](http://example.com/image.jpg)</tt> (only allowed in
|
||||||
|
story text</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
|
|
||||||
<div style="clear: both;"></div>
|
<div style="clear: both;"></div>
|
||||||
|
|
||||||
<%= render :partial => "global/markdownhelp" %>
|
<%= render :partial => "global/markdownhelp",
|
||||||
|
:locals => { :allow_images => true } %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -85,7 +85,8 @@
|
||||||
|
|
||||||
<div style="clear: both;"></div>
|
<div style="clear: both;"></div>
|
||||||
|
|
||||||
<%= render :partial => "global/markdownhelp" %>
|
<%= render :partial => "global/markdownhelp",
|
||||||
|
:locals => { :allow_images => true } %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
class Markdowner
|
class Markdowner
|
||||||
def self.to_html(text)
|
def self.to_html(text, allow_images = false)
|
||||||
if text.blank?
|
if text.blank?
|
||||||
return ""
|
return ""
|
||||||
else
|
else
|
||||||
html = RDiscount.new(text.to_s, :smart, :autolink, :safelink,
|
html = RDiscount.new(text.to_s, *[ :smart, :autolink, :safelink,
|
||||||
:filter_styles, :filter_html, :no_image).to_html
|
:filter_styles, :filter_html ] + (allow_images ? [] : [ :no_image ])).
|
||||||
|
to_html
|
||||||
|
|
||||||
# change <h1> headings to just emphasis tags
|
# change <h1> headings to just emphasis tags
|
||||||
html.gsub!(/<(\/)?h(\d)>/) {|_| "<#{$1}strong>" }
|
html.gsub!(/<(\/)?h(\d)>/) {|_| "<#{$1}strong>" }
|
||||||
|
|
Loading…
Reference in a new issue