-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from creativepsyco/app_api
Stable Uploads now safe to do a pull request
- Loading branch information
Showing
25 changed files
with
378 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ capybara-*.html | |
**.orig | ||
rerun.txt | ||
pickle-email-*.html | ||
public/system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the apps controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
class AppsController < ApplicationController | ||
before_filter :authenticate_user! | ||
# GET /apps | ||
# GET /apps.json | ||
def index | ||
@apps = App.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @apps } | ||
end | ||
end | ||
|
||
# GET /apps/1 | ||
# GET /apps/1.json | ||
def show | ||
@app = App.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @app } | ||
end | ||
end | ||
|
||
# GET /apps/new | ||
# GET /apps/new.json | ||
def new | ||
@app = App.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @app } | ||
end | ||
end | ||
|
||
# GET /apps/1/edit | ||
def edit | ||
@app = App.find(params[:id]) | ||
end | ||
|
||
# POST /apps | ||
# POST /apps.json | ||
def create | ||
puts params | ||
# XXX: make sure authenticated person is same | ||
app_data = { | ||
:name => params[:name], | ||
:description => params[:description], | ||
:thumbnail => params[:thumbnail], | ||
:helpLink => params[:helpLink], | ||
:version => params[:version], | ||
:user_id => params[:user_id], | ||
:appFile => params[:appFile] | ||
} | ||
@app = App.new(app_data) | ||
|
||
respond_to do |format| | ||
if @app.save | ||
format.html #{ redirect_to @app, notice: 'App was successfully created.' } | ||
format.json { render json: @app, status: :created } | ||
else | ||
format.html # { render action: "new" } | ||
format.json { render json: @app.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /apps/1 | ||
# PUT /apps/1.json | ||
def update | ||
@app = App.find(params[:id]) | ||
@app.user = User.find(params[:user_id]) | ||
|
||
respond_to do |format| | ||
if @app.update_attributes(params[:app]) | ||
format.html # { redirect_to @app, notice: 'App was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @app.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /apps/1 | ||
# DELETE /apps/1.json | ||
def destroy | ||
@app = App.find(params[:id]) | ||
@app.destroy | ||
|
||
respond_to do |format| | ||
format.html # { redirect_to apps_url } | ||
format.json { head :no_content } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module AppsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class App < ActiveRecord::Base | ||
belongs_to :user | ||
attr_accessible :description, :helpLink, :name, :user_id, :version, :thumbnail, :appFile | ||
|
||
has_attached_file :thumbnail, | ||
:styles => { :medium => "300x300>", :thumb => "100x100>" }, | ||
:default_url => "/images/:style/missing.png" | ||
|
||
has_attached_file :appFile | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<%= form_for(@app) do |f| %> | ||
<% if @app.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@app.errors.count, "error") %> prohibited this app from being saved:</h2> | ||
|
||
<ul> | ||
<% @app.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 :description %><br /> | ||
<%= f.text_field :description %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :user_id %><br /> | ||
<%= f.number_field :user_id %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :helpLink %><br /> | ||
<%= f.text_field :helpLink %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :version %><br /> | ||
<%= f.text_field :version %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing app</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @app %> | | ||
<%= link_to 'Back', apps_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<h1>Listing apps</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Name</th> | ||
<th>Description</th> | ||
<th>User</th> | ||
<th>Helplink</th> | ||
<th>Version</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<% @apps.each do |app| %> | ||
<tr> | ||
<td><%= app.name %></td> | ||
<td><%= app.description %></td> | ||
<td><%= app.user_id %></td> | ||
<td><%= app.helpLink %></td> | ||
<td><%= app.version %></td> | ||
<td><%= link_to 'Show', app %></td> | ||
<td><%= link_to 'Edit', edit_app_path(app) %></td> | ||
<td><%= link_to 'Destroy', app, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New App', new_app_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New app</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', apps_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<b>Name:</b> | ||
<%= @app.name %> | ||
</p> | ||
|
||
<p> | ||
<b>Description:</b> | ||
<%= @app.description %> | ||
</p> | ||
|
||
<p> | ||
<b>User:</b> | ||
<%= @app.user_id %> | ||
</p> | ||
|
||
<p> | ||
<b>Helplink:</b> | ||
<%= @app.helpLink %> | ||
</p> | ||
|
||
<p> | ||
<b>Version:</b> | ||
<%= @app.version %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_app_path(@app) %> | | ||
<%= link_to 'Back', apps_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateApps < ActiveRecord::Migration | ||
def change | ||
create_table :apps do |t| | ||
t.string :name | ||
t.string :description | ||
t.integer :user_id | ||
t.string :helpLink | ||
t.string :version | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddThumbnailToApps < ActiveRecord::Migration | ||
def change | ||
add_attachment :apps, :thumbnail | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddAppFileToApps < ActiveRecord::Migration | ||
def change | ||
add_attachment :apps, :appFile | ||
end | ||
end |
Oops, something went wrong.