Giter Site home page Giter Site logo

dkln / markitup-rails Goto Github PK

View Code? Open in Web Editor NEW

This project forked from niedfelj/markitup-rails

0.0 2.0 0.0 252 KB

The markItUp! universal markup editor, bundled for Rails 3.1+ Asset Pipeline.

License: MIT License

Ruby 17.74% JavaScript 51.01% CSS 28.66% HTML 2.59%

markitup-rails's Introduction

markitup-rails

Description

The markItUp! universal markup editor, bundled for Rails 3.1+ Asset Pipeline.

markItUp! is a JavaScript plug-in built on the jQuery library. It allows you to turn any textarea into a markup editor. HTML, Textile, Wiki Syntax, Markdown, BBcode or even your own Markup system can be easily implemented.

markitup-rails ships with several markup "sets" and editor "skins" including:

Markup Sets

  • bbcode
  • css
  • default
  • dotclear
  • html
  • markdown
  • markmin
  • rest
  • textile
  • texy
  • txt2tags
  • wiki
  • xbbcode

Editor Skins

  • markitup
  • simple

Requirements

This gem requires Rails 3.1+ and has been tested on the following versions:

  • 3.1
  • 3.2

This gem requires Ruby 1.9+ and has been tested against the following Ruby versions:

  • 1.9.2
  • 1.9.3
  • JRuby
  • Rubinius

Installation

Add this line to your application's Gemfile:

gem "markitup-rails"

And then execute:

$ bundle

Or install it yourself as:

$ gem install markitup-rails

Configuration

The Markitup::Rails module accepts a configure block with options to customize the engine behavior.

Place any custom configuration in a file such as config/initializers/markitup_rails.rb.

Layout

Set the layout option to customize the layout used by the AJAX live preview:

Markitup::Rails.configure do |config|
  config.layout = "other"  # default is `markitup`
end

You may also override the default locally by creating a new layout file at app/views/layouts/markitup.html.erb.

Formatter

Set the formatter option to customize the renderer for the preview. This can be any object that responds to call and which takes a single argument with the markup to render:

Markitup::Rails.configure do |config|
  config.formatter = -> markup { BBCodeParser.parse(markup) }
end

Route

markitup-rails provides a URL endpoint that be mounted to support a live server-side preview of markItUp! content.

To enable, mount the engine in your config/routes.rb file:

mount Markitup::Rails::Engine, at: "markitup", as: "markitup"

This will create a URL helper for markitup.preview_url which will route to /markitup/preview.

The preview URL will render the editor content using the config.formatter and display the content within the config.layout.

Usage

For Rails 3.1 and greater, the files will be added to the asset pipeline and available for you to use.

To enable the markItUp! editor in your application, you will need to include the appropriate JavaScript and Stylesheet files for the Set and Skin you wish to use.

Example:

  • Add the following line to the file app/assets/javascripts/application.js (or other sprockets manifest):
//= require markitup
//= require markitup/sets/xbbcode/set
  • Add the following line to the file app/assets/stylesheets/application.css:
*= require markitup/skins/markitup/style
*= require markitup/sets/xbbcode/style

You may also include the styles in your SCSS file directly:

@import "markitup/skins/markitup/style";
@import "markitup/sets/xbbcode/style";

Using markItUp!

Example:

jQuery ->

  # Target all text areas
  $("textarea").markItUp mySettings

  # Target a specific ID
  $("#my_id").markItUp mySettings

  # Target a specific class
  $("textarea.markitup").markItUp mySettings

See the markItUp! documentation for more information.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a Pull Request

Contributors

Many thanks go to the following who have contributed to making this gem even better:

  • @uri
    • initial version
  • @phlipper
    • complete rewrite as an engine for Rails 3.1+
    • add AJAX live preview support
    • add support for Sets and Skins, add many defaults to choose from
  • @ilja
    • update markitup to version 1.1.14
  • @zinenko
    • fix invalid images url in simple skin
  • @tamaloa
    • added default /markitup/preview path to all default settings
  • @tgjones
    • allow multiple settings objects to be used within a single page

License

markitup-rails

markItUp!

markItUp! is released under both the MIT and GPL Open Source licenses. In short, this means that markItUp! is totally Free, and you can do whatever you want with it. You are only obligated to keep the credits in place.

markitup-rails's People

Contributors

ilja avatar niedfelj avatar phlipper avatar tamaloa avatar uri avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.