class GitNoted::Application
Constants
- TRANSPARENT_1PX_PNG
Attributes
renderer[RW]
repository[RW]
Public Class Methods
default_renderer()
click to toggle source
# File lib/git_noted/application.rb, line 11 def self.default_renderer renderer = Redcarpet::Render::HTML.new({ escape_html: true, safe_links_only: true, }) redcarpet = Redcarpet::Markdown.new(renderer, { tables: true, no_intra_emphasis: true }) redcarpet.method(:render) end
new(repository:, renderer: Application.default_renderer)
click to toggle source
Calls superclass method
# File lib/git_noted/application.rb, line 51 def initialize(repository:, renderer: Application.default_renderer) super() @repository = repository @renderer = renderer end
with(allow_origins: [], **options)
click to toggle source
# File lib/git_noted/application.rb, line 23 def self.with(allow_origins: [], **options) Class.new(self) do alias_method :initialize_saved, :initialize define_method(:initialize) do initialize_saved(**options) end use Rack::Cors do allow do origins *allow_origins unless allow_origins.empty? resource '/api/*', { methods: [:get, :options, :head], headers: :any, expose: [], credentials: true, max_age: 600, } end allow do origins '*' resource '/public/*', :headers => :any, :methods => :get end end end end
Public Instance Methods
load_labels(params)
click to toggle source
# File lib/git_noted/application.rb, line 156 def load_labels(params) used_with_label_names = (params[:used_with] || '').split(',') prefix = params[:prefix] prefix = nil if prefix == '' @repository.search_labels(prefix: prefix, used_with: used_with_label_names) end
load_notes(params)
click to toggle source
# File lib/git_noted/application.rb, line 150 def load_notes(params) label_names = (params[:labels] || '').split(",") exclude_label_names = (params[:exclude_labels] || '').split(",") @repository.search_notes(labels: label_names, exclude_labels: exclude_label_names) end
read_note(note)
click to toggle source
# File lib/git_noted/application.rb, line 142 def read_note(note) @repository.read(note) end
render_note(note)
click to toggle source
# File lib/git_noted/application.rb, line 146 def render_note(note) @renderer.call(read_note(note)) end