Giter Site home page Giter Site logo

hanami-2-application-template's Introduction

Hanami 🌸

The web, with simplicity.

Version

This branch contains the code for hanami 2.0.x.

Frameworks

Hanami is a full-stack Ruby web framework. It's made up of smaller, single-purpose libraries.

This repository is for the full-stack framework, which provides the glue that ties all the parts together:

These components are designed to be used independently or together in a Hanami application.

Status

Gem Version CI Depfu

Installation

Hanami supports Ruby (MRI) 3.0+

gem install hanami

Usage

hanami new bookshelf
cd bookshelf && bundle
bundle exec hanami server # visit http://localhost:2300

Please follow along with the Getting Started guide.

Donations

You can give back to Open Source, by supporting Hanami development via GitHub Sponsors.

Supporters

Contact

Community

We strive for an inclusive and helpful community. We have a Code of Conduct to handle controversial cases. In general, we expect you to be nice with other people. Our hope is for a great software and a great Community.

Contributing Open Source Helpers

  1. Fork it ( https://github.com/hanami/hanami/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

In addition to contributing code, you can help to triage issues. This can include reproducing bug reports, or asking for vital information such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to subscribe to hanami on CodeTriage.

Tests

To run all test suite:

$ bundle exec rake

To run all the unit tests:

$ bundle exec rspec spec/unit

To run all the integration tests:

$ bundle exec rspec spec/integration

To run a single test:

$ bundle exec rspec path/to/spec.rb

Development Requirements

  • Ruby >= 3.0
  • Bundler
  • Node.js (MacOS)

Versioning

Hanami uses Semantic Versioning 2.0.0

Copyright

Copyright © 2014 Hanami Team – Released under MIT License.

hanami-2-application-template's People

Contributors

afrojun avatar choallin avatar cllns avatar copiousfreetime avatar dependabot[bot] avatar dsisnero avatar evhan avatar francois avatar iachettifederico avatar ianks avatar jodosha avatar katafrakt avatar parndt avatar pvcarrera avatar rbngzlv avatar solnic avatar swilgosz avatar timriley avatar waiting-for-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hanami-2-application-template's Issues

Things required to deploy to Heroku

Recently I have deployed an app from the template to Heroku and I needed to tweak a few things. Listing them here, so we can discuss which of them should make it to the code (I will be happy to prepare PRs, once we decide) - or at least be a checklist for someone else facing similar problems.

  1. Commit Gemfile.lock and yarn.lock currently the are in .gitignore and Heroku does not allow that (I see now it's partly addressed by b38df3a)
  2. Serve assets from /public

Currently there's this in config.ru:

use Rack::Static,
  urls: ["/assets"],
  root: ".assets/tmp",
  header_rules: [
    ["/assets", {"Cache-Control" => "public, max-age=31536000"}]
  ]

I had to change to root to root: ENV['PRECOMPILED_ASSETS'] == 'true' ? "public" : ".assets/tmp", so it serves precompiled assets from /public. I'm not really sure what's the deal with .assets directory though, so there might be other solution for this.

  1. Disconnect Sequel databases in Puma before_fork (Sequel::DATABASES.each(&:disconnect)) - I'm not sure here if it's something Hanami.shutdown should do, but for now manual disconnect is required.

No asset served

I have added tailwindcss to my project and imported the tailwind files.
The genereated assets files are looking good but unfortunatly I can't load them because I get a 404 error for either the css and the js file.

I changed the port for the asset server to 7070 in the setting :assets_server_url and in the package.json. The manifest is looking good too but the server is not there. Did I miss something?

Problem with installation instructions

This is a very minor thing, but perhaps worth fixing. The README says that one should run ./bin/install name_of_your_app to get the template running. However, what actually happens is a bunch of errors:

./bin/install: line 1: require: command not found
./bin/install: line 2: require: command not found
./bin/install: line 3: require: command not found
./bin/install: line 4: require: command not found
./bin/install: line 5: require: command not found
./bin/install: line 7: class: command not found
./bin/install: line 180: warning: here-document at line 8 delimited by end-of-file (wanted `self')
./bin/install: line 8: class: command not found

It seems that either the install script should contain a shebang for Ruby or it should be run via ruby /bin/install name_of_your_app (both work).

Show action cannot load `main/action'

Overview

In the slices/main/lib/main/actions/home/show.rb there is

require "main/action"

But this causes the project to crash probably due to container auto_registration path misconfiguration

Log output

[17621] ! Unable to load application: LoadError: cannot load such file -- main/action
Traceback (most recent call last):
        56: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bin/ruby_executable_hooks:24:in `<main>'
        55: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bin/ruby_executable_hooks:24:in `eval'
        54: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bin/puma:23:in `<main>'
        53: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bin/puma:23:in `load'
        52: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/puma-4.3.7/bin/puma:10:in `<top (required)>'
        51: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/puma-4.3.7/lib/puma/cli.rb:80:in `run'
        50: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/puma-4.3.7/lib/puma/launcher.rb:172:in `run'
        49: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/puma-4.3.7/lib/puma/cluster.rb:413:in `run'
        48: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/puma-4.3.7/lib/puma/runner.rb:155:in `load_and_bind'
        47: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/puma-4.3.7/lib/puma/configuration.rb:246:in `app'
        46: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/puma-4.3.7/lib/puma/configuration.rb:321:in `load_rackup'
        45: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
        44: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
        43: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
        42: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
        41: from config.ru:14:in `block in <main>'
        40: from config.ru:14:in `require'
        39: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami/boot.rb:5:in `<top (required)>'
        38: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami.rb:72:in `boot'
        37: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami.rb:72:in `new'
        36: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami/application.rb:345:in `initialize'
        35: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami/application.rb:345:in `new'
        34: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami/application/router.rb:16:in `initialize'
        33: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/router-7d70f09f9c25/lib/hanami/router.rb:86:in `initialize'
        32: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/router-7d70f09f9c25/lib/hanami/router.rb:86:in `instance_eval'
        31: from /Users/sebastian/Projects/Driggl/hanami-sandbox/config/routes.rb:4:in `block in <top (required)>'
        30: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami/application/router.rb:47:in `slice'
        29: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami/application/router.rb:37:in `scope'
        28: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami/application/routing/middleware/stack.rb:41:in `with'
        27: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami/application/router.rb:38:in `block in scope'
        26: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/router-7d70f09f9c25/lib/hanami/router.rb:389:in `scope'
        25: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/router-7d70f09f9c25/lib/hanami/router.rb:389:in `instance_eval'
        24: from /Users/sebastian/Projects/Driggl/hanami-sandbox/config/routes.rb:5:in `block (2 levels) in <top (required)>'
        23: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/router-7d70f09f9c25/lib/hanami/router.rb:148:in `root'
        22: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/router-7d70f09f9c25/lib/hanami/router.rb:199:in `get'
        21: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/router-7d70f09f9c25/lib/hanami/router.rb:749:in `add_route'
        20: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/router-7d70f09f9c25/lib/hanami/router.rb:774:in `resolve_endpoint'
        19: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami/application/routing/resolver.rb:35:in `call'
        18: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami/application/routing/resolver.rb:77:in `resolve_string_identifier'
        17: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/bundler/gems/hanami-a62803f36c89/lib/hanami/slice.rb:88:in `[]'
        16: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-container-0.7.2/lib/dry/container/mixin.rb:134:in `[]'
        15: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-system-0.19.0/lib/dry/system/container.rb:486:in `resolve'
        14: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-container-0.7.2/lib/dry/container/mixin.rb:121:in `resolve'
        13: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-container-0.7.2/lib/dry/container/resolver.rb:33:in `call'
        12: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-container-0.7.2/lib/dry/container/item/callable.rb:15:in `call'
        11: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-system-0.19.0/lib/dry/system/auto_registrar.rb:35:in `block (2 levels) in call'
        10: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-system-0.19.0/lib/dry/system/component.rb:73:in `instance'
         9: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-system-0.19.0/lib/dry/system/loader.rb:45:in `call'
         8: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-system-0.19.0/lib/dry/system/loader/autoloading.rb:19:in `require!'
         7: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-system-0.19.0/lib/dry/system/loader.rb:65:in `constant'
         6: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-inflector-0.2.0/lib/dry/inflector.rb:90:in `constantize'
         5: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/dry-inflector-0.2.0/lib/dry/inflector.rb:90:in `const_get'
         4: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
         3: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
         2: from /Users/sebastian/Projects/Driggl/hanami-sandbox/slices/main/lib/main/actions/home/show.rb:3:in `<top (required)>'
         1: from /Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
/Users/sebastian/.rvm/gems/ruby-2.7.2@sandboxapp/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require': cannot load such file -- main/action (LoadError)

Can't run setup/server because AppName::Routes doesn't exist

Aftere cloning this repo I run the bin/install command and everything worked fine.

Now, when I want to run the script/setup or the script/server scripts I get this error:

/.asdf/installs/ruby/3.0.1/lib/ruby/gems/3.0.0/gems/dry-inflector-0.2.1/lib/dry/inflector.rb:89:in `const_get': uninitialized constant CourtManager::Routes (NameError)

asset paths not working

I needed to change my asset paths in layouts/application.html.slim from assets["main__public.css"] to assets["main/public.css"] and similarly for public.js

This is my npm stdout, without changing any configs:

$ npm start

> [email protected] start
> PORT=8080 concurrently "TS_NODE_PROJECT=.assets/tsconfig.webpack.json ts-node .assets/scripts/build development" "serve -C .assets/tmp" --kill-others --prefix-colors=yellow.dim,cyan.dim

[1] INFO: Accepting connections at http://localhost:8080
[0] asset main/public.js 724 KiB [emitted] (name: main/public) 1 related asset
[0] asset main/public.css 229 KiB [emitted] (name: main/public) 1 related asset
[0] asset manifest.json 280 bytes [emitted]

undefined method `content_for' when app name contains a digit (?)

Steps to reproduce:

  1. Clone this repo
  2. bin/install hanami_2_test
  3. script/setup docker (but happens on local setup too)
  4. Go to localhost:3000

Result:

Puma caught this error: undefined method `content_for' for #<Hanami::View::Scope _name=nil _locals={} _render_env=#<Hanami::View::RenderEnvironment renderer=#<Hanami::View::Renderer paths=[#<Hanami::View::Path dir=#<Pathname:/app/slices/main/web/templates/layouts/application> root=#<Pathname:/app/slices/main/web/templates>>] format=:html engine_mapping={} options={:default_encoding=>"utf-8"}> inflector=#<Dry::Inflector> context=#<Hanami::View::Context _options={}> scope_builder=#<Hanami::View::ScopeBuilder namespace=nil> part_builder=#<Hanami::View::PartBuilder namespace=Main::View::Parts>>> (NoMethodError)
/usr/local/bundle/gems/hanami-view-2.0.0.alpha2/lib/hanami/view/scope.rb:160:in `method_missing'
/app/slices/main/web/templates/layouts/application.html.slim:6:in `__tilt_7340'
/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `call'
/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:170:in `evaluate'
/usr/local/bundle/gems/tilt-2.0.10/lib/tilt/template.rb:109:in `render'
/usr/local/bundle/gems/hanami-view-2.0.0.alpha2/lib/hanami/view/renderer.rb:49:in `render'
/usr/local/bundle/gems/hanami-view-2.0.0.alpha2/lib/hanami/view/renderer.rb:32:in `template'
/usr/local/bundle/gems/hanami-view-2.0.0.alpha2/lib/hanami/view/render_environment.rb:44:in `template'
/usr/local/bundle/gems/hanami-view-2.0.0.alpha2/lib/hanami/view/standalone_view.rb:354:in `call'
/usr/local/bundle/gems/hanami-controller-2.0.0.alpha2/lib/hanami/action/response.rb:79:in `render'
/usr/local/bundle/gems/hanami-controller-2.0.0.alpha2/lib/hanami/action/application_action.rb:90:in `handle'
/usr/local/bundle/gems/hanami-controller-2.0.0.alpha2/lib/hanami/action/standalone_action.rb:310:in `block in call'
/usr/local/bundle/gems/hanami-controller-2.0.0.alpha2/lib/hanami/action/standalone_action.rb:296:in `catch'
/usr/local/bundle/gems/hanami-controller-2.0.0.alpha2/lib/hanami/action/standalone_action.rb:296:in `call'
/usr/local/bundle/gems/hanami-router-2.0.0.alpha5/lib/hanami/router.rb:104:in `call'
/usr/local/bundle/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:266:in `context'
/usr/local/bundle/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:260:in `call'
/usr/local/bundle/gems/dry-monitor-0.4.0/lib/dry/monitor/rack/middleware.rb:37:in `block in call'
/usr/local/bundle/gems/dry-monitor-0.4.0/lib/dry/monitor/notifications.rb:11:in `measure'
/usr/local/bundle/gems/dry-monitor-0.4.0/lib/dry/monitor/rack/middleware.rb:37:in `call'
/usr/local/bundle/gems/hanami-2.0.0.alpha2/lib/hanami/application.rb:362:in `call'
/usr/local/bundle/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
/usr/local/bundle/gems/rack-2.2.3/lib/rack/static.rb:161:in `call'
/usr/local/bundle/gems/puma-4.3.7/lib/puma/configuration.rb:228:in `call'
/usr/local/bundle/gems/puma-4.3.7/lib/puma/server.rb:713:in `handle_request'
/usr/local/bundle/gems/puma-4.3.7/lib/puma/server.rb:472:in `process_client'
/usr/local/bundle/gems/puma-4.3.7/lib/puma/server.rb:328:in `block in run'
/usr/local/bundle/gems/puma-4.3.7/lib/puma/thread_pool.rb:134:in `block in spawn_thread'

Now, this was bugging me since yesterday until I discovered that if I'm renaming the app to a name without 2 (i.e. bin/install hanami_test) - it works! Is it just some super weird edge case or an actual bug?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.