-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
525 additions
and
435 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,85 @@ | ||
class MediasController < ApplicationController | ||
# GET /medias | ||
# GET /medias.xml | ||
def index | ||
@medias = Media.search(params[:filter],params[:page]) | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @medias } | ||
end | ||
end | ||
|
||
# GET /medias/1 | ||
# GET /medias/1.xml | ||
def show | ||
@media = Media.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @media } | ||
end | ||
end | ||
|
||
# GET /medias/new | ||
# GET /medias/new.xml | ||
def new | ||
@media = Media.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.xml { render :xml => @media } | ||
end | ||
end | ||
|
||
# GET /medias/1/edit | ||
def edit | ||
@media = Media.find(params[:id]) | ||
end | ||
|
||
# POST /medias | ||
# POST /medias.xml | ||
def create | ||
@media = Media.new(params[:media]) | ||
|
||
respond_to do |format| | ||
if @media.save | ||
flash[:notice] = 'Media was successfully created.' | ||
format.html { redirect_to(@media) } | ||
format.xml { render :xml => @media, :status => :created, :location => @media } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @media.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /medias/1 | ||
# PUT /medias/1.xml | ||
def update | ||
@media = Media.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @media.update_attributes(params[:media]) | ||
flash[:notice] = 'Media was successfully updated.' | ||
format.html { redirect_to(@media) } | ||
format.xml { head :ok } | ||
else | ||
format.html { render :action => "edit" } | ||
format.xml { render :xml => @media.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /medias/1 | ||
# DELETE /medias/1.xml | ||
def destroy | ||
@media = Media.find(params[:id]) | ||
@media.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(medias_url) } | ||
format.xml { head :ok } | ||
end | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
app/helpers/attachments_helper.rb → app/helpers/medias_helper.rb
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
5 changes: 2 additions & 3 deletions
5
app/views/attachments/_attachment.html.haml → app/views/medias/_attachment.html.haml
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 |
---|---|---|
@@ -1,9 +1,8 @@ | ||
- semantic_form_for(@attachment, :html => {:multipart => true, :class => "form"}) do |f| | ||
- semantic_form_for(@media, :html => {:multipart => true, :class => "form"}) do |f| | ||
= f.input :media, :label => "Arquivo" | ||
|
||
= f.input :info | ||
.clear | ||
.navform | ||
= f.submit "Salvar →", :class => "button" | ||
ou | ||
= link_to 'Voltar', attachments_path | ||
= link_to 'Voltar', medias_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 @@ | ||
.media | ||
- f.inputs do | ||
= f.input :kind, :as => :select, :collection => Media.get_kind_values | ||
= f.input :value, :input_html => { :size => 15 } | ||
= f.remove_link "remove" |
2 changes: 1 addition & 1 deletion
2
app/views/attachments/edit.html.haml → app/views/medias/edit.html.haml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.block | ||
.content | ||
%h2{:class => "title"} Editando Registro | ||
.inner= render @attachment | ||
.inner= render @media |
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,20 @@ | ||
.block | ||
.head | ||
%h2.title Attachable | ||
.content | ||
%table{:class => "table"} | ||
%tbody | ||
%tr | ||
%th Tipo | ||
%th Info | ||
-@medias.each do |media| | ||
%tr | ||
-if media.media_content_type =~ /^image/ | ||
%td= image_tag media.media.url(:thumb) | ||
-else | ||
%td== #{image_tag("/images/mime/#{choose_icon media.media_file_name}")} #{media.media_file_name} | ||
%td= media.info | ||
|
||
= will_paginate @medias | ||
- sidebar do | ||
= link_to 'Novo Registro', new_media_path, :class => 'icon iadd' |
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
.head | ||
%h2 Novo registro | ||
.content | ||
.inner= render @attachment | ||
.inner= render @media |
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 @@ | ||
<p> | ||
<b>Attachable:</b> | ||
<%=h @media.attachable %> | ||
</p> | ||
|
||
<p> | ||
<b>Info:</b> | ||
<%=h @media.info %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_media_path(@media) %> | | ||
<%= link_to 'Back', medias_path %> |
Oops, something went wrong.