refinerycms-locations 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/admin/locations_controller.rb +7 -0
- data/app/controllers/locations_controller.rb +30 -0
- data/app/models/location.rb +5 -0
- data/app/views/admin/locations/_form.html.erb +49 -0
- data/app/views/admin/locations/_location.html.erb +20 -0
- data/app/views/admin/locations/_sortable_list.html.erb +4 -0
- data/app/views/admin/locations/edit.html.erb +1 -0
- data/app/views/admin/locations/index.html.erb +67 -0
- data/app/views/admin/locations/new.html.erb +1 -0
- data/app/views/locations/index.html.erb +50 -0
- data/app/views/locations/show.html.erb +50 -0
- data/config/locales/en.yml +23 -0
- data/config/locales/nb.yml +19 -0
- data/config/locales/nl.yml +19 -0
- data/config/routes.rb +11 -0
- data/lib/generators/refinerycms_locations_generator.rb +6 -0
- data/lib/locations.rb +20 -0
- data/lib/tasks/locations.rake +13 -0
- metadata +63 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
class LocationsController < ApplicationController
|
2
|
+
|
3
|
+
before_filter :find_all_locations
|
4
|
+
before_filter :find_page
|
5
|
+
|
6
|
+
def index
|
7
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
8
|
+
# by swapping @page for @location in the line below:
|
9
|
+
present(@page)
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
@location = Location.find(params[:id])
|
14
|
+
|
15
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
16
|
+
# by swapping @page for @location in the line below:
|
17
|
+
present(@page)
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def find_all_locations
|
23
|
+
@locations = Location.find(:all, :order => "position ASC")
|
24
|
+
end
|
25
|
+
|
26
|
+
def find_page
|
27
|
+
@page = Page.find_by_link_url("/locations")
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<% form_for [:admin, @location] do |f| -%>
|
2
|
+
<%= render :partial => "/shared/admin/error_messages", :locals => {
|
3
|
+
:object => @location,
|
4
|
+
:include_object_name => true
|
5
|
+
} %>
|
6
|
+
|
7
|
+
<div class='field'>
|
8
|
+
<%= f.label :name -%>
|
9
|
+
<%= f.text_field :name, :class => 'larger widest' -%>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<div class='field'>
|
13
|
+
<%= f.label :address -%>
|
14
|
+
<%= f.text_field :address -%>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div class='field'>
|
18
|
+
<%= f.label :phone -%>
|
19
|
+
<%= f.text_field :phone -%>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<div class='field'>
|
23
|
+
<%= f.label :hours -%>
|
24
|
+
<%= f.text_field :hours -%>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<br/>
|
28
|
+
<div>
|
29
|
+
Convert address to Longitude and Latitude using <%= link_to "getlatlon.com", "http://www.getlatlon.com/", :target => '_new' %>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div class='field'>
|
33
|
+
<%= f.label :longitude -%>
|
34
|
+
<%= f.text_field :longitude -%>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<div class='field'>
|
38
|
+
<%= f.label :latitude -%>
|
39
|
+
<%= f.text_field :latitude -%>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<%= render :partial => "/shared/admin/form_actions",
|
43
|
+
:locals => {
|
44
|
+
:f => f,
|
45
|
+
:continue_editing => false,
|
46
|
+
:delete_title => t('admin.locations.location.delete'),
|
47
|
+
:delete_confirmation => t('shared.admin.delete.message', :title => @location.name)
|
48
|
+
} %>
|
49
|
+
<% end -%>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(location) -%>">
|
2
|
+
<span class='title'>
|
3
|
+
<%= location.name %>
|
4
|
+
<span class="preview"> </span>
|
5
|
+
</span>
|
6
|
+
<span class='actions'>
|
7
|
+
<%= link_to refinery_icon_tag("application_go.png"), location_url(location),
|
8
|
+
:title => t('.view_live'),
|
9
|
+
:target => "_blank" %>
|
10
|
+
<%= link_to refinery_icon_tag("application_edit.png"), edit_admin_location_path(location),
|
11
|
+
:title => t('.edit') %>
|
12
|
+
<%= link_to refinery_icon_tag("delete.png"), admin_location_path(location),
|
13
|
+
:class => "cancel confirm-delete",
|
14
|
+
:title => t('.delete'),
|
15
|
+
:'data-confirm' => t('shared.admin.delete.message',
|
16
|
+
:title => location.name
|
17
|
+
),
|
18
|
+
:'data-method' => :delete %>
|
19
|
+
</span>
|
20
|
+
</li>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => "form" %>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<div id='actions'>
|
2
|
+
<ul>
|
3
|
+
<% if Admin::LocationsController.searchable? %>
|
4
|
+
<li>
|
5
|
+
<%= render :partial => "/shared/admin/search",
|
6
|
+
:locals => {
|
7
|
+
:url => admin_locations_url
|
8
|
+
} %>
|
9
|
+
</li>
|
10
|
+
<% end %>
|
11
|
+
<li>
|
12
|
+
<%= link_to t('.create_new'), new_admin_location_url,
|
13
|
+
:class => "add_icon" %>
|
14
|
+
</li>
|
15
|
+
<% if !searching? and Location.count > 1 and Admin::LocationsController.sortable? %>
|
16
|
+
<li>
|
17
|
+
<%= link_to t('.reorder', :what => "Locations"),
|
18
|
+
admin_locations_url,
|
19
|
+
:id => "reorder_action",
|
20
|
+
:class => "reorder_icon" %>
|
21
|
+
|
22
|
+
<%= link_to t('.reorder_done', :what => "Locations"),
|
23
|
+
admin_locations_url,
|
24
|
+
:id => "reorder_action_done",
|
25
|
+
:style => "display: none;",
|
26
|
+
:class => "reorder_icon" %>
|
27
|
+
</li>
|
28
|
+
<% end %>
|
29
|
+
</ul>
|
30
|
+
</div>
|
31
|
+
<div id='records'>
|
32
|
+
<% if searching? %>
|
33
|
+
<h2><%= t('shared.admin.search.results_for', :query => params[:search]) %></h2>
|
34
|
+
<% if @locations.any? %>
|
35
|
+
<%= will_paginate @locations, :previous_label => '«', :next_label => '»' %>
|
36
|
+
<ul>
|
37
|
+
<%= render :partial => "location",
|
38
|
+
:collection => @locations %>
|
39
|
+
</ul>
|
40
|
+
<%= will_paginate @locations, :previous_label => '«', :next_label => '»' %>
|
41
|
+
<% else %>
|
42
|
+
<p><%= t('shared.admin.search.no_results') %></p>
|
43
|
+
<% end %>
|
44
|
+
<% else %>
|
45
|
+
<% if @locations.any? %>
|
46
|
+
<%= will_paginate @locations,
|
47
|
+
:previous_label => '«',
|
48
|
+
:next_label => '»' %>
|
49
|
+
|
50
|
+
<%= render :partial => "sortable_list" %>
|
51
|
+
|
52
|
+
<%= will_paginate @locations,
|
53
|
+
:previous_label => '«',
|
54
|
+
:next_label => '»' %>
|
55
|
+
<% else %>
|
56
|
+
<p>
|
57
|
+
<strong>
|
58
|
+
<%= t('.no_items_yet') %>
|
59
|
+
</strong>
|
60
|
+
</p>
|
61
|
+
<% end %>
|
62
|
+
<% end %>
|
63
|
+
</div>
|
64
|
+
<%= render :partial => "/shared/admin/make_sortable",
|
65
|
+
:locals => {
|
66
|
+
:tree => false
|
67
|
+
} if !searching? and Location.count > 1 %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => "form" %>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<%= stylesheet_link_tag "locations" %>
|
2
|
+
<%= javascript_include_tag "http://maps.google.com/maps?file=api&v=2&sensor=false&key=ADD_YOUR_KEY_HERE", "http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/src/markermanager.js" %>
|
3
|
+
<script type="text/javascript">
|
4
|
+
var markers = [];
|
5
|
+
var map;
|
6
|
+
<% @locations.each_with_index do |location, i| %>
|
7
|
+
$('#location_link_<%=i%>').live('click', function() {
|
8
|
+
markers[<%=i%>].openInfoWindowHtml(markers[<%=i%>].descr);
|
9
|
+
map.panTo(new GLatLng(<%=location.latitude%>,<%=location.longitude%>));
|
10
|
+
});
|
11
|
+
<% end %>
|
12
|
+
window.onload = function initialize() {
|
13
|
+
if (GBrowserIsCompatible()) {
|
14
|
+
map = new GMap2(document.getElementById("map_canvas"));
|
15
|
+
map.setCenter(new GLatLng(37.8046,-122.2703), 9);
|
16
|
+
map.setUIToDefault();
|
17
|
+
var mgr = new MarkerManager(map);
|
18
|
+
var icn = new GIcon();
|
19
|
+
icn.image = "/images/pointer.png";
|
20
|
+
icn.size = new GSize(21,34);
|
21
|
+
icn.iconAnchor = new GPoint(10,34);
|
22
|
+
icn.infoWindowAnchor = new GPoint(10,0);
|
23
|
+
icn.shadow = "/images/shadow.png";
|
24
|
+
icn.shadow_size = (37,34);
|
25
|
+
<% @locations.each_with_index do |location, i| %>
|
26
|
+
var marker = new GMarker(new GLatLng(<%= location.latitude %>,<%= location.longitude %>), {icon:icn, click: true});
|
27
|
+
marker.descr = "<p class='gmap'><span class='gtitle'><%= location.name %></span><br /><%= location.address %><br /><%= location.phone %><br /><%= location.hours %></p>"
|
28
|
+
GEvent.addListener(marker, "click", function(){this.openInfoWindowHtml(this.descr);});
|
29
|
+
mgr.addMarker(marker, 1);
|
30
|
+
markers[<%=i%>] = marker;
|
31
|
+
delete marker;
|
32
|
+
<% end %>
|
33
|
+
mgr.refresh();
|
34
|
+
}
|
35
|
+
};
|
36
|
+
</script>
|
37
|
+
|
38
|
+
<% content_for :body_content_left do %>
|
39
|
+
<div id="map_canvas" style="width: 610px; height: 550px; margin-left: 10px;"></div>
|
40
|
+
<% end %>
|
41
|
+
|
42
|
+
<% content_for :body_content_right do %>
|
43
|
+
<% @locations.each_with_index do |location, i| %>
|
44
|
+
<div id="location_link_<%=i%>" class="location_link" style="margin-bottom: 10px;">
|
45
|
+
<%= location.name %><br/><%= location.address %>
|
46
|
+
</div>
|
47
|
+
<% end %>
|
48
|
+
<% end %>
|
49
|
+
|
50
|
+
<%= render :partial => "/shared/content_page" %>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<% content_for :body_content_title do %>
|
2
|
+
<%= @location.name %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<% content_for :body_content_left do %>
|
6
|
+
|
7
|
+
<div>
|
8
|
+
<h3>Name</h3>
|
9
|
+
<%=raw @location.name %>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<div>
|
13
|
+
<h3>Address</h3>
|
14
|
+
<%=raw @location.address %>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div>
|
18
|
+
<h3>Phone</h3>
|
19
|
+
<%=raw @location.phone %>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<div>
|
23
|
+
<h3>Hours</h3>
|
24
|
+
<%=raw @location.hours %>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div>
|
28
|
+
<h3>Longitude</h3>
|
29
|
+
<%=raw @location.longitude %>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div>
|
33
|
+
<h3>Latitude</h3>
|
34
|
+
<%=raw @location.latitude %>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<% end %>
|
38
|
+
|
39
|
+
<% content_for :body_content_right do %>
|
40
|
+
<h2><%= t('.other') %></h2>
|
41
|
+
<ul id="locations">
|
42
|
+
<% @locations.each do |location| %>
|
43
|
+
<li>
|
44
|
+
<%= link_to location.name, location_url(location) %>
|
45
|
+
</li>
|
46
|
+
<% end %>
|
47
|
+
</ul>
|
48
|
+
<% end %>
|
49
|
+
|
50
|
+
<%= render :partial => "/shared/content_page" %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
en:
|
2
|
+
shared:
|
3
|
+
admin:
|
4
|
+
image_picker:
|
5
|
+
image: image
|
6
|
+
plugins:
|
7
|
+
locations:
|
8
|
+
title: Locations
|
9
|
+
admin:
|
10
|
+
locations:
|
11
|
+
index:
|
12
|
+
create_new: Create a new Location
|
13
|
+
reorder: Reorder Locations
|
14
|
+
reorder_done: Done Reordering Locations
|
15
|
+
sorry_no_results: Sorry! There are no results found.
|
16
|
+
no_items_yet: There are no Locations yet. Click "Create a new Location" to add your first location.
|
17
|
+
location:
|
18
|
+
view_live: View this location live <br/><em>(opens in a new window)</em>
|
19
|
+
edit: Edit this location
|
20
|
+
delete: Remove this location forever
|
21
|
+
locations:
|
22
|
+
show:
|
23
|
+
other: Other Locations
|
@@ -0,0 +1,19 @@
|
|
1
|
+
nb:
|
2
|
+
plugins:
|
3
|
+
locations:
|
4
|
+
title: Locations
|
5
|
+
admin:
|
6
|
+
locations:
|
7
|
+
index:
|
8
|
+
create_new: Lag en ny Location
|
9
|
+
reorder: Endre rekkefølgen på Locations
|
10
|
+
reorder_done: Ferdig å endre rekkefølgen Locations
|
11
|
+
sorry_no_results: Beklager! Vi fant ikke noen resultater.
|
12
|
+
no_items_yet: Det er ingen Locations enda. Klikk på "Lag en ny Location" for å legge til din første location.
|
13
|
+
location:
|
14
|
+
view_live: Vis hvordan denne location ser ut offentlig <br/><em>(åpner i et nytt vindu)</em>
|
15
|
+
edit: Rediger denne location
|
16
|
+
delete: Fjern denne location permanent
|
17
|
+
locations:
|
18
|
+
show:
|
19
|
+
other: Andre Locations
|
@@ -0,0 +1,19 @@
|
|
1
|
+
nl:
|
2
|
+
plugins:
|
3
|
+
locations:
|
4
|
+
title: Locations
|
5
|
+
admin:
|
6
|
+
locations:
|
7
|
+
index:
|
8
|
+
create_new: Maak een nieuwe Location
|
9
|
+
reorder: Wijzig de volgorde van de Locations
|
10
|
+
reorder_done: Klaar met het wijzingen van de volgorde van de Locations
|
11
|
+
sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
|
12
|
+
no_items_yet: Er zijn nog geen Locations. Druk op 'Maak een nieuwe Location' om de eerste aan te maken.
|
13
|
+
location:
|
14
|
+
view_live: Bekijk deze location op de website <br/><em>(opent een nieuw venster)</em>
|
15
|
+
edit: Bewerk deze location
|
16
|
+
delete: Verwijder deze location voor eeuwig
|
17
|
+
locations:
|
18
|
+
show:
|
19
|
+
other: Andere Locations
|
data/config/routes.rb
ADDED
data/lib/locations.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'refinery'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
module Locations
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
initializer "static assets" do |app|
|
7
|
+
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
8
|
+
end
|
9
|
+
|
10
|
+
config.after_initialize do
|
11
|
+
Refinery::Plugin.register do |plugin|
|
12
|
+
plugin.name = "locations"
|
13
|
+
plugin.activity = {:class => Location,
|
14
|
+
:title => 'name'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: refinerycms-locations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- chaunce
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-01-26 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Ruby on Rails Locations engine for Refinery CMS
|
15
|
+
email:
|
16
|
+
- chaunce.slc@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/generators/refinerycms_locations_generator.rb
|
22
|
+
- lib/locations.rb
|
23
|
+
- lib/tasks/locations.rake
|
24
|
+
- config/locales/en.yml
|
25
|
+
- config/locales/nb.yml
|
26
|
+
- config/locales/nl.yml
|
27
|
+
- config/routes.rb
|
28
|
+
- app/controllers/admin/locations_controller.rb
|
29
|
+
- app/controllers/locations_controller.rb
|
30
|
+
- app/models/location.rb
|
31
|
+
- app/views/admin/locations/_form.html.erb
|
32
|
+
- app/views/admin/locations/_location.html.erb
|
33
|
+
- app/views/admin/locations/_sortable_list.html.erb
|
34
|
+
- app/views/admin/locations/edit.html.erb
|
35
|
+
- app/views/admin/locations/index.html.erb
|
36
|
+
- app/views/admin/locations/new.html.erb
|
37
|
+
- app/views/locations/index.html.erb
|
38
|
+
- app/views/locations/show.html.erb
|
39
|
+
homepage: https://github.com/chaunce/refinerycms-locations
|
40
|
+
licenses: []
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.8.24
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: Ruby on Rails Locations engine for Refinery CMS
|
63
|
+
test_files: []
|