Skip to content

Display and edit some of your rails application file directly inside your browser

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
MIT-LICENSE
Notifications You must be signed in to change notification settings

timotheeguerin/rails_embed_editor

Repository files navigation

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'

About

Display and edit some of your rails application file directly inside your browser

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
MIT-LICENSE

Stars

Watchers

Forks

Packages

No packages published