All Projects โ†’ akabiru โ†’ panda

akabiru / panda

Licence: MIT License
๐Ÿผ Panda is an mvc web application framework built with Ruby.

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to panda

Cuba
Rum based microframework for web development.
Stars: โœญ 1,385 (+11441.67%)
Mutual labels:  rack, micro-framework
YurunPHP
YurunPHPๆ˜ฏๅฎ‡ๆถฆ่ฝฏไปถไธ“ไธบๆ‡’ไบบๅผ€ๅ‘่€…่ฎพ่ฎก็š„ไธ€ๆฌพๅผ€ๆบPHPๆก†ๆžถ๏ผŒๅŸบไบŽMVCๅŠจๆ€ๅˆ†ๅฑ‚ๆžถๆž„๏ผŒๅผ€ๅ‘่€…ๅฏไปฅๆ นๆฎ้œ€่ฆ่‡ช่กŒๆ‰ฉๅ……ๅˆ†ๅฑ‚ใ€‚ๅฎ‡ๆถฆPHPไบคๆต็พค๏ผš17916227
Stars: โœญ 30 (+150%)
Mutual labels:  mvc-framework
mini-swift
Minimal Flux architecture written in Swift.
Stars: โœญ 40 (+233.33%)
Mutual labels:  micro-framework
rack-ratelimit
Flexible rate limiting for your Rack apps
Stars: โœญ 111 (+825%)
Mutual labels:  rack
rack-simple user agent
Rack::SimpleUserAgent is stupidly simple UA detector
Stars: โœญ 13 (+8.33%)
Mutual labels:  rack
booking
PHP Room meeting script เน‚เธ›เธฃเนเธเธฃเธกเธˆเธญเธ‡เธซเน‰เธญเธ‡เธ›เธฃเธฐเธŠเธธเธก PHP
Stars: โœญ 18 (+50%)
Mutual labels:  mvc-framework
Geisha
Tiny Java Web Framework.
Stars: โœญ 120 (+900%)
Mutual labels:  mvc-framework
blockbase
Lightweight MVC Framework for Node.js
Stars: โœญ 32 (+166.67%)
Mutual labels:  mvc-framework
laminas-mvc
Laminas's event-driven MVC layer, including MVC Applications, Controllers, and Plugins
Stars: โœญ 90 (+650%)
Mutual labels:  mvc-framework
back
Back.js : MVC Framework for Node.js written in Typescript and built on top of Express.js
Stars: โœญ 51 (+325%)
Mutual labels:  mvc-framework
rdf-ldp
A suite of LDP software and middleware for RDF.rb & Rack
Stars: โœญ 14 (+16.67%)
Mutual labels:  rack
W
Framework pรฉdagogique de la WebForce3
Stars: โœญ 10 (-16.67%)
Mutual labels:  mvc-framework
yatpl
Yet Another Template Engine ๐Ÿš€
Stars: โœญ 14 (+16.67%)
Mutual labels:  rack
pimf-framework
Micro framework for PHP that emphasises minimalism and simplicity
Stars: โœญ 42 (+250%)
Mutual labels:  micro-framework
serverless-rack
Serverless plugin to deploy Ruby Rack applications (Sinatra/Rails/Padrino/Cuba etc.) and bundle gems
Stars: โœญ 58 (+383.33%)
Mutual labels:  rack
stencil-realworld-app
An example SPA written with Stencil
Stars: โœญ 56 (+366.67%)
Mutual labels:  mvc-framework
leafMVC
MVC "Framework" created from Leaf PHP Framework
Stars: โœญ 25 (+108.33%)
Mutual labels:  mvc-framework
Bingo-Framework
MVC framework for PHP
Stars: โœญ 15 (+25%)
Mutual labels:  mvc-framework
rack-fluentd-logger
Rack middleware to send traffic logs to Fluentd
Stars: โœญ 21 (+75%)
Mutual labels:  rack
vessel
Vessel is an opinionated bootstrap of files to setup an API centric Flask application.
Stars: โœญ 16 (+33.33%)
Mutual labels:  micro-framework

Code Climate Coverage Status Issue Count Build Status Dependency Status Gem Version

Panda

Panda is an mvc framework built with Ruby for building web applications.

Getting started

Clone Panda

$ git clone https://github.com/andela-akabiru/panda

Add this line to your application's Gemfile:

gem 'panda_frwk'

And then execute:

$ bundle

Usage

Panda uses the mvc pattern. Thus your application structure should be as follows:

.
โ”œโ”€โ”€ app
โ”‚   โ”œโ”€โ”€ controllers
โ”‚   โ”‚   โ””โ”€โ”€ todo_controller.rb
โ”‚   โ”œโ”€โ”€ models
โ”‚   โ”‚   โ””โ”€โ”€ todo.rb
โ”‚   โ””โ”€โ”€ views
โ”‚       โ”œโ”€โ”€ layouts
โ”‚       โ”‚   โ””โ”€โ”€ application.html.erb
โ”‚       โ””โ”€โ”€ todo
โ”‚           โ”œโ”€โ”€ edit.html.erb
โ”‚           โ”œโ”€โ”€ index.html.erb
โ”‚           โ”œโ”€โ”€ new.html.erb
โ”‚           โ””โ”€โ”€ show.html.erb
โ”œโ”€โ”€ config
โ”‚   โ”œโ”€โ”€ application.rb
โ”‚   โ””โ”€โ”€ routes.rb
โ”œโ”€โ”€ config.ru
โ”œโ”€โ”€ db
โ”‚   โ””โ”€โ”€ app.db
โ”œโ”€โ”€ Gemfile
โ”œโ”€โ”€ Gemfile.lock
โ””โ”€โ”€ README.md

Routes

Your routes should be defined in config/routes.rb file. Here's an example.

TodoApplication.routes.draw do
  root "todo#index"
  get "/todo", to: "todo#index"
  get "/todo/new", to: "todo#new"
  get "/todo/:id", to: "todo#show"
  get "/todo/:id/edit", to: "todo#edit"
  post "/todo", to: "todo#create"
  put "/todo/:id", to: "todo#update"
  delete "/todo/:id", to: "todo#destroy"
end

Models

Models are defined in app/models folder. Here's an example model

class Todo < Panda::Record::Base
  to_table :todos
  property :id, type: :integer, primary_key: true
  property :title, type: :text, nullable: false
  property :body, type: :text, nullable: false
  property :status, type: :text, nullable: false
  property :created_at, type: :text, nullable: false
  create_table
end

Controllers

Controllers are defined in app/controllers. Here's an example controller.

class TodoController < Panda::BaseController
  def index
    @todos = Todo.all
  end

  def show
    @todo = Todo.find(params["id"])
  end

  def new
  end

  def edit
    @todo = Todo.find(params["id"])
  end

  def update
    todo = Todo.find(params["id"])
    todo.update(
      title: params["title"],
      body: params["body"],
      status: params["status"]
    )
    redirect_to "/todo/#{todo.id}"
  end

  def create
    Todo.create(
      title: params["title"],
      body: params["body"],
      status: params["status"],
      created_at: Time.now.to_s
    )
    redirect_to "/todo"
  end

  def destroy
    todo = Todo.find(params["id"])
    todo.destroy
    redirect_to "/todo"
  end
end

Views

Views are mapped to the controller actions. E.g if You have a TodoController, views for that controller should be defined in app/views/todos/action_name.erb. Panda depends on Tilt gem and thus supports embedded ruby in the views. Instance variables defined in the controller actions can be accessed in the corresponding view.

Here's an example usage:

Controller app/controllers/todo_controller.rb

[...]
def index
  @todos = Todo.all
end
[...]

View app/views/index.html.erb

<h1>My Todos</h1>

<% @todos.each do |todo| %>
  <p><strong><%= todo.title %></strong> <em><%= todo.status %></em>
    <a href="/todo/<%= todo.id %>" id="todo_<%= todo.id %>">Show</a> | <a href="/todo/<%= todo.id %>/edit">Edit</a>
  </p>
<% end %>

<p><a href="/todo/new">New Todo</a></p>

Note that there's an layout file app/views/layouts/application.html.erb. Here you can define your general view layout. Other views will be rendered inside the file.

Here's a sample layout file:

<!DOCTYPE html>
<html>
<head>
  <title><%= title %></title>
</head>
<body>
  <%= yield %>
</body>
</html>

Configuration

I bet you've noticed that there's a config.ru file. This file that gets called when we run our panda application. However, there're some few things to take note of:

Set the APP_ROOT to the current directory since panda uses that constant to find templates.

APP_ROOT = __dir__

Require config/appliaction

require_relative './config/application.rb'

Add method override middleware. This masks put and delete request as post requests.

use Rack::MethodOverride

After this what's left is initialising the panda application, locading the routes and running it.

To run the application run

$ bundle exec rackup

at the root of your application.

Tests

Panda is well tested with a sample application for integration tests and unit specs for the base model. To run the specs run

$ bundle exec rake

Or

$ bundle exec rspec -fd

Application Limitations

  • Panda does not have a generator for file structures.
  • Panda does not support model relationships at the moment

Dependencies

  1. Ruby
  2. SQlite3
  3. Bundler
  4. Rack
  5. Rack Test
  6. Rspec

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/akabiru/panda. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].