ActiveScaffold for Amber on Crystal.
- amber-0.6.7
- granite-orm (maiha fork)
- crystal-0.24.1
Add this to your amber application's shard.yml
:
dependencies:
active_scaffold:
github: maiha/active_scaffold.cr
version: 0.3.7
granite_orm:
#github: amberframework/granite-orm
github: maiha/granite-orm
branch: master
require "active_scaffold"
class UsersController < ApplicationController
include ActiveScaffold(User)
active_scaffold do |config|
# config.id = "code" # primary key (default: "id")
config.columns = ["first_name", "last_name"]
config.actions = ["list", "show"]
config.action_links["show"].label = "View"
config.list.paging.order = "id DESC"
config.list.paging.limit = 15
config.list.paging.window = 5
# config.list.paging.count = false # disable `SELECT COUNT`
config.show.label = "user(%s)"
end
end
You can put global settings in ActiveScaffold::Default
that sets default values to all controllers.
ActiveScaffold::Default::List::PAGING = {limit: 5}
All configurable parameters are in ActiveScaffold::Default
.
See https://github.com/maiha/active-scaffold.cr/wiki/API:-Global-settings
- add
?debug
parameter to the url, or
active_scaffold do |config|
config.debug = true
- config : ActiveScaffold::Config::Core
- config.columns : ActiveScaffold::Data::Columns
- config.column : ActiveScaffold::Data::Column
- config.action_links : ActiveScaffold::Data::ActionLinks
- config.action_link : ActiveScaffold::Data::ActionLink
- config.list : ActiveScaffold::Config::List
- config.list.paging : ActiveScaffold::Data::Paging
- config.show : ActiveScaffold::Config::Show
- config.edit : ActiveScaffold::Config::Edit
- config.update : ActiveScaffold::Config::Update
Currently, there are no full generators. So please setup files manually as follows.
public/dist/active_scaffold.css
->../../lib/active_scaffold/src/active_scaffold/assets/stylesheets/active_scaffold.css
(cd public/dist && ln -s ../../lib/active_scaffold/src/active_scaffold/assets/stylesheets/active_scaffold.css)
src/views/layouts/application.slang
- add css to the end of
head
part - add js to the end of
body
part
- add css to the end of
link rel="stylesheet" href="/dist/active_scaffold.css"
script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"
Put into shard.yml
.
targets:
active_scaffold:
main: lib/active_scaffold/bin/gen.cr
Then, build it.
shards build
For example, please run following command for UsersController
and User
model.
./bin/active_scaffold users
This writes following files if missing.
config/routes.cr
src/models/user.cr
src/controllers/users_controller.cr
src/views/users
->../../lib/active_scaffold/src/active_scaffold/views
- data
-
ActiveScaffold::Data::Action(T)
-
ActiveScaffold::Data::Actions(T)
-
ActiveScaffold::Data::ActionLink(T)
-
ActiveScaffold::Data::ActionLinks(T)
-
ActiveScaffold::Data::Column(T)
-
ActiveScaffold::Data::Columns(T)
-
- config
-
ActiveScaffold::Configure(T)
-
ActiveScaffold::Config::Base(T)
-
ActiveScaffold::Config::Core(T)
-
ActiveScaffold::Config::Edit(T)
-
ActiveScaffold::Config::List(T)
-
ActiveScaffold::Config::Search(T)
-
ActiveScaffold::Config::Show(T)
-
- actions
-
ActiveScaffold::Actions::Create(T)
-
ActiveScaffold::Actions::Delete(T)
-
ActiveScaffold::Actions::Edit(T)
-
ActiveScaffold::Actions::List(T)
-
ActiveScaffold::Actions::New(T)
-
ActiveScaffold::Actions::Show(T)
-
ActiveScaffold::Actions::Update(T)
-
- features
- debug
- pagination
- sorting
- global settings
- ajax
- search
- in place editor
- assosications
- nested
- generators
- auths and roles
- localizations
crystal spec -v
- Fork it ( https://github.com/maiha/active_scaffold.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- maiha maiha - creator, maintainer