diff --git a/app/assets/images/space-p1.png b/app/assets/images/space-p1.png new file mode 100644 index 0000000..cbce3a9 Binary files /dev/null and b/app/assets/images/space-p1.png differ diff --git a/app/assets/images/space-p2.png b/app/assets/images/space-p2.png new file mode 100644 index 0000000..c3541c0 Binary files /dev/null and b/app/assets/images/space-p2.png differ diff --git a/app/assets/stylesheets/space-frontend.scss b/app/assets/stylesheets/space-frontend.scss index 537dee1..dbf57ba 100644 --- a/app/assets/stylesheets/space-frontend.scss +++ b/app/assets/stylesheets/space-frontend.scss @@ -4,7 +4,19 @@ .overlay { position: absolute; } - +.s-space.show-space .selection-box-label.absolute-center{ + display: none; +} +.s-space.show-space .selection-box-label.absolute-center.active{ + display: block; + position: absolute; + bottom: 110%; + left: 100%; + background: #2196F3; + color: white; + width: 150%; + padding: 0.2em; +} #full-layout-canvas { text-align: center; position: relative; diff --git a/app/controllers/spaces_controller.rb b/app/controllers/spaces_controller.rb index 073fd72..58208e2 100644 --- a/app/controllers/spaces_controller.rb +++ b/app/controllers/spaces_controller.rb @@ -1,120 +1,120 @@ class SpacesController < ApplicationController - def index - params = OrbitHelper.params - page = Page.where(:page_id => params[:page_id]).first - buildings = Building.filter_by_categories.collect do |building| - floors = building.floors.desc(:title).collect do |floor| - image = (!floor.frontend_image.thumb.url.nil? ? floor.frontend_image.thumb.url : "/assets/default-floor.jpg") - link = floor.layout.nil? ? (floor.floor_units.empty? ? "#" : "/#{I18n.locale.to_s}#{page.url}/#{floor.floor_units.first.to_param}?method=unit") : OrbitHelper.url_to_show(floor.to_param) - { - "floor-title" => floor.title, - "floor-image" => image, - "alt-title" => floor.title, - "link_to_show" => link - } - end - { - "building-title" => building.title, - "building-image" => building.image.url, - "alt-title" => building.title, - "floors" => floors - } - end + def index + params = OrbitHelper.params + page = Page.where(:page_id => params[:page_id]).first + buildings = Building.filter_by_categories.collect do |building| + floors = building.floors.desc(:title).collect do |floor| + image = (!floor.frontend_image.thumb.url.nil? ? floor.frontend_image.thumb.url : "/assets/default-floor.jpg") + link = floor.layout.nil? ? (floor.floor_units.empty? ? "#" : "/#{I18n.locale.to_s}#{page.url}/#{floor.floor_units.first.to_param}?method=unit") : OrbitHelper.url_to_show(floor.to_param) + { + "floor-title" => floor.title, + "floor-image" => image, + "alt-title" => floor.title, + "link_to_show" => link + } + end + { + "building-title" => building.title, + "building-image" => building.image.url, + "alt-title" => building.title, + "floors" => floors + } + end - { - "buildings" => buildings, - "extras" => { + { + "buildings" => buildings, + "extras" => { - } - } - end + } + } + end - def show - params = OrbitHelper.params - floor = Floor.where(:uid => params[:uid]).first rescue nil - thumb_image = (!floor.frontend_image.thumb.url.nil? ? floor.frontend_image.thumb.url : "/assets/default-floor.jpg") - image = (!floor.frontend_image.mobile.url.nil? ? floor.frontend_image.mobile.url : "#") - page = Page.where(:page_id => params[:page_id]).first + def show + params = OrbitHelper.params + floor = Floor.where(:uid => params[:uid]).first rescue nil + thumb_image = (!floor.frontend_image.thumb.url.nil? ? floor.frontend_image.thumb.url : "/assets/default-floor.jpg") + image = (!floor.frontend_image.mobile.url.nil? ? floor.frontend_image.mobile.url : "#") + page = Page.where(:page_id => params[:page_id]).first - { - "floor-title" => floor.title, - "floor-frontend-image-thumb" => thumb_image, - "floor-frontend-image" => image, - "image-alt" => floor.title, - "building-back-link" => "/" + I18n.locale.to_s + page.url, - "floor-layout" => floor.layout, - "floor-id" => floor.id.to_s, - "page-id" => page.page_id - } - end + { + "floor-title" => floor.title, + "floor-frontend-image-thumb" => thumb_image, + "floor-frontend-image" => image, + "image-alt" => floor.title, + "building-back-link" => "/" + I18n.locale.to_s + page.url, + "floor-layout" => floor.layout, + "floor-id" => floor.id.to_s, + "page-id" => page.page_id + } + end - def floor_units - floor = Floor.find(params[:floor_id]) rescue nil - page = Page.where(:page_id => params[:page_id]).first rescue nil - units = [] - if !floor.nil? - floor.floor_units.each do |unit| - url = "/#{I18n.locale.to_s}#{page.url}/#{unit.to_param}?method=unit" rescue "#" - units << { - "id" => unit.id.to_s, - "url" => url - } - end - end + def floor_units + floor = Floor.find(params[:floor_id]) rescue nil + page = Page.where(:page_id => params[:page_id]).first rescue nil + units = [] + if !floor.nil? + floor.floor_units.each do |unit| + url = "/#{I18n.locale.to_s}#{page.url}/#{unit.to_param}?method=unit" rescue "#" + units << { + "id" => unit.id.to_s, + "url" => url + } + end + end - render :json => {"success" => true, "units" => units} - end + render :json => {"success" => true, "units" => units} + end - def floor_sub_units - unit = FloorUnit.find(params[:unit_id]) rescue nil - page = Page.where(:page_id => params[:page_id]).first rescue nil - units = [] - if !unit.nil? - unit.floor_sub_units.each do |subunit| - url = subunit.floor_sub_unit_images.empty? ? "#" : "/#{I18n.locale.to_s}#{page.url}/#{subunit.to_param}?method=showcase&layout=false" rescue "#" - units << { - "id" => subunit.id.to_s, - "url" => url - } - end - end + def floor_sub_units + unit = FloorUnit.find(params[:unit_id]) rescue nil + page = Page.where(:page_id => params[:page_id]).first rescue nil + units = [] + if !unit.nil? + unit.floor_sub_units.each do |subunit| + url = subunit.floor_sub_unit_images.empty? ? "#" : "/#{I18n.locale.to_s}#{page.url}/#{subunit.to_param}?method=showcase&layout=false" rescue "#" + units << { + "id" => subunit.id.to_s, + "url" => url + } + end + end - render :json => {"success" => true, "sub_units" => units} - end + render :json => {"success" => true, "sub_units" => units} + end - def unit - params = OrbitHelper.params - unit = FloorUnit.where(:uid => params[:uid]).first rescue nil - page = Page.where(:page_id => params[:page_id]).first - layout = unit.layout.nil? ? "
" : unit.layout - backlink = unit.floor.layout.nil? ? "/" + I18n.locale.to_s + page.url : "/" + I18n.locale.to_s + page.url + "/#{unit.floor.to_param}" - { - "unit-title" => unit.title, - "floor-back-link" => backlink, - "unit-layout" => layout, - "unit-id" => unit.id.to_s, - "page-id" => page.page_id - } - end + def unit + params = OrbitHelper.params + unit = FloorUnit.where(:uid => params[:uid]).first rescue nil + page = Page.where(:page_id => params[:page_id]).first + layout = unit.layout.nil? ? "
" : unit.layout + backlink = unit.floor.layout.nil? ? "/" + I18n.locale.to_s + page.url : "/" + I18n.locale.to_s + page.url + "/#{unit.floor.to_param}" + { + "unit-title" => unit.title, + "floor-back-link" => backlink, + "unit-layout" => layout, + "unit-id" => unit.id.to_s, + "page-id" => page.page_id + } + end - def showcase - params = OrbitHelper.params - unit = FloorSubUnit.where(:uid => params[:uid]).first rescue nil - images = [] - unit.floor_sub_unit_images.each do |image| - images << { - "image-thumb-url" => image.image.thumb.url, - "image-url" => image.image.url, - "alt-image" => unit.title - } - end - { - "unit-images" => images, - "extras" => { - "unit-title" => unit.title - } - } - end + def showcase + params = OrbitHelper.params + unit = FloorSubUnit.where(:uid => params[:uid]).first rescue nil + images = [] + unit.floor_sub_unit_images.each do |image| + images << { + "image-thumb-url" => image.image.thumb.url, + "image-url" => image.image.url, + "alt-image" => unit.title + } + end + { + "unit-images" => images, + "extras" => { + "unit-title" => unit.title + } + } + end end diff --git a/modules/space/info.json b/modules/space/info.json new file mode 100644 index 0000000..2f255a2 --- /dev/null +++ b/modules/space/info.json @@ -0,0 +1,12 @@ +{ + "frontend": [ + { + "filename" : "space_index1", + "name" : { + "zh_tw" : "1. 卡片式 ( 模組標題, 大樓, 樓層)", + "en" : "1. Card-like layout ( widget-title, buildings, floors )" + }, + "thumbnail" : "thumb.png" + } + ] +} \ No newline at end of file diff --git a/modules/space/show.html.erb b/modules/space/show.html.erb new file mode 100644 index 0000000..3ea406b --- /dev/null +++ b/modules/space/show.html.erb @@ -0,0 +1,93 @@ +
+

{{floor-title}}

+
+ {{floor-layout}} +
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/modules/space/showcase.html.erb b/modules/space/showcase.html.erb new file mode 100644 index 0000000..7ddfb9b --- /dev/null +++ b/modules/space/showcase.html.erb @@ -0,0 +1,60 @@ + +
+
+

{{unit-title}}

+
+
+ +
+
+ +
+
+
+ + {{alt-image}} + +
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/modules/space/space_index1.html.erb b/modules/space/space_index1.html.erb new file mode 100644 index 0000000..65dcf62 --- /dev/null +++ b/modules/space/space_index1.html.erb @@ -0,0 +1,89 @@ +
+ + +
+ +
+ +
+ + diff --git a/modules/space/thumbs/thumb.png b/modules/space/thumbs/thumb.png new file mode 100644 index 0000000..266af56 Binary files /dev/null and b/modules/space/thumbs/thumb.png differ diff --git a/modules/space/unit.html.erb b/modules/space/unit.html.erb new file mode 100644 index 0000000..1a16f89 --- /dev/null +++ b/modules/space/unit.html.erb @@ -0,0 +1,197 @@ +
+
+
+
+

{{unit-title}}

+
+ {{unit-layout}} +
+ +
+ +
+
+
+ + \ No newline at end of file diff --git a/space.gemspec b/space.gemspec index 2681450..7707796 100644 --- a/space.gemspec +++ b/space.gemspec @@ -2,7 +2,19 @@ $:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: require "space/version" - +app_path = File.expand_path(__dir__) +template_path = ENV['PWD'] + '/app/templates' +all_template = Dir.glob(template_path+'/*/') +puts 'copying module' +all_template.each do |folder| + if folder.split('/')[-1] != 'mobile' + begin + system ('cp -r '+ app_path + '/modules/ ' + folder) + rescue + puts 'error copy' + end + end +end # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "space"