No commit activity in last 3 years
No release in over 3 years
A tool that allow to display a embed editor on your page and edit local file(Views, Controller, ...). Details otw
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
>= 4.0.0, ~> 4.0
 Project Readme

rails_embed_editor

Build Status Coverage Status Code Climate

#Installation Install the gem

gem 'rails_embed_editor'

Include the assests

  <%= javascript_include_tag 'rails_embed_editor/application' if Rails.env.development? %>
  <%= stylesheet_link_tag 'rails_embed_editor/application' if Rails.env.development? %>

#Configure Generate the config file

rails g rails_embed_editor:config

Add authorization. In the config file

config.authorize_with :cancan #only cancan is supported for now

The user need the permission `:edit :local_file' to be edit a file.

#How it work Use the method helper to generate an editor

rails_embed_editor(somefile, options)

You can give the follwoing options:

  • first_line The first line to read
  • last_line The last line to read
  • line The line where the editor will be centered(To be used with radius)
  • radius The radius around the given line (To be used with line)
  • editormode Set what the editor can do. (Add RailsEmbedEditor::EditorMode:: in front)
  • READONLY The editor will only be able to show the content
  • READWRIE The editor will start in readonly mode but an option to enable editing is displayed
  • WRITE The editor start in edit mode
  • highlight Highlight some part of the code(String). It can have 3 difference format
  • line Will highlight the given line
  • line_start, line_end Will highlight the range of line given
  • line_start, col_start, line_end, cold_end Will highlight the given range with column start and end Example: (This will read 2 line around line 5 in the file welcome/how.html.erb)
<%= rails_embed_editor("#{Rails.root}/app/views/welcome/show.html.erb", :line => 5, :radius => 2, 
:highlight => '5'
:editormode => RailsEmbedEditor::EditorMode::READ_WRITE) %>

This is what the editor looks like capture

#Customization ##Change default theme The plugin is using ace_rails_ap gem. You can include any theme the gem has included.

First require

#= require ace/theme-themeIwant

#Example
#= require ace/theme-chaos

Then edit the global variable

window.rails_embed_editor_default_theme = 'themeIwant'

#Example
window.rails_embed_editor_default_theme = 'chaos'