Class: RailsMarkup::Configuration
- Inherits:
-
Object
- Object
- RailsMarkup::Configuration
- Defined in:
- lib/rails_markup/configuration.rb
Constant Summary collapse
- ALLOWED_ACCENTS =
%w[indigo amber blue emerald rose].freeze
- ALLOWED_POSITIONS =
%w[tl tr br bl].freeze
- ALLOWED_SIZES =
%w[slim compact default].freeze
Instance Attribute Summary collapse
-
#api_token ⇒ Object
Bearer token for the external API (MCP production tools).
-
#author_name_method ⇒ Object
Method name (Symbol) or Proc to resolve the author's display name from the current_user.
-
#base_controller_class ⇒ Object
Base controller class name for dashboard/API controllers.
-
#dashboard_layout ⇒ Object
Layout for the dashboard views.
-
#enable_screenshots ⇒ Object
Enable element screenshot capture in the toolbar.
-
#fab_visible ⇒ Object
Show the floating action button (FAB) specifically.
-
#health_interval ⇒ Object
Health check poll interval in seconds.
-
#on_create_callback ⇒ Object
Proc called after an annotation is created.
-
#per_page ⇒ Object
Number of annotations per page on the dashboard.
-
#require_api_token_in_development ⇒ Object
In development the external API skips token auth by default so you can reach it from another device on your LAN (e.g. your phone).
-
#return_url ⇒ Object
URL path for "Back to app" link in the dashboard header.
-
#table_name ⇒ Object
Database table name for annotations.
-
#toolbar_accent ⇒ Object
Accent color for the toolbar FAB and UI elements.
-
#toolbar_enabled ⇒ Object
Render the annotation toolbar system at all (FAB, panel, pins, sync).
-
#toolbar_position ⇒ Object
FAB button position: "bl" (bottom-left), "br" (bottom-right), "tl" (top-left), "tr" (top-right).
-
#toolbar_size ⇒ Object
FAB button size: "default" (48px), "compact" (40px), "slim" (32px).
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #resolve_author_name(user) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/rails_markup/configuration.rb', line 84 def initialize @base_controller_class = "RailsMarkup::ApplicationController" @api_token = nil @require_api_token_in_development = false @table_name = "rails_markup_annotations" @per_page = 25 @toolbar_accent = "indigo" @toolbar_enabled = true @fab_visible = true @toolbar_position = "bl" @toolbar_size = "default" @return_url = nil @dashboard_layout = "rails_markup/application" @author_name_method = :email @on_create_callback = nil @enable_screenshots = true @health_interval = 60 end |
Instance Attribute Details
#api_token ⇒ Object
Bearer token for the external API (MCP production tools). Set to nil to disable external API.
16 17 18 |
# File 'lib/rails_markup/configuration.rb', line 16 def api_token @api_token end |
#author_name_method ⇒ Object
Method name (Symbol) or Proc to resolve the author's display name from the current_user. Symbol: calls user.public_send(method_name) — e.g. :name, :email, :display_name Proc: receives user, returns string — e.g. ->(u) { u.full_name } Default: :email
61 62 63 |
# File 'lib/rails_markup/configuration.rb', line 61 def @author_name_method end |
#base_controller_class ⇒ Object
Base controller class name for dashboard/API controllers. Set to a controller that provides authentication. Example: "AdminAuthController"
12 13 14 |
# File 'lib/rails_markup/configuration.rb', line 12 def base_controller_class @base_controller_class end |
#dashboard_layout ⇒ Object
Layout for the dashboard views. Set to a host app layout name to embed within that layout. Default: "rails_markup/application" (engine's own layout) Example: "admin"
52 53 54 |
# File 'lib/rails_markup/configuration.rb', line 52 def dashboard_layout @dashboard_layout end |
#enable_screenshots ⇒ Object
Enable element screenshot capture in the toolbar. Default: true
70 71 72 |
# File 'lib/rails_markup/configuration.rb', line 70 def enable_screenshots @enable_screenshots end |
#fab_visible ⇒ Object
Show the floating action button (FAB) specifically. When false, the FAB is hidden but the toolbar system stays active — pins still render and the panel is reachable via its toggle. Use when the host provides its own trigger or wants read-only pins. Requires toolbar_enabled. Default: true
41 42 43 |
# File 'lib/rails_markup/configuration.rb', line 41 def fab_visible @fab_visible end |
#health_interval ⇒ Object
Health check poll interval in seconds. Default: 60
82 83 84 |
# File 'lib/rails_markup/configuration.rb', line 82 def health_interval @health_interval end |
#on_create_callback ⇒ Object
Proc called after an annotation is created. Receives the annotation record. Use for email/Slack/webhook notifications. Default: nil (no callback)
66 67 68 |
# File 'lib/rails_markup/configuration.rb', line 66 def on_create_callback @on_create_callback end |
#per_page ⇒ Object
Number of annotations per page on the dashboard.
55 56 57 |
# File 'lib/rails_markup/configuration.rb', line 55 def per_page @per_page end |
#require_api_token_in_development ⇒ Object
In development the external API skips token auth by default so you can reach it from another device on your LAN (e.g. your phone). That allows unauthenticated reads AND writes from any network peer. Set to true to require the bearer token even in development. Default: false (open in development)
23 24 25 |
# File 'lib/rails_markup/configuration.rb', line 23 def require_api_token_in_development @require_api_token_in_development end |
#return_url ⇒ Object
URL path for "Back to app" link in the dashboard header. Set to nil to hide the link. Example: "/admin"
46 47 48 |
# File 'lib/rails_markup/configuration.rb', line 46 def return_url @return_url end |
#table_name ⇒ Object
Database table name for annotations.
26 27 28 |
# File 'lib/rails_markup/configuration.rb', line 26 def table_name @table_name end |
#toolbar_accent ⇒ Object
Accent color for the toolbar FAB and UI elements.
29 30 31 |
# File 'lib/rails_markup/configuration.rb', line 29 def @toolbar_accent end |
#toolbar_enabled ⇒ Object
Render the annotation toolbar system at all (FAB, panel, pins, sync). Set to false to disable rails-markup entirely for a request/environment. Default: true
34 35 36 |
# File 'lib/rails_markup/configuration.rb', line 34 def @toolbar_enabled end |
#toolbar_position ⇒ Object
FAB button position: "bl" (bottom-left), "br" (bottom-right), "tl" (top-left), "tr" (top-right). Default: "bl"
74 75 76 |
# File 'lib/rails_markup/configuration.rb', line 74 def @toolbar_position end |
#toolbar_size ⇒ Object
FAB button size: "default" (48px), "compact" (40px), "slim" (32px). Default: "default"
78 79 80 |
# File 'lib/rails_markup/configuration.rb', line 78 def @toolbar_size end |
Instance Method Details
#resolve_author_name(user) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/rails_markup/configuration.rb', line 103 def (user) return nil unless user case when Symbol then user.respond_to?() ? user.public_send() : nil when Proc then .call(user) end rescue => e Rails.logger.warn("[rails-markup] author_name_method error: #{e.}") if defined?(Rails) nil end |