refinerycms-location_explorer 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/refinery/location_explorer/locations_map.coffee +43 -0
- data/app/assets/javascripts/refinery/location_explorer/map_picker.coffee +28 -0
- data/app/assets/javascripts/refinery/location_explorer/vendor/gmaps.js +1091 -0
- data/app/assets/stylesheets/refinery/location_explorer.css.scss +70 -0
- data/app/assets/stylesheets/refinery/location_explorer/map_picker.css.scss +26 -0
- data/app/controllers/refinery/location_explorer/admin/locations_controller.rb +12 -0
- data/app/controllers/refinery/location_explorer/locations_controller.rb +44 -0
- data/app/models/refinery/location_explorer/location.rb +41 -0
- data/app/models/refinery/location_explorer/owner_decorator.rb +46 -0
- data/app/views/refinery/location_explorer/admin/locations/_actions.html.erb +25 -0
- data/app/views/refinery/location_explorer/admin/locations/_form.html.erb +27 -0
- data/app/views/refinery/location_explorer/admin/locations/_location.html.erb +20 -0
- data/app/views/refinery/location_explorer/admin/locations/_locations.html.erb +2 -0
- data/app/views/refinery/location_explorer/admin/locations/_map.html.erb +29 -0
- data/app/views/refinery/location_explorer/admin/locations/_records.html.erb +18 -0
- data/app/views/refinery/location_explorer/admin/locations/_sortable_list.html.erb +5 -0
- data/app/views/refinery/location_explorer/admin/locations/edit.html.erb +1 -0
- data/app/views/refinery/location_explorer/admin/locations/index.html.erb +7 -0
- data/app/views/refinery/location_explorer/admin/locations/new.html.erb +1 -0
- data/app/views/refinery/location_explorer/locations/index.html.haml +30 -0
- data/app/views/refinery/location_explorer/locations/show.html.haml +16 -0
- data/config/locales/en.yml +30 -0
- data/config/locales/es.yml +31 -0
- data/config/locales/fr.yml +30 -0
- data/config/locales/nb.yml +30 -0
- data/config/locales/nl.yml +30 -0
- data/config/routes.rb +17 -0
- data/db/migrate/1_create_location_explorer_locations.rb +33 -0
- data/db/seeds.rb +25 -0
- data/lib/generators/refinery/location_explorer_generator.rb +23 -0
- data/lib/generators/refinery/templates/config/initializers/refinery/location_explorer.rb.erb +4 -0
- data/lib/refinery/location_explorer.rb +22 -0
- data/lib/refinery/location_explorer/configuration.rb +9 -0
- data/lib/refinery/location_explorer/engine.rb +27 -0
- data/lib/refinerycms-location_explorer.rb +3 -0
- data/lib/tasks/refinery/locations.rake +13 -0
- data/readme.md +51 -0
- metadata +148 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
.refinerycms-locations {
|
2
|
+
#locations {
|
3
|
+
#locations_index_map {
|
4
|
+
border: 2px solid black;
|
5
|
+
height: 500px;
|
6
|
+
$radius: 10px;
|
7
|
+
-webkit-border-radius: $radius;
|
8
|
+
-moz-border-radius: $radius;
|
9
|
+
border-radius: $radius;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
.map_sidebar {
|
14
|
+
position: relative;
|
15
|
+
|
16
|
+
.arrow {
|
17
|
+
border: 15px solid transparent;
|
18
|
+
border-right: 15px solid black;
|
19
|
+
width: 0px;
|
20
|
+
position: absolute;
|
21
|
+
top: 10px;
|
22
|
+
left: -30px;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
.location_preview {
|
27
|
+
border: 2px solid #000000;
|
28
|
+
background-color: #1c1714;
|
29
|
+
color: #CCC;
|
30
|
+
|
31
|
+
h2.location_name {
|
32
|
+
color: #FFFFFF !important;
|
33
|
+
margin: 0;
|
34
|
+
background-color: black;
|
35
|
+
padding: 10px;
|
36
|
+
}
|
37
|
+
|
38
|
+
.location_content {
|
39
|
+
padding: 10px;
|
40
|
+
|
41
|
+
a {
|
42
|
+
color: #FFF;
|
43
|
+
}
|
44
|
+
|
45
|
+
.description_preview {
|
46
|
+
margin-bottom: 1em;
|
47
|
+
}
|
48
|
+
|
49
|
+
img.location_image {
|
50
|
+
border: 1px solid black !important;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
}
|
55
|
+
|
56
|
+
#location_show {
|
57
|
+
#submenu {
|
58
|
+
display: none;
|
59
|
+
}
|
60
|
+
h1#body_content_title {
|
61
|
+
height: 26px;
|
62
|
+
line-height: 26px;
|
63
|
+
margin-bottom: 20px;
|
64
|
+
}
|
65
|
+
#submenu_container {
|
66
|
+
margin-top: 46px;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#map-picker {
|
2
|
+
height: 400px;
|
3
|
+
width: 600px;
|
4
|
+
border: 1px solid #666;
|
5
|
+
margin: 0 10px 5px 0;
|
6
|
+
float: left;
|
7
|
+
}
|
8
|
+
|
9
|
+
.formtastic {
|
10
|
+
.page_part aside {
|
11
|
+
width: 335px;
|
12
|
+
margin-left: 610px;
|
13
|
+
|
14
|
+
fieldset {
|
15
|
+
width: 335px;
|
16
|
+
|
17
|
+
ol {
|
18
|
+
width: 335px;
|
19
|
+
|
20
|
+
input {
|
21
|
+
width: 98%;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Refinery
|
2
|
+
module LocationExplorer
|
3
|
+
class LocationsController < ::ApplicationController
|
4
|
+
|
5
|
+
before_filter :find_all_locations
|
6
|
+
before_filter :find_page
|
7
|
+
|
8
|
+
def index
|
9
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
10
|
+
# by swapping @page for @location in the line below:
|
11
|
+
present(@page)
|
12
|
+
end
|
13
|
+
|
14
|
+
def show
|
15
|
+
@location = decorate_location(Location.find(params[:id]))
|
16
|
+
|
17
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
18
|
+
# by swapping @page for @location in the line below:
|
19
|
+
present(@page)
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def decorate_location(location)
|
25
|
+
location.owner ? OwnerDecorator.new(location) : location
|
26
|
+
end
|
27
|
+
|
28
|
+
def decorate_locations(locations)
|
29
|
+
locations.map do |location|
|
30
|
+
decorate_location(location)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def find_all_locations
|
35
|
+
@locations = decorate_locations(Location.order('position ASC'))
|
36
|
+
end
|
37
|
+
|
38
|
+
def find_page
|
39
|
+
@page = ::Refinery::Page.where(:link_url => "/location_explorer").first
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Refinery
|
2
|
+
module LocationExplorer
|
3
|
+
class Location < Refinery::Core::BaseModel
|
4
|
+
self.table_name = 'refinery_locations'
|
5
|
+
|
6
|
+
attr_accessible :name, :description, :latitude, :longitude, :position, :owner, :colour_override
|
7
|
+
|
8
|
+
acts_as_indexed :fields => [:name, :description]
|
9
|
+
|
10
|
+
belongs_to :owner, :polymorphic => true
|
11
|
+
has_many_page_images
|
12
|
+
|
13
|
+
delegate :colour, :name, :description, :to => :owner, :allow_nil => true, :prefix => :owner
|
14
|
+
|
15
|
+
def description_preview
|
16
|
+
if description
|
17
|
+
matches = description.match(/<p>(.*)<\/p>/)
|
18
|
+
text = matches ? matches[1] : description
|
19
|
+
text.truncate(200)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def latlng
|
24
|
+
[latitude, longitude] if latitude && longitude
|
25
|
+
end
|
26
|
+
|
27
|
+
def preview_image_url
|
28
|
+
image = images.first
|
29
|
+
image.thumbnail("253x160#c").url if image
|
30
|
+
end
|
31
|
+
|
32
|
+
def colour
|
33
|
+
colour_override
|
34
|
+
end
|
35
|
+
|
36
|
+
def detail_url
|
37
|
+
"/locations/#{to_param}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Refinery
|
2
|
+
module LocationExplorer
|
3
|
+
class OwnerDecorator
|
4
|
+
def self.use_owner_attribute(*keys)
|
5
|
+
keys.each do |key|
|
6
|
+
define_method(key) do
|
7
|
+
owner.send(key) || @subject.send(key)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
use_owner_attribute :name, :description, :preview_image_url, :colour, :description_preview
|
13
|
+
|
14
|
+
def initialize(subject)
|
15
|
+
@subject = subject
|
16
|
+
end
|
17
|
+
|
18
|
+
def method_missing(sym, *args, &block)
|
19
|
+
@subject.send sym, *args, &block
|
20
|
+
end
|
21
|
+
|
22
|
+
def as_json(options = {})
|
23
|
+
results = {}
|
24
|
+
methods = [:latitude, :longitude, :name] + (options[:methods] || [])
|
25
|
+
methods.each do |method|
|
26
|
+
results[method.to_s] = send(method)
|
27
|
+
end
|
28
|
+
results.as_json
|
29
|
+
end
|
30
|
+
|
31
|
+
def detail_url
|
32
|
+
"/#{owner_resource_name}/#{owner.to_param}"
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def owner_resource_name
|
38
|
+
owner.class.model_name.split('::').last.underscore.pluralize
|
39
|
+
end
|
40
|
+
|
41
|
+
def owner
|
42
|
+
@subject.owner
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<ul>
|
2
|
+
<% if ::Refinery::LocationExplorer::Admin::LocationsController.searchable? %>
|
3
|
+
<li>
|
4
|
+
<%= render '/refinery/admin/search', :url => refinery.location_explorer_admin_locations_path %>
|
5
|
+
</li>
|
6
|
+
<% end %>
|
7
|
+
<li>
|
8
|
+
<%= link_to t('.create_new'), refinery.new_location_explorer_admin_location_path,
|
9
|
+
:class => "add_icon" %>
|
10
|
+
</li>
|
11
|
+
<% if !searching? && ::Refinery::LocationExplorer::Admin::LocationsController.sortable? && ::Refinery::LocationExplorer::Location.any? %>
|
12
|
+
<li>
|
13
|
+
<%= link_to t('.reorder', :what => "Locations"),
|
14
|
+
refinery.location_explorer_admin_locations_path,
|
15
|
+
:id => "reorder_action",
|
16
|
+
:class => "reorder_icon" %>
|
17
|
+
|
18
|
+
<%= link_to t('.reorder_done', :what => "Locations"),
|
19
|
+
refinery.location_explorer_admin_locations_path,
|
20
|
+
:id => "reorder_action_done",
|
21
|
+
:style => "display: none;",
|
22
|
+
:class => "reorder_icon" %>
|
23
|
+
</li>
|
24
|
+
<% end %>
|
25
|
+
</ul>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%= semantic_form_for [refinery, :location_explorer_admin, @location] do |f| -%>
|
2
|
+
<%= render '/refinery/admin/error_messages',
|
3
|
+
:object => @location,
|
4
|
+
:include_object_name => true %>
|
5
|
+
|
6
|
+
<%= f.inputs do %>
|
7
|
+
<%= f.input :name, :input_html => {:class => 'larger widest'} %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<%= tabbed_fieldsets f, [
|
11
|
+
Refinery::Pages::Tab.new(:name => 'map', :partial => '/refinery/location_explorer/admin/locations/map'),
|
12
|
+
:description,
|
13
|
+
Refinery::Pages::Tab.new(:name => 'images', :partial => '/refinery/admin/pages/tabs/images')
|
14
|
+
] %>
|
15
|
+
|
16
|
+
<%= render '/refinery/admin/form_actions', :f => f,
|
17
|
+
:continue_editing => false,
|
18
|
+
:delete_title => t('delete', :scope => 'refinery.locations.admin.locations.location'),
|
19
|
+
:delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @location.name) %>
|
20
|
+
<% end -%>
|
21
|
+
<% content_for :javascripts do %>
|
22
|
+
<script>
|
23
|
+
$(document).ready(function(){
|
24
|
+
page_options.init(false, '', '');
|
25
|
+
});
|
26
|
+
</script>
|
27
|
+
<% 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
|
+
|
5
|
+
</span>
|
6
|
+
<span class='actions'>
|
7
|
+
|
8
|
+
<%= link_to refinery_icon_tag("application_go.png"), refinery.location_explorer_location_path(location),
|
9
|
+
:title => t('.view_live_html'),
|
10
|
+
:target => "_blank" %>
|
11
|
+
|
12
|
+
<%= link_to refinery_icon_tag("application_edit.png"), refinery.edit_location_explorer_admin_location_path(location),
|
13
|
+
:title => t('.edit') %>
|
14
|
+
<%= link_to refinery_icon_tag("delete.png"), refinery.location_explorer_admin_location_path(location),
|
15
|
+
:class => "cancel confirm-delete",
|
16
|
+
:title => t('.delete'),
|
17
|
+
:confirm => t('message', :scope => 'refinery.admin.delete', :title => location.name),
|
18
|
+
:method => :delete %>
|
19
|
+
</span>
|
20
|
+
</li>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<div class="wym_skin_refinery page_part">
|
2
|
+
<div class="wym_box field">
|
3
|
+
<div id="map-picker">
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<aside>
|
7
|
+
<%= f.inputs do %>
|
8
|
+
<%= f.input :latitude, :input_html => {:id => 'location_latitude'} %>
|
9
|
+
<%= f.input :longitude, :input_html => {:id => 'location_longitude'} %>
|
10
|
+
<% end %>
|
11
|
+
</aside>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<% content_for :stylesheets, stylesheet_link_tag('refinery/location_explorer/map_picker.css') %>
|
16
|
+
<% content_for :javascripts do %>
|
17
|
+
<%= javascript_include_tag('http://maps.google.com/maps/api/js?sensor=true') %>
|
18
|
+
<%= javascript_include_tag('refinery/location_explorer/vendor/gmaps.js') %>
|
19
|
+
<%= javascript_include_tag('refinery/location_explorer/map_picker') %>
|
20
|
+
|
21
|
+
<script type="text/javascript">
|
22
|
+
$(document).ready(function(){
|
23
|
+
var map_picker = new Application.MapPicker(
|
24
|
+
'#map-picker',
|
25
|
+
<%= Refinery::LocationExplorer.config.map_center.to_json.html_safe %>,
|
26
|
+
<%= f.object.latlng.to_json.html_safe %>);
|
27
|
+
});
|
28
|
+
</script>
|
29
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% if searching? %>
|
2
|
+
<h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
|
3
|
+
<% end %>
|
4
|
+
<div class='pagination_container'>
|
5
|
+
<% if @locations.any? %>
|
6
|
+
<%= render 'locations' %>
|
7
|
+
<% else %>
|
8
|
+
<p>
|
9
|
+
<% unless searching? %>
|
10
|
+
<strong>
|
11
|
+
<%= t('.no_items_yet') %>
|
12
|
+
</strong>
|
13
|
+
<% else %>
|
14
|
+
<%= t('no_results', :scope => 'refinery.admin.search') %>
|
15
|
+
<% end %>
|
16
|
+
</p>
|
17
|
+
<% end %>
|
18
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<section id='records'>
|
2
|
+
<%= render 'records' %>
|
3
|
+
</section>
|
4
|
+
<aside id='actions'>
|
5
|
+
<%= render 'actions' %>
|
6
|
+
</aside>
|
7
|
+
<%= render '/refinery/admin/make_sortable', :tree => false if !searching? and ::Refinery::LocationExplorer::Admin::LocationsController.sortable? and ::Refinery::LocationExplorer::Location.count > 1 %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
- content_for :body_content_left do
|
2
|
+
%article#locations
|
3
|
+
#locations_index_map
|
4
|
+
|
5
|
+
- content_for :body_content_right do
|
6
|
+
- location = @locations.first
|
7
|
+
- if location
|
8
|
+
#location_preview.map_sidebar{:style => "display: none"}
|
9
|
+
.arrow
|
10
|
+
.location_preview
|
11
|
+
%h2.location_name
|
12
|
+
.location_content
|
13
|
+
.description_preview
|
14
|
+
.image_container
|
15
|
+
= link_to "more details", '#', :class => 'more_details'
|
16
|
+
|
17
|
+
- content_for :javascripts do
|
18
|
+
= javascript_include_tag('http://maps.google.com/maps/api/js?sensor=true')
|
19
|
+
= javascript_include_tag('refinery/location_explorer/vendor/gmaps.js')
|
20
|
+
= javascript_include_tag('refinery/location_explorer/locations_map')
|
21
|
+
:javascript
|
22
|
+
$(document).ready(function(){
|
23
|
+
var locations_map = new Application.LocationsMap('#locations_index_map', #{Refinery::LocationExplorer.config.map_center});
|
24
|
+
locations_map.addLocations(#{@locations.to_json(:methods => [:description_preview, :preview_image_url, :colour, :detail_url]).html_safe});
|
25
|
+
});
|
26
|
+
|
27
|
+
.refinerycms-locations
|
28
|
+
= render '/refinery/content_page'
|
29
|
+
|
30
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
- content_for :body_content_title do
|
2
|
+
= @location.name
|
3
|
+
|
4
|
+
- content_for :body do
|
5
|
+
%article.location
|
6
|
+
= render 'refinery/jquery_gallery/gallery', :page => @location
|
7
|
+
|
8
|
+
%section.description
|
9
|
+
- if @location.description.present?
|
10
|
+
%h3 Description
|
11
|
+
=raw @location.description
|
12
|
+
|
13
|
+
|
14
|
+
.refinerycms-locations
|
15
|
+
#location_show
|
16
|
+
= render '/refinery/content_page'
|