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
28 changed files
with
713 additions
and
147 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
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,47 @@ | ||
Admin.controllers :doors do | ||
|
||
get :index do | ||
@doors = Door.all | ||
render 'doors/index' | ||
end | ||
|
||
get :new do | ||
@door = Door.new | ||
render 'doors/new' | ||
end | ||
|
||
post :create do | ||
@door = Door.new(params[:door]) | ||
if @door.save | ||
flash[:notice] = 'Door was successfully created.' | ||
redirect url(:doors, :edit, :id => @door.id) | ||
else | ||
render 'doors/new' | ||
end | ||
end | ||
|
||
get :edit, :with => :id do | ||
@door = Door.first(:id => params[:id]) | ||
render 'doors/edit' | ||
end | ||
|
||
put :update, :with => :id do | ||
@door = Door.first(:id => params[:id]) | ||
if @door.update(params[:door]) | ||
flash[:notice] = 'Door was successfully updated.' | ||
redirect url(:doors, :edit, :id => @door.id) | ||
else | ||
render 'doors/edit' | ||
end | ||
end | ||
|
||
delete :destroy, :with => :id do | ||
door = Door.first(:id => params[:id]) | ||
if door.destroy | ||
flash[:notice] = 'Door was successfully destroyed.' | ||
else | ||
flash[:error] = 'Unable to destroy Door!' | ||
end | ||
redirect url(:doors, :index) | ||
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,47 @@ | ||
Admin.controllers :maps do | ||
|
||
get :index do | ||
@maps = Map.all | ||
render 'maps/index' | ||
end | ||
|
||
get :new do | ||
@map = Map.new | ||
render 'maps/new' | ||
end | ||
|
||
post :create do | ||
@map = Map.new(params[:map]) | ||
if @map.save | ||
flash[:notice] = 'Map was successfully created.' | ||
redirect url(:maps, :edit, :id => @map.id) | ||
else | ||
render 'maps/new' | ||
end | ||
end | ||
|
||
get :edit, :with => :id do | ||
@map = Map.get(params[:id]) | ||
render 'maps/edit' | ||
end | ||
|
||
put :update, :with => :id do | ||
@map = Map.get(params[:id]) | ||
if @map.update(params[:map]) | ||
flash[:notice] = 'Map was successfully updated.' | ||
redirect url(:maps, :edit, :id => @map.id) | ||
else | ||
render 'maps/edit' | ||
end | ||
end | ||
|
||
delete :destroy, :with => :id do | ||
map = Map.get(params[:id]) | ||
if map.destroy | ||
flash[:notice] = 'Map was successfully destroyed.' | ||
else | ||
flash[:error] = 'Unable to destroy Map!' | ||
end | ||
redirect url(:maps, :index) | ||
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
get :new do | ||
@story = Story.new | ||
@story.map = Map.first | ||
render 'stories/new' | ||
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,112 @@ | ||
class Padrino::Helpers::FormBuilder::AbstractFormBuilder | ||
# Here we have access to a number of useful variables | ||
# | ||
# ** template (use this to invoke any helpers)(ex. template.hidden_field_tag(...)) | ||
# ** object (the record for this form) (ex. object.valid?) | ||
# ** object_name (object's underscored type) (ex. object_name => 'admin_user') | ||
# | ||
# We also have access to self.field_types => [:text_field, :text_area, ...] | ||
# In addition, we have access to all the existing field tag | ||
# helpers (text_field, hidden_field, file_field, ...) | ||
|
||
# f.ordering_select :color, :options => ['red', 'green'] | ||
def ordering_select(field, options={}) | ||
options.reverse_merge!(:id => field_id(field), :selected => field_value(field)) | ||
options[:class] = 'ordering_select' | ||
options.merge!(:class => field_error(field, options)) | ||
@template.select_tag field_name(field), options | ||
end | ||
|
||
# f.text_area :summary, :value => "(enter summary)", :id => 'summary' | ||
def rich_text_area(field, options={}) | ||
options.reverse_merge!(:value => field_value(field), :id => field_id(field)) | ||
options[:class] = 'rich_text_editor' | ||
options.merge!(:class => field_error(field, options)) | ||
@template.text_area_tag field_name(field), options | ||
end | ||
|
||
# f.date_field :event_date, :value=>"1985-12-31", :id=> 'date' | ||
def date_field(field, options={}) | ||
options.reverse_merge!(:value => field_value(field), :id => field_id(field)) | ||
options[:class] = 'date_field' | ||
options.merge!(:class => field_error(field, options)) | ||
@template.date_field_tag field_name(field), options | ||
end | ||
|
||
# f.time_field :event_time, :value=>"20:30", :id=> 'date' | ||
def time_field(field, options={}) | ||
options.reverse_merge!(:value => field_value(field) ? field_value(field).to_time.strftime("%H:%M") : nil, :id => field_id(field)) | ||
options[:class] = 'time_field' | ||
options.merge!(:class => field_error(field, options)) | ||
@template.time_field_tag field_name(field), options | ||
end | ||
|
||
# f.time_field :event_time, :value=>"20:30", :id=> 'date' | ||
def number_field(field, options={}) | ||
options.reverse_merge!(:value => field_value(field) ? field_value(field).to_i : nil, :id => field_id(field)) | ||
options[:class] = 'number_field' | ||
options.merge!(:class => field_error(field, options)) | ||
@template.number_field_tag field_name(field), options | ||
end | ||
|
||
# f.image_file_field :photo, :class => 'avatar' | ||
def image_file_field(field, options={}) | ||
options.reverse_merge!(:id => field_id(field)) | ||
options.merge!(:class => field_error(field, options)) | ||
html = '' | ||
html += @template.file_field_tag field_name(field), options | ||
if object.send(field).url | ||
html += "<img src='#{object.send(field).url}' class='image_file_field_thumbnail' alt='#'/>" | ||
end | ||
html | ||
end | ||
|
||
# f.normal_file_field :photo, :class => 'avatar' | ||
def normal_file_field(field, options={}) | ||
options.reverse_merge!(:id => field_id(field)) | ||
options.merge!(:class => field_error(field, options)) | ||
html = '' | ||
html += @template.file_field_tag field_name(field), options | ||
if object.send(field).url | ||
html += "<span class='normal_file_field_name'>File: #{object.send(field).url}</span>" | ||
end | ||
html | ||
end | ||
|
||
# f.audio_file_field :photo, :class => 'avatar' | ||
def audio_file_field(field, options={}) | ||
options.reverse_merge!(:id => field_id(field)) | ||
options.merge!(:class => field_error(field, options)) | ||
html = '' | ||
html += @template.file_field_tag field_name(field), options | ||
if object.send(field).url | ||
html += "<span class='audio_file_field_name'>File: #{object.send(field).url}</span>" | ||
end | ||
html | ||
end | ||
|
||
def crud_fields(options = {}) | ||
html = "" | ||
if options[:parent] | ||
fields = object.class.form_fields(options[:parent]) | ||
else | ||
fields = object.class.form_fields | ||
end | ||
fields.each_with_index do |f, i| | ||
html << "<p class='#{f[:type]}_type'>" | ||
html << self.label(f[:label] || f[:name]) | ||
if f[:options] | ||
html << self.send(f[:type], f[:name], :options=>f[:options]) | ||
elsif f[:options] && f[:include_blank] | ||
html << self.send(f[:type], f[:name], :options=>f[:options], :include_blank=>f[:include_blank]) | ||
else | ||
html << self.send(f[:type], f[:name]) | ||
end | ||
if f[:help] | ||
html << '<span class="field_help"><a href="return false;">Help</a><span class="jt_content">'+f[:help]+'</span></span>' | ||
end | ||
html << "</p>\n" | ||
end | ||
html | ||
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
.block | ||
%h3 Simple Block | ||
.content | ||
%p | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | ||
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | ||
.block | ||
%h3 Links | ||
%ul.navigation | ||
%li=link_to "Link 1" | ||
%li=link_to "Link 2" | ||
- if false | ||
.block | ||
%h3 Simple Block | ||
.content | ||
%p | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | ||
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | ||
.block | ||
%h3 Links | ||
%ul.navigation | ||
%li=link_to "Link 1" | ||
%li=link_to "Link 2" |
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,48 @@ | ||
.group | ||
=f.label :x | ||
=f.error_message_on :x | ||
=f.number_field :x, :class => :text_field | ||
|
||
=f.label :y | ||
=f.error_message_on :y | ||
=f.number_field :y, :class => :text_field | ||
|
||
.group | ||
=f.label :from_id | ||
=f.error_message_on :from_id | ||
|
||
%select{:name=>"door[from_id]", :onchange => "console.log(this); $('#map_image').attr('src', $(this).find('option:selected').data().image);"} | ||
- maps = Map.all | ||
- maps.each do |map| | ||
%option{:"data-image" => "/map_images/#{map.slug}.png", :value=>map.id, :selected => @door.from_id == map.id}= map.title | ||
|
||
.group | ||
=f.label :to_id | ||
=f.error_message_on :to_id | ||
|
||
%select{:name=>"door[to_id]"} | ||
- maps = Map.all | ||
- maps.each do |map| | ||
%option{:"data-image" => "/map_images/#{map.slug}.png", :value=>map.id, :selected => @door.to_id == map.id}= map.title | ||
|
||
%img#map_image{:src=>"/map_images/#{@door.from.slug}.png", :width => "800"} | ||
#marker{:style=>"display: block; position: absolute; z-index: 2000; width: 8px; height: 8px; background-color: black;"} | ||
|
||
:javascript | ||
$(function() { | ||
var $map = $("#map_image"); | ||
window.redrawMarker = function() { | ||
var left = $map.offset().left + (parseInt($("#door_x").val()) * $map.width()/100.0 ); | ||
console.log(left); | ||
$("#marker").css("left", left); | ||
$("#marker").css("top", $map.offset().top + (parseInt($("#door_y").val()) * $map.height()/100.0 )); | ||
} | ||
$("#door_x").bind("change", function() { redrawMarker(); }); | ||
$("#door_y").bind("change", function() { redrawMarker(); }); | ||
redrawMarker(); | ||
var markerInterval = setInterval(redrawMarker, 500); | ||
}); | ||
|
||
.group.navform.wat-cf | ||
=f.submit pat(:save), :class => :button | ||
=f.submit pat(:cancel), :onclick => "window.location='#{url(:doors, :index)}';return false", :class => :button |
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,15 @@ | ||
.block | ||
.secondary-navigation | ||
%ul.wat-cf | ||
%li.first=link_to pat(:list), url(:doors, :index) | ||
%li=link_to pat(:new), url(:doors, :new) | ||
%li.active=link_to pat(:edit), url(:doors, :edit, :id => @door.id) | ||
.content | ||
%h2.title | ||
=pat(:edit) | ||
=mt(:door) | ||
.inner | ||
-form_for :door, url(:doors, :update, :id => @door.id), :method => :put, :class => :form do |f| | ||
=partial "doors/form", :locals => { :f => f } | ||
|
||
-content_for :sidebar, partial("base/sidebar") |
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,33 @@ | ||
.block | ||
.secondary-navigation | ||
%ul.wat-cf | ||
%li.first.active=link_to pat(:list), url(:doors, :index) | ||
%li=link_to pat(:new), url(:doors, :new) | ||
.content | ||
%h2.title | ||
=pat(:all) | ||
=mt(:doors) | ||
.inner | ||
%table.table | ||
%tr | ||
%th.first=mat(:door, :id) | ||
%th=mat(:door, :x) | ||
%th=mat(:door, :y) | ||
%th=mat(:door, :from_id) | ||
%th=mat(:door, :to_id) | ||
%th.last=" " | ||
-@doors.each do |door| | ||
%tr | ||
%td.first=door.id | ||
%td=door.x | ||
%td=door.y | ||
%td=door.from.slug | ||
%td=door.to.slug | ||
%td.last | ||
=button_to pat(:edit), url(:doors, :edit, :id => door.id), :method => :get, :class => :button_to | ||
="|" | ||
=button_to pat(:delete), url(:doors, :destroy, :id => door.id), :method => :delete, :class => :button_to, :onsubmit => "return confirm('#{pat(:confirm)}')" | ||
.actions-bar.wat-cf | ||
.actions=" " | ||
|
||
-content_for :sidebar, partial("base/sidebar") |
Oops, something went wrong.