Skip to content

Commit

Permalink
Added plugins table and scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
augustf committed Jul 9, 2012
1 parent 22fa799 commit ba57b67
Show file tree
Hide file tree
Showing 18 changed files with 406 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/assets/javascripts/plugins.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/plugins.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the plugins controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
56 changes: 56 additions & 0 deletions app/assets/stylesheets/scaffolds.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
body {
background-color: #fff;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }

p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px; }

pre {
background-color: #eee;
padding: 10px;
font-size: 11px; }

a {
color: #000;
&:visited {
color: #666; }
&:hover {
color: #fff;
background-color: #000; } }

div {
&.field, &.actions {
margin-bottom: 10px; } }

#notice {
color: green; }

.field_with_errors {
padding: 2px;
background-color: red;
display: table; }

#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff; }
ul li {
font-size: 12px;
list-style: square; } }
83 changes: 83 additions & 0 deletions app/controllers/plugins_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
class PluginsController < ApplicationController
# GET /plugins
# GET /plugins.json
def index
@plugins = Plugin.all

respond_to do |format|
format.html # index.html.erb
format.json { render json: @plugins }
end
end

# GET /plugins/1
# GET /plugins/1.json
def show
@plugin = Plugin.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.json { render json: @plugin }
end
end

# GET /plugins/new
# GET /plugins/new.json
def new
@plugin = Plugin.new

respond_to do |format|
format.html # new.html.erb
format.json { render json: @plugin }
end
end

# GET /plugins/1/edit
def edit
@plugin = Plugin.find(params[:id])
end

# POST /plugins
# POST /plugins.json
def create
@plugin = Plugin.new(params[:plugin])

respond_to do |format|
if @plugin.save
format.html { redirect_to @plugin, notice: 'Plugin was successfully created.' }
format.json { render json: @plugin, status: :created, location: @plugin }
else
format.html { render action: "new" }
format.json { render json: @plugin.errors, status: :unprocessable_entity }
end
end
end

# PUT /plugins/1
# PUT /plugins/1.json
def update
@plugin = Plugin.find(params[:id])

respond_to do |format|
if @plugin.update_attributes(params[:plugin])
format.html { redirect_to @plugin, notice: 'Plugin was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @plugin.errors, status: :unprocessable_entity }
end
end
end

# DELETE /plugins/1
# DELETE /plugins/1.json
def destroy
@plugin = Plugin.find(params[:id])
@plugin.destroy

respond_to do |format|
format.html { redirect_to plugins_url }
format.json { head :no_content }
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/plugins_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module PluginsHelper
end
3 changes: 3 additions & 0 deletions app/models/plugin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Plugin < ActiveRecord::Base
attr_accessible :enabled, :gem_name, :gem_version, :installed, :module_name, :name, :source, :source_url
end
49 changes: 49 additions & 0 deletions app/views/plugins/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<%= form_for(@plugin) do |f| %>
<% if @plugin.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@plugin.errors.count, "error") %> prohibited this plugin from being saved:</h2>

<ul>
<% @plugin.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :module_name %><br />
<%= f.text_field :module_name %>
</div>
<div class="field">
<%= f.label :enabled %><br />
<%= f.check_box :enabled %>
</div>
<div class="field">
<%= f.label :gem_name %><br />
<%= f.text_field :gem_name %>
</div>
<div class="field">
<%= f.label :gem_version %><br />
<%= f.text_field :gem_version %>
</div>
<div class="field">
<%= f.label :source %><br />
<%= f.text_field :source %>
</div>
<div class="field">
<%= f.label :source_url %><br />
<%= f.text_field :source_url %>
</div>
<div class="field">
<%= f.label :installed %><br />
<%= f.check_box :installed %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
6 changes: 6 additions & 0 deletions app/views/plugins/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h1>Editing plugin</h1>

<%= render 'form' %>
<%= link_to 'Show', @plugin %> |
<%= link_to 'Back', plugins_path %>
37 changes: 37 additions & 0 deletions app/views/plugins/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<h1>Listing plugins</h1>

<table>
<tr>
<th>Name</th>
<th>Module name</th>
<th>Enabled</th>
<th>Gem name</th>
<th>Gem version</th>
<th>Source</th>
<th>Source url</th>
<th>Installed</th>
<th></th>
<th></th>
<th></th>
</tr>

<% @plugins.each do |plugin| %>
<tr>
<td><%= plugin.name %></td>
<td><%= plugin.module_name %></td>
<td><%= plugin.enabled %></td>
<td><%= plugin.gem_name %></td>
<td><%= plugin.gem_version %></td>
<td><%= plugin.source %></td>
<td><%= plugin.source_url %></td>
<td><%= plugin.installed %></td>
<td><%= link_to 'Show', plugin %></td>
<td><%= link_to 'Edit', edit_plugin_path(plugin) %></td>
<td><%= link_to 'Destroy', plugin, confirm: 'Are you sure?', method: :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New Plugin', new_plugin_path %>
5 changes: 5 additions & 0 deletions app/views/plugins/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>New plugin</h1>

<%= render 'form' %>
<%= link_to 'Back', plugins_path %>
45 changes: 45 additions & 0 deletions app/views/plugins/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<p id="notice"><%= notice %></p>

<p>
<b>Name:</b>
<%= @plugin.name %>
</p>

<p>
<b>Module name:</b>
<%= @plugin.module_name %>
</p>

<p>
<b>Enabled:</b>
<%= @plugin.enabled %>
</p>

<p>
<b>Gem name:</b>
<%= @plugin.gem_name %>
</p>

<p>
<b>Gem version:</b>
<%= @plugin.gem_version %>
</p>

<p>
<b>Source:</b>
<%= @plugin.source %>
</p>

<p>
<b>Source url:</b>
<%= @plugin.source_url %>
</p>

<p>
<b>Installed:</b>
<%= @plugin.installed %>
</p>


<%= link_to 'Edit', edit_plugin_path(@plugin) %> |
<%= link_to 'Back', plugins_path %>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Concerto::Application.routes.draw do
resources :plugins

#Custom route for the screen creation/admin form JS
#TODO(bamnet): Clean this up
match "update_owners" => "screens#update_owners"
Expand Down
16 changes: 16 additions & 0 deletions db/migrate/20120709001009_create_plugins.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class CreatePlugins < ActiveRecord::Migration
def change
create_table :plugins do |t|
t.string :name
t.string :module_name
t.boolean :enabled
t.string :gem_name
t.string :gem_version
t.string :source
t.string :source_url
t.boolean :installed

t.timestamps
end
end
end
16 changes: 15 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
Expand All @@ -10,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120612053133) do
ActiveRecord::Schema.define(:version => 20120709001009) do

create_table "concerto_configs", :force => true do |t|
t.string "key"
Expand Down Expand Up @@ -85,6 +86,19 @@
t.integer "level", :default => 1
end

create_table "plugins", :force => true do |t|
t.string "name"
t.string "module_name"
t.boolean "enabled"
t.string "gem_name"
t.string "gem_version"
t.string "source"
t.string "source_url"
t.boolean "installed"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end

create_table "positions", :force => true do |t|
t.text "style"
t.decimal "top", :precision => 6, :scale => 5, :default => 0.0
Expand Down
21 changes: 21 additions & 0 deletions test/fixtures/plugins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html

one:
name: MyString
module_name: MyString
enabled: false
gem_name: MyString
gem_version: MyString
source: MyString
source_url: MyString
installed: false

two:
name: MyString
module_name: MyString
enabled: false
gem_name: MyString
gem_version: MyString
source: MyString
source_url: MyString
installed: false

0 comments on commit ba57b67

Please sign in to comment.