Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

WatersOfOblivion-wikipodia

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

WatersOfOblivion-wikipodia

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

=Wikipodia

Wikipodia is a DSL for defining wikis within a Controller. It contains a small preprocessor which recognizes links within text and converts them to user defined formats. It allows a way to define these formats and a way in which to display content being linked to.

==A Simple Example

For example, a simple wiki which just has pages processed with RedCloth:

class FooController < ActionController::Base wikipodia do # Define a link to another page section :page do # Define what to do when one of the links is clicked action do @page = Page.find(params[:id]) render :text => RedCloth.new(handle_wiki_links(@page.content)).to_html end

    # Define how to transform the link
    url do |id, text|
      "\"#{text}\":#{page_path(id)}"
    end
  end
end

end

Anywhere in @page.content, links of the format [[page:some-id Some Text]] will be converted into RedCloth links of the format "Some Text":/page/some-id.

==A More Complex Example

A more complete wiki might support not only pages, but images and file downloads:

class MiniWikiController < ActionController::Base wikipodia do section :page do action do @page = Page.find(params[:id]) render :text => RedCloth.new(handle_wiki_links(@page.content)).to_html end

    url do |id, text|
      "\"#{text}\":#{page_path(id)}"
    end
  end

  section :image do
    action do
      @image = Image.find(params[:id])
      send_data @image.content
    end

    url do |id, text|
      "!#{image_path(id)}!"
    end
  end

  section :document do
    action do
      @document = Documents.find(params[:id])
      send_data @document.content, :filename => @document.original_filename, :type => @document.content_type
    end

    url do |id, text|
      "\"#{text}\":#{document_path(id)}"
    end
  end
end

end

==Gem

This plugin is available as a Gem. To use it, simply add the following line to your config/environment.rb and run rake gems:install:

config.gem "WatersOfOblivion-wikipodia", :lib => "wikipodia", :source => "http://gems.github.com/"

Copyright (c) 2009 Jonathan Bryant, released under the MIT license

FAQs

Package last updated on 11 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc