{"id":15600057,"url":"https://github.com/akabiru/panda","last_synced_at":"2025-04-28T10:49:29.513Z","repository":{"id":129240086,"uuid":"64389504","full_name":"akabiru/panda","owner":"akabiru","description":"🐼 Panda is an mvc web application framework built with Ruby.","archived":false,"fork":false,"pushed_at":"2023-12-15T12:07:23.000Z","size":34,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T01:11:20.303Z","etag":null,"topics":["framework-ruby","micro-framework","mvc-framework","rack","ruby"],"latest_commit_sha":null,"homepage":"https://akabiru.github.io/panda/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akabiru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-07-28T11:19:41.000Z","updated_at":"2024-08-29T15:13:51.000Z","dependencies_parsed_at":"2023-04-25T16:17:38.232Z","dependency_job_id":null,"html_url":"https://github.com/akabiru/panda","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akabiru%2Fpanda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akabiru%2Fpanda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akabiru%2Fpanda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akabiru%2Fpanda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akabiru","download_url":"https://codeload.github.com/akabiru/panda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251299337,"owners_count":21567199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework-ruby","micro-framework","mvc-framework","rack","ruby"],"created_at":"2024-10-03T02:01:34.750Z","updated_at":"2025-04-28T10:49:29.492Z","avatar_url":"https://github.com/akabiru.png","language":"Ruby","readme":"![](https://www.dropbox.com/s/yfhnvtjd7iei1e4/panda.png?raw=1)\n\n[![Code Climate](https://codeclimate.com/github/andela-akabiru/panda/badges/gpa.svg)](https://codeclimate.com/github/andela-akabiru/panda) [![Coverage Status](https://coveralls.io/repos/github/andela-akabiru/panda/badge.svg?branch=master)](https://coveralls.io/github/andela-akabiru/panda?branch=master) [![Issue Count](https://codeclimate.com/github/andela-akabiru/panda/badges/issue_count.svg)](https://codeclimate.com/github/andela-akabiru/panda) [![Build Status](https://travis-ci.org/akabiru/panda.svg?branch=master)](https://travis-ci.org/akabiru/panda)\n[![Dependency Status](https://gemnasium.com/badges/github.com/andela-akabiru/panda.svg)](https://gemnasium.com/github.com/andela-akabiru/panda) [![Gem Version](https://badge.fury.io/rb/panda_frwk.svg)](https://badge.fury.io/rb/panda_frwk)\n\n# Panda\n\nPanda is an mvc framework built with Ruby for building web applications.\n\n## Getting started\n\nClone Panda\n\n    $ git clone https://github.com/akabiru/panda\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'panda_frwk'\n```\n\nAnd then execute:\n\n    $ bundle\n\n## Usage\n\nPanda uses the mvc pattern. Thus your application structure should be as follows:\n\n    .\n    ├── app\n    │   ├── controllers\n    │   │   └── todo_controller.rb\n    │   ├── models\n    │   │   └── todo.rb\n    │   └── views\n    │       ├── layouts\n    │       │   └── application.html.erb\n    │       └── todo\n    │           ├── edit.html.erb\n    │           ├── index.html.erb\n    │           ├── new.html.erb\n    │           └── show.html.erb\n    ├── config\n    │   ├── application.rb\n    │   └── routes.rb\n    ├── config.ru\n    ├── db\n    │   └── app.db\n    ├── Gemfile\n    ├── Gemfile.lock\n    └── README.md\n\n\n\n### Routes\n\nYour routes should be defined in `config/routes.rb` file. Here's an example.\n\n```ruby\nTodoApplication.routes.draw do\n  root \"todo#index\"\n  get \"/todo\", to: \"todo#index\"\n  get \"/todo/new\", to: \"todo#new\"\n  get \"/todo/:id\", to: \"todo#show\"\n  get \"/todo/:id/edit\", to: \"todo#edit\"\n  post \"/todo\", to: \"todo#create\"\n  put \"/todo/:id\", to: \"todo#update\"\n  delete \"/todo/:id\", to: \"todo#destroy\"\nend\n```\n\n### Models\n\nModels are defined in `app/models` folder. Here's an example model\n\n```ruby\nclass Todo \u003c Panda::Record::Base\n  to_table :todos\n  property :id, type: :integer, primary_key: true\n  property :title, type: :text, nullable: false\n  property :body, type: :text, nullable: false\n  property :status, type: :text, nullable: false\n  property :created_at, type: :text, nullable: false\n  create_table\nend\n```\n\n### Controllers\n\nControllers are defined in `app/controllers`. Here's an example controller.\n\n```ruby\nclass TodoController \u003c Panda::BaseController\n  def index\n    @todos = Todo.all\n  end\n\n  def show\n    @todo = Todo.find(params[\"id\"])\n  end\n\n  def new\n  end\n\n  def edit\n    @todo = Todo.find(params[\"id\"])\n  end\n\n  def update\n    todo = Todo.find(params[\"id\"])\n    todo.update(\n      title: params[\"title\"],\n      body: params[\"body\"],\n      status: params[\"status\"]\n    )\n    redirect_to \"/todo/#{todo.id}\"\n  end\n\n  def create\n    Todo.create(\n      title: params[\"title\"],\n      body: params[\"body\"],\n      status: params[\"status\"],\n      created_at: Time.now.to_s\n    )\n    redirect_to \"/todo\"\n  end\n\n  def destroy\n    todo = Todo.find(params[\"id\"])\n    todo.destroy\n    redirect_to \"/todo\"\n  end\nend\n```\n\n### Views\n\nViews 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](https://github.com/rtomayko/tilt) gem and thus supports embedded ruby in the views. Instance variables defined in the controller actions can be accessed in the corresponding view.\n\nHere's an example usage:\n\nController `app/controllers/todo_controller.rb`\n\n```ruby\n[...]\ndef index\n  @todos = Todo.all\nend\n[...]\n```\n\nView `app/views/index.html.erb`\n\n```html\n\u003ch1\u003eMy Todos\u003c/h1\u003e\n\n\u003c% @todos.each do |todo| %\u003e\n  \u003cp\u003e\u003cstrong\u003e\u003c%= todo.title %\u003e\u003c/strong\u003e \u003cem\u003e\u003c%= todo.status %\u003e\u003c/em\u003e\n    \u003ca href=\"/todo/\u003c%= todo.id %\u003e\" id=\"todo_\u003c%= todo.id %\u003e\"\u003eShow\u003c/a\u003e | \u003ca href=\"/todo/\u003c%= todo.id %\u003e/edit\"\u003eEdit\u003c/a\u003e\n  \u003c/p\u003e\n\u003c% end %\u003e\n\n\u003cp\u003e\u003ca href=\"/todo/new\"\u003eNew Todo\u003c/a\u003e\u003c/p\u003e\n```\n\n\nNote 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.\n\nHere's a sample layout file:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003e\u003c%= title %\u003e\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c%= yield %\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Configuration\n\nI 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:\n\nSet the `APP_ROOT` to the current directory since panda uses that constant to find templates.\n\n```ruby\nAPP_ROOT = __dir__\n```\n\nRequire `config/appliaction`\n\n```ruby\nrequire_relative './config/application.rb'\n```\n\nAdd method override middleware. This masks put and delete request as post requests.\n\n```ruby\nuse Rack::MethodOverride\n```\n\nAfter this what's left is initialising the panda application, locading the routes and running it.\n\nTo run the application run\n\n    $ bundle exec rackup\n\nat the root of your application.\n\n\n### Tests\n\nPanda is well tested with a sample application for integration tests and unit specs for the base model. To run the specs run\n\n    $ bundle exec rake\n\nOr\n\n    $ bundle exec rspec -fd\n\n## Application Limitations\n\n  * Panda does not have a generator for file structures.\n  * Panda does not support model relationships at the moment\n\n## Dependencies\n  1. [Ruby](https://github.com/rbenv/rbenv)\n  2. [SQlite3](https://github.com/sparklemotion/sqlite3-ruby)\n  3. [Bundler](https://github.com/bundler/bundler)\n  4. [Rack](https://github.com/rack/rack)\n  5. [Rack Test](https://github.com/brynary/rack-test)\n  6. [Rspec](https://github.com/rspec/rspec)\n\n## Contributing\n\nBug 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](http://contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakabiru%2Fpanda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakabiru%2Fpanda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakabiru%2Fpanda/lists"}