## Installation To use, add this line to your application's Gemfile: gem 'ood_appkit' And then execute: bundle install ## Usage ### Rake Tasks #### reset Running this rake task ```bash bin/rake ood_appkit:reset ``` will clear the Rails cache and update the timestamp on the `tmp/restart.txt` file that is used by Passenger to decide whether to restart the application. ### URL Handlers for System Apps #### Public URL This is the URL used to access publicly available assets provided by the OOD infrastructure, e.g., the `favicon.ico`. ```erb <%= favicon_link_tag nil, href: OodAppkit.public.url.join('favicon.ico') %> ``` Note: We used `nil` here as the source otherwise Rails will try to prepend the `RAILS_RELATIVE_URL_ROOT` to it. We explicitly define the link using `href:` instead. You can change the options using environment variables: ```bash OOD_PUBLIC_URL='/public' OOD_PUBLIC_TITLE='Public Assets' ``` Or by modifying the configuration in an initializer: ```ruby # config/initializers/ood_appkit.rb OodAppkit.configure do |config| # Defaults config.public = OodAppkit::PublicUrl.new title: 'Public Assets', base_url: '/public' end ``` #### Dashboard URL ```erb <%= link_to OodAppkit.dashboard.title, OodAppkit.dashboard.url.to_s %> ``` You can change the options using environment variables: ```bash OOD_DASHBOARD_URL='/pun/sys/dashboard' OOD_DASHBOARD_TITLE='Dashboard' ``` Or by modifying the configuration in an initializer: ```ruby # config/initializers/ood_appkit.rb OodAppkit.configure do |config| # Defaults config.dashboard = OodAppkit::DashboardUrl.new title: 'Dashboard', base_url: '/pun/sys/dashboard' end ``` #### Files App ```erb <%# Link to the Files app %> <%= link_to OodAppkit.files.title, OodAppkit.files.url.to_s %> <%# Link to open files app to specified directory %> <%= link_to "/path/to/file", OodAppkit.files.url(path: "/path/to/file").to_s %> <%= link_to "/path/to/file", OodAppkit.files.url(path: Pathname.new("/path/to/file")).to_s %> <%# Link to retrieve API info for given file %> <%= link_to "/path/to/file", OodAppkit.files.api(path: "/path/to/file").to_s %> ``` You can change the options using environment variables: ```bash OOD_FILES_URL='/pun/sys/files' OOD_FILES_TITLE='Files' ``` Or by modifying the configuration in an initializer: ```ruby # config/initializers/ood_appkit.rb OodAppkit.configure do |config| # Defaults config.files = OodAppkit::FilesUrl.new title: 'Files', base_url: '/pun/sys/files' end ``` #### Shell App ```erb <%# Link to the Shell app %> <%= link_to OodAppkit.shell.title, OodAppkit.shell.url.to_s %> <%# Link to launch Shell app for specified host %> <%= link_to "Ruby Shell", OodAppkit.shell.url(host: "ruby").to_s %> <%# Link to launch Shell app in specified directory %> <%= link_to "Shell in /path/to/dir", OodAppkit.shell.url(path: "/path/to/dir").to_s %> <%# Link to launch Shell app for specified host in directory %> <%= link_to "Ruby in /path/to/dir", OodAppkit.shell.url(host: "ruby", path: "/path/to/dir").to_s %> ``` You can change the options using environment variables: ```bash OOD_SHELL_URL='/pun/sys/shell' OOD_SHELL_TITLE='Shell' ``` Or by modifying the configuration in an initializer: ```ruby # config/initializers/ood_appkit.rb OodAppkit.configure do |config| # Defaults config.shell = OodAppkit::ShellUrl.new title: 'Shell', base_url: '/pun/sys/shell' end ``` ### Rack Middleware for handling Files under Dataroot This mounts all the files under the `OodAppkit.dataroot` using the following route by default: ```ruby # config/routes.rb mount OodAppkit::FilesRackApp.new => '/files', as: :files ``` To disable this generated route: ```ruby # config/initializers/ood_appkit.rb OodAppkit.configure do |config| config.routes.files_rack_app = false end ``` To add a new route: ```ruby # config/routes.rb # rename URI from '/files' to '/dataroot' mount OodAppkit::FilesRackApp.new => '/dataroot', as: :files # create new route with root set to '/tmp' on filesystem mount OodAppkit::FilesRackApp.new(root: '/tmp') => '/tmp', as: :tmp ``` ### Wiki Static Page Engine This gem comes with a wiki static page engine. It uses the supplied markdown handler to display GitHub style wiki pages. By default the route is generated for you: ```ruby # config/routes.rb get 'wiki/*page' => 'ood_appkit/wiki#show', as: :wiki, content_path: 'wiki' ``` and can be accessed within your app by ```erb <%= link_to "Documentation", wiki_path('Home') %> ``` To disable this generated route: ```ruby # config/initializers/ood_appkit.rb OodAppkit.configure do |config| config.routes.wiki = false end ``` To change (disable route first) or add a new route: ```ruby # config/routes.rb # can modify URI as well as file system content path where files reside get 'tutorial/*page' => 'ood_appkit/wiki#show', as: :tutorial, content_path: '/path/to/my_tutorial' # can use your own controller get 'wiki/*page' => 'my_wiki#show', as: :wiki, content_path: 'wiki' ``` You can use your own controller by including the appropriate concern: ```ruby # app/controllers/my_wiki_controller.rb class MyWikiController < ApplicationController include OodAppkit::WikiPage layout :layout_for_page private def layout_for_page 'wiki_layout' end end ``` And add a show view for this controller: ```erb <%# app/views/my_wiki/show.html.erb %>