Permalink
Browse files

Added support for SlideShare

  • Loading branch information...
0 parents commit 7d9812261ee9cedef5761897fd2e79a0c8a05c70 Dimitrij Denissenko committed Oct 18, 2009
Showing with 105 additions and 0 deletions.
  1. +25 −0 LICENSE
  2. +15 −0 ext/format_helper.rb
  3. +15 −0 ext_info.rb
  4. +10 −0 ext_settings.yml
  5. +30 −0 lib/wiki_engine/markup_extension.rb
  6. +10 −0 locales/settings/en-US.yml
@@ -0,0 +1,25 @@
+ Retrospectiva - http://www.retrospectiva.org
+ Copyright (C) 2006 Dimitrij Denissenko
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ Important notice:
+ Any parts literally taken over from i2[1] are also liable to
+ the MIT license.
@@ -0,0 +1,15 @@
+module FormatHelper
+
+ protected
+
+ def post_markup_with_markup_extensions(content)
+ returning post_markup_without_markup_extensions(content) do |output|
+ WikiEngine.markup_extensions.each do |extension|
+ next unless RetroCM[:content][:markup_extensions][extension.name]
+ extension.apply_to!(output)
+ end
+ end
+ end
+ alias_method_chain :post_markup, :markup_extensions
+
+end
@@ -0,0 +1,15 @@
+#--
+# Copyright (C) 2009 Dimitrij Denissenko
+# Please read LICENSE document for more information.
+#++
+require 'wiki_engine/markup_extension'
+
+module WikiEngine
+ mattr_accessor :markup_extensions
+ self.markup_extensions = []
+end
+
+WikiEngine::MarkupExtension.push 'slideshare', /\[slideshare (.+?)\]/ do |match|
+ match =~ /\[slideshare (.+?)\]/
+ %Q(<object><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?#{$1}" type="application/x-shockwave-flash" width="425" height="350" allowscriptaccess="always" allowfullscreen="true"></embed></object>)
+end
@@ -0,0 +1,10 @@
+---
+- !ruby/object:RetroCM::Section
+ name: 'content'
+ groups:
+ - !ruby/object:RetroCM::Group
+ name: 'markup_extensions'
+ settings:
+ - !ruby/object:RetroCM::BooleanSetting
+ name: 'slideshare'
+ default: false
@@ -0,0 +1,30 @@
+# coding:utf-8
+module WikiEngine
+ class MarkupExtension
+
+ class << self
+
+ def push(*args, &block)
+ WikiEngine.markup_extensions.push new(*args, &block)
+ end
+
+ end
+
+ attr_reader :name
+
+ def initialize(name, pattern, replacement = nil, &block)
+ @name = name.to_sym
+ @pattern = pattern
+ @replacement = block_given? ? block : replacement
+ end
+
+ def apply_to!(content)
+ if @replacement.is_a?(Proc)
+ content.gsub!(@pattern, &@replacement)
+ else
+ content.gsub!(@pattern, @replacement)
+ end
+ end
+
+ end
+end
@@ -0,0 +1,10 @@
+en-US:
+ settings:
+ content:
+ groups:
+ markup_extensions:
+ label: 'Markup extensions'
+ settings:
+ slideshare:
+ label: 'SlideShare'
+ description: Enable SlideShare extension.

0 comments on commit 7d98122

Please sign in to comment.