Code Monkey home page Code Monkey logo

hanami.github.io'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.github.io's People

Contributors

alfonsouceda avatar apohllo avatar biow0lf avatar bounga avatar cllns avatar cveneziani avatar davydovanton avatar dependabot[bot] avatar erol avatar gizotti avatar graywolf avatar hackling avatar jc00ke avatar jikkujose avatar jodosha avatar marionschleifer avatar mbajur avatar mzeleniuk avatar oana-sipos avatar roryokane avatar siaw23-retired avatar smaximov avatar tak1n avatar timriley avatar tomkadwill avatar vlad-at-work avatar vladislav-yashin avatar vyper avatar weppos avatar y-yagi 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

Watchers

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

hanami.github.io's Issues

Broken links

I built a quick and dirty tool to check the broken links on our website.

This is the output:

Visiting http://hanamirb.org/guides/1.0/upgrade-notes/v060  Not Found
Visiting http://hanamirb.org/guides/1.0/upgrade-notes/v070  Not Found
Visiting http://hanamirb.org/guides/1.0/upgrade-notes/v080  Not Found
Visiting http://hanamirb.org/guides/1.0/upgrade-notes/v090  Not Found
Visiting http://hanamirb.org/guides/1.0/upgrade-notes/v100  Not Found
Visiting http://hanamirb.org/guides/head/validations/boolean-logic  Not Found
Visiting http://hanamirb.org/guides/head/validations/custom-predicates  Not Found
Visiting http://hanamirb.org/guides/head/validations/advanced-usage  Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v070  Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v100  Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v100beta1  Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v090  Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v080  Not Found
Visiting http://hanamirb.org/guides/upgrade-notes/v060  Not Found
Visiting http://hanamirb.org/guides/architectures/container  Not Found
Visiting http://hanamirb.org/guides/architectures/application  Not Found

Repository query page

We should add a new page with repository query examples.

TODO

  • joins;
  • groub by;
  • where with block (ILIKE, IN, etc);
  • order;
  • some SQL functions (type casting for example);
  • #exist?

If you want to see something special please, add comment with it

GS Guide: Hanami 1.2 test count is different

Right before the section in the GS guide called "Building Forms To Create Records", there's some test output shown:

9 runs, 16 assertions, 0 failures, 0 errors, 0 skips

This test output has changed in v1.2 to:

12 runs, 20 assertions, 0 failures, 0 errors, 0 skips

I guess there have been some new tests added in the interim?


I am submitting this as an issue and not a PR because I couldn't find a 1.2-specific getting started guide at the moment.

Incomplete guide share code of views

I wrote this code my application and I run the bundle exec hanami s
so I got message uninitialized constant Web .
I think Web is not initialized when accept_json.rb is loaded.

Below codes work well.

# apps/web/views/accept_json.rb
module Web
  module Views
    module AcceptJson
      def self.included(view)
        view.class_eval do
          format :json
        end
      end
    end
  end
end

or

# apps/web/application.rb
module Web
  class Application < Hanami::Application
    configure do
      # ...
      view.prepare do
        require_relative './views/accept_json'
        include Web::Views::AcceptJson
      end
    end
  end
end

Make better navigation menu for mobile site

Hi folks:

I open this issue because when you navigate the guides from a mobile it's a little irritating when you click a link and then you have to scroll down again.

You can see a screenshot to see what is the first thing you see when enter in the guides:

fireshot capture 6 - hanami i guides - getting started - http___hanamirb org_guides_getting-started_

I think we could have a select instead the list, what do you think?

Inconsistency in Getting Started – “there isn't an else condition”, but there is

The Getting Started guide has a confusing inconsistency here:

With our validations in place, we can limit our entity creation and redirection to cases where the incoming params are valid:

# apps/web/controllers/books/create.rb
module Web::Controllers::Books
  class Create
    include Web::Action

    expose :book

    params do
      required(:book).schema do
        required(:title).filled(:str?)
        required(:author).filled(:str?)
      end
    end

    def call(params)
      if params.valid?
        @book = BookRepository.create(Book.new(params[:book]))

        redirect_to '/books'
      else
        self.status = 422
      end
    end
  end
end

You may have noticed that there isn't an else condition to that if statement.
What happens when params aren't valid?

The paragraph after the code says that there isn’t an else condition, but there is one – it says self.status = 422. There is no other nearby code block that the paragraph could be referring to.

When I look at the history of getting-started.md, I see that commit 4f5f071 “Guides: explain the differences between #halt and #status=” created this inconsistency. That commit mainly edited the HTTP Status section of the Action Control Flow page, but edited two code blocks in Getting Started too. The else condition was added without the following paragraph being updated.

I don’t know enough to suggest whether the else condition should be removed or the paragraph after the code should be revised.

Various issues with 'Getting started' guide

I've been going through the guide and I've hit several places where it seems to be out of date or otherwise wrong.

  • hanami new bookshelf --database=postgres will generate a project which uses minitest, not rspec, but all the code examples use rspec
  • the rspec examples use the old foo.should.match bar syntax, which nowadays is not recommended. Some of the test examples just don't run at all (those that use must_equal and co; there is also one random assert, which of course also fails in an rspec context)

I can try to fix some of these issues, although I would need some guidance as to whether to change the test examples to minitest (since that is the out-of-the-box default), or change them to expect syntax, or whatever.

[Post v1.1] Interactor guide

In the v1.1, we'll change the good practices for interactors:

  • no more params in initializers (well, in fact, you can actually do what you want in initializer, but it's best if you keep it for dependency injections)
  • params go through #call
  • #call can now take anything as parameters, except no parameters (so the minimum declaration is def call(*); end and not def call; end

Old format (̀#call without parameters) will still be working (I guess we'll deprecate it in v1.2?)

Use common style for Command line commands

Examples:
Without bundle exec
hanami generate action web dashboard#index
http://hanamirb.org/guides/actions/overview/

With and without lead percent
http://hanamirb.org/guides/projects/rake/

I suppose bundle exec is excess. With rbenv and one version of hanami it works properly without bundle exec. OhMyZsh with some simple settings adds bundle exec to rake commands automatically.

Perhaps these guides are not responsible with bundler and it needs to be moved to Command Line section.

Getting Started - Remove Postgres in favor of SQLite

hanami new bookshelf --database=postgres

should just be

hanami new bookshelf

We don't use any advanced features of Postgres, and it makes the Getting Started guide more complicated. Some users may have to spend time installing Postgres (which can be a pain!) or dealing with authentication issues... all just to learn the basics of Hanami!

I think we should include a note telling users that we're using SQLite and that in a production app they should use Postgres or some other production-ready database (and show them it's easy to use postgres instead: hanami new bookshelf --database=postgres)

Separate guides into respective repos

Hi there,

I have an idea for restructuring the guides into their own respective repos.

For example, rather than having the assets guides in this repo (hanami/hanami.github.io) at source/guides/assets/, we could put the guides inside the hanami/assets repo, at guides/

Then the build tool here could just clone each of the repos and build the site based on that. Travis could listen to each repo for commits and rebuild the site for every one, to ensure it's up-to-date.

Here's the current sources/guides folder, and where they'd be relocated to (/guides in each repo unless specified):

actions/              => hanami/controller
architectures/        => hanami/hanami (guides/architectures)
command-line/         => hanami/hanami (guides/command-line)
helpers/              => hanami/helpers
mailers/              => hanami/mailer
models/               => hanami/model  (guides/)
upgrade-notes/        => hanami/hanami (guides/upgrade-notes) - or stays here
applications/         => hanami/hanami (guides/applications)
assets/               => hanami/assets
getting-started.md    => hanami/hanami (or stays here)
index.md              => stays here
migrations/           => hanami/model (guides/migrations)
routing/              => hanami/router
views/                => hanami/view

This would fix the issue of having to make two separate PR's for changes that affect the guides. Though you'd still have to do that for changes that affect the getting-started guide. The blog would stay in this repo.

This would also help people searching for something in, let's say, hanami/controller that is answered in the guide for that section.

Thoughts?
@hanami/core-team @hanami/contributors

Weird-feeling phrase in `hanami.github.io/source/guides/views/testing.md`

We can both understand if a specific presentational logic behaves correctly and/or assert if the rendered markup.

I feel like a) there's something missing at the end ("assert if the rendered markup is correct") or b) the sentence should be slightly different ("assert the contents of the rendered markup").

Method in views (confusing example)

Given example maybe should be replaced by another one, not bound to form, because passing wrong params cause error

Add a book#test_0002_displays list of errors when params contains errors:
NameError: undefined local variable or method `form' for #<Hanami::View::Rendering::Scope:0x007fe0fa942e00>
Did you mean?  fork

Error happens because template is rendering from Web::Views::Books::Create instead Web::Views::Books::New and Create view don't have form method

And this may be confusing, especially when passing tutorial in first time.

License?

I was wondering what the license of your source is, more specifically the design and it's assets.

Custom Helpers Guide - load_paths order issue

Following the example in Custom Helpers Guide (http://lotusrb.org/guides/helpers/custom-helpers/), I had an application loading error:
uninitialized constant Web::Helpers (NameError)
with Lotus v0.5.0 and Ruby 2.2.3.

It seems to be related to the loading order defined in application.rb file:

# apps/web/application.rb
      # ...

      load_paths << [
        'controllers',
        'views',
        'helpers'
      ]
# ...

      view.prepare do
        include Lotus::Helpers
        include Web::Helpers::Shuffler
      end

I guess helpers must be loaded before views before being included into them.
Inserting 'helpers' on top of load_paths fixed the issue:

# apps/web/application.rb
      # ...

      load_paths << [
        'helpers',
        'controllers',
        'views'
      ]
# ...

I this is right, could you fix the guide?
Thanks.

Interactor Guide

Hanami::Interactor, in hanami/utils is a very useful component.

We should consider adding a Guide to the website about how to use it (and the benefits of it).

Perhaps it could be an extension of the Getting Started guide, working from the bookshelf example.

There's no Hanami::Utils section on the site, so not sure if that's worth adding.

Happy to help write/review this guide, if we choose to move forward with it.

Trailing Slash on Route

I'm doing the getting started tutorial:

http://lotusrb.org/guides/getting-started/

But I'm stuck here:

image

It seems that if there's no trailing slash on /books, it says "File not found":

image

By adding the trailing slash, it displays correctly:

image

So I had to change visit to use trailing slash in order to make the tests pass.

image

Any ideas why this is happening?

Doc: fix code in Guides/1.1/Architecture/Interactors

I may have found mistake in http://hanamirb.org/guides/1.1/architecture/interactors/.

That page contain code above:

# spec/bookshelf/interactors/add_book_spec.rb:
require 'spec_helper'

describe AddBook do
  let(:interactor) { AddBook.new }

  it "succeeds" do
    expect(interactor.call).to be_a_success
  end
end
# lib/bookshelf/interactors/add_book.rb
require 'hanami/interactor'

class AddBook
  include Hanami::Interactor

  def initialize
    # set up the object
  end

  def call(book_attributes)
    # get it done
  end
end

Copy and paste these codes, run bundle exec rake test, I saw an error like this:

  1) Error:
AddBook#test_0001_succeeds:
ArgumentError: wrong number of arguments (given 0, expected 1)
    /Users/hoge/work/myruby/hanami_practice/bookshelf/lib/bookshelf/interactors/add_book.rb:10:in `call'
    /Users/hoge/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/hanami-utils-1.1.1/lib/hanami/interactor.rb:356:in `block in call'

Docs improvement

I suggest discussing what we want to add to guides. I created a simple list with my ideas. If you have other ideas - let's discuss and update list ❤️

List

Validations

  • Copy validation docs from validation repository
  • Say that hanami-v based on dry-v

Controllers

  • Add information about flash (now we have only information about testing)
  • Rendering XML and JSON data in controllers
  • Streaming and File Downloads

View

Router

Introduction

  • Build simple JSON API project with hanami (something like "Getting Started")

Model

  • check this PR: #343

Other guides

  • How to build custom CLI
  • Add information about hanami-utils
  • Security Guide
  • Debugging hanami app
  • Profiling hanami app
  • How to contribute to hanami

cc @hanami/core

Database configuration guide

There should be a guide on database configuration explaining where to put the database link and what it should look like with majorly used databases (sqlite, mysql, postgresql)

Travis can't deploy site

We have a little problem with travis now. For fixing this, I see two ways:

  1. Ask @joneslee85 to help us and set new password to secret;
  2. Update build config in travis for a new person (travis guide how to set secret value).

What do you prefer @hanami/core?

Show all blog posts

The blog page only links to the 5 most recent posts: http://hanamirb.org/blog/

I couldn't find any other way to see older blog posts. I just searched google for what I was looking for).

It makes sense to only show 5 most recent by default, but others should be reachable.
We can either add pagination, or make an 'archive' index page that links to all the blog posts.

Anchor icon

Hello,
Anchor icon which is used on the blog posts is differs from the site styleguide (IMHO)
image

May I submit PR for it, or this works as designed ?

Remove bundle directory

The bundle directory is quite large and takes a long time to clone down here in Kangaland. I would suggest removing this directory and instead relying on the Gemfile.lock.

My concern with it being so huge is that it is a barrier-to-entry for new OSS contributors, who may also come from countries with slow internet connections.

WDYT?

Default focus in the search box for guides

Hi,

This is really a small issue, and maybe it's by even by design, but I find it really annoying that whenever I open a new page in /guides, the focus goes to the search box on top, because I can't scroll with PageUp/PageDown right away. And if I scroll with the mouse, when I click on a link (typically on the right-hand side panel), it does not activate the link but removes the focus from the search box. Then I have to click again. And at least on Firefox, the search box, when it receives the focus, extends too much and pushes the top-right-hand links div down, pushing the whole page contents down, so that means that the link will move up after the first click.

I hope that makes sense.

Update search to only show newest version

image

Those are links to:

  • /guides/1.0/actions/rack-integration/
  • /guides/1.1/actions/rack-integration/
  • /guides/actions/rack-integration/ (which is same as 1.1 right now)

I think we should just link to the last one. What do others think? @davydovanton @hanami/core

Environment Variables guide

Right now we use dotenv in development and test environments, but not production. This issue has effected several people in the chat.

We should consider adding a guide for Environment variables. Specifically, explain how they're set in development and test, as well as offer some suggestions for how to set them in production (heroku config:set,.env.production combined with an entry in .gitignore, or even .bashrc).

We can talk about SERVE_STATIC_ASSETS and APPNAME_SESSIONS_SECRET there too.

Add Guide for Deploying

We already have a mini-guide for deploying to Heroku on the homepage, in a tab, but we should put this same information (with more explanation) into a Guide. Perhaps we should make it generic, but focus on Heroku, since it's a standard enough that we can help people.

The cause for this is that @sovetnik asked about a deploying issue in the Gitter chat. We should make it so people don't have to ask in the chat.

Guide: sessions is misleading regarding custom session adapters

Here https://github.com/hanami/hanami.github.io/blob/build/source/guides/head/actions/sessions.md it says that

Custom storage technologies are autoloaded via require "rack/session/#{ adapter_name }". 

However, when I create file with class Rack::Session::Foo loadable by require 'rack/session/foo', it's not autoloaded and server complains about uninitialized constant. At the moment I just require it manualy at top of application.rb, but the guide should probably be reworded somehow (not sure how).

Need verification on a portion of the architectures page

As from the Architectures page, there is a sentence said that

Indeed, by opening lib/bookshelf.rb, we find the Bookshelf module, which is the main namespace of our project.

From my workspace, I don't see Module Bookshelf on such file. My lib/bookshelf.rb content is as follow
Hanami::Utils.require!("#{__dir__}/bookshelf")

Not sure if such text is still valid.

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.