github.com/maiha/active-scaffold.cr

ActiveScaffold for Amber on Crystal

2 stars
0 dependents
License: MIT

Nothing has been indexed for 0.3.1 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  active_scaffold:
    github: maiha/active-scaffold.cr
    version: ~> 0.3.1

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.3.1. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

active_scaffold.cr Build Status

ActiveScaffold for Amber on Crystal.

  • amber-0.6.7
  • granite-orm (maiha fork)
  • crystal-0.24.1

Installation

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

Usage

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

Global settings

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

Debug

  • add ?debug parameter to the url, or
  active_scaffold do |config|
    config.debug = true

API

Install

Currently, there are no full generators. So please setup files manually as follows.

once for an application

  • 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
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

each controllers

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

TODO

  • data
    • [x] ActiveScaffold::Data::Action(T)
    • [x] ActiveScaffold::Data::Actions(T)
    • [x] ActiveScaffold::Data::ActionLink(T)
    • [x] ActiveScaffold::Data::ActionLinks(T)
    • [x] ActiveScaffold::Data::Column(T)
    • [x] ActiveScaffold::Data::Columns(T)
  • config
    • [x] ActiveScaffold::Configure(T)
    • [x] ActiveScaffold::Config::Base(T)
    • [x] ActiveScaffold::Config::Core(T)
    • [x] ActiveScaffold::Config::Edit(T)
    • [x] ActiveScaffold::Config::List(T)
    • [ ] ActiveScaffold::Config::Search(T)
    • [x] ActiveScaffold::Config::Show(T)
  • actions
    • [x] ActiveScaffold::Actions::Create(T)
    • [x] ActiveScaffold::Actions::Delete(T)
    • [x] ActiveScaffold::Actions::Edit(T)
    • [x] ActiveScaffold::Actions::List(T)
    • [x] ActiveScaffold::Actions::New(T)
    • [x] ActiveScaffold::Actions::Show(T)
    • [x] ActiveScaffold::Actions::Update(T)
  • features
    • [x] debug
    • [x] pagination
    • [x] sorting
    • [x] global settings
    • [ ] ajax
    • [ ] search
    • [ ] in place editor
    • [ ] assosications
    • [ ] nested
    • [ ] generators
    • [ ] auths and roles
    • [ ] localizations

Development

crystal spec -v

Contributing

  1. Fork it ( https://github.com/maiha/active_scaffold.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • maiha maiha - creator, maintainer