merge
This commit is contained in:
commit
e2e9ef59aa
3
Gemfile
3
Gemfile
@ -32,6 +32,9 @@ gem "devise-async"
|
|||||||
gem "passenger" , "6.0.15" , require: "phusion_passenger/rack_handler"
|
gem "passenger" , "6.0.15" , require: "phusion_passenger/rack_handler"
|
||||||
gem "bootsnap", require: false
|
gem "bootsnap", require: false
|
||||||
|
|
||||||
|
gem "opal-rails"
|
||||||
|
gem "opal-browser"
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
||||||
gem "debug", platforms: %i[ mri mingw x64_mingw ]
|
gem "debug", platforms: %i[ mri mingw x64_mingw ]
|
||||||
|
18
Gemfile.lock
18
Gemfile.lock
@ -262,8 +262,24 @@ GEM
|
|||||||
mustache
|
mustache
|
||||||
nokogiri (~> 1.7)
|
nokogiri (~> 1.7)
|
||||||
sanitize
|
sanitize
|
||||||
|
opal (1.7.2)
|
||||||
|
ast (>= 2.3.0)
|
||||||
|
parser (~> 3.0, >= 3.0.3.2)
|
||||||
|
opal-browser (0.3.3)
|
||||||
|
opal (>= 1.0, < 2.0)
|
||||||
|
paggio (>= 0.3.0)
|
||||||
|
opal-rails (2.0.2)
|
||||||
|
opal (~> 1.0)
|
||||||
|
opal-sprockets (~> 1.0)
|
||||||
|
rails (>= 6.0, < 7.1)
|
||||||
|
sprockets-rails (>= 3.0)
|
||||||
|
opal-sprockets (1.0.3)
|
||||||
|
opal (>= 1.0, < 2.0)
|
||||||
|
sprockets (~> 4.0)
|
||||||
|
tilt (>= 1.4)
|
||||||
open4 (1.3.4)
|
open4 (1.3.4)
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
|
paggio (0.3.0)
|
||||||
parser (3.2.0.0)
|
parser (3.2.0.0)
|
||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
passenger (6.0.15)
|
passenger (6.0.15)
|
||||||
@ -435,6 +451,8 @@ DEPENDENCIES
|
|||||||
kaminari
|
kaminari
|
||||||
merged!
|
merged!
|
||||||
mina
|
mina
|
||||||
|
opal-browser
|
||||||
|
opal-rails
|
||||||
passenger (= 6.0.15)
|
passenger (= 6.0.15)
|
||||||
pg (~> 1.1)
|
pg (~> 1.1)
|
||||||
pundit (~> 2.3)
|
pundit (~> 2.3)
|
||||||
|
@ -3,3 +3,4 @@
|
|||||||
//= link_tree ../../javascript .js
|
//= link_tree ../../javascript .js
|
||||||
//= link_tree ../../../vendor/javascript .js
|
//= link_tree ../../../vendor/javascript .js
|
||||||
//= link_tree ../builds
|
//= link_tree ../builds
|
||||||
|
//= link_directory ../javascript .js
|
5
app/assets/javascript/opal_main.js.rb
Normal file
5
app/assets/javascript/opal_main.js.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
require "opal"
|
||||||
|
require "native"
|
||||||
|
require 'promise'
|
||||||
|
require 'browser/setup/mini'
|
||||||
|
require 'vue_r'
|
2
app/assets/javascript/vue_r.rb
Normal file
2
app/assets/javascript/vue_r.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
require "vue_r/application"
|
||||||
|
require "vue_r/mounter"
|
67
app/assets/javascript/vue_r/application.rb
Normal file
67
app/assets/javascript/vue_r/application.rb
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
module VueR
|
||||||
|
class Application
|
||||||
|
|
||||||
|
def initialize(hash)
|
||||||
|
hash.each do |k,v|
|
||||||
|
wrap_attr(k,v)
|
||||||
|
end
|
||||||
|
@effect = nil
|
||||||
|
@subscribers = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
def wrap_attr(k,v)
|
||||||
|
instance_variable_set "@#{k}" , v
|
||||||
|
define_getter(k)
|
||||||
|
define_setter(k)
|
||||||
|
end
|
||||||
|
|
||||||
|
def define_getter(k)
|
||||||
|
self.class.define_method k.to_sym do
|
||||||
|
track(k)
|
||||||
|
instance_variable_get "@#{k}".to_sym
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def define_setter(k)
|
||||||
|
self.class.define_method "#{k}=".to_sym do |new_v|
|
||||||
|
instance_variable_set "@#{k}" , new_v
|
||||||
|
trigger(k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def track( key )
|
||||||
|
puts "Tracking:#{key}-#{@effect.hash}"
|
||||||
|
return unless @effect
|
||||||
|
get_subscribers_for(key) << @effect
|
||||||
|
end
|
||||||
|
|
||||||
|
def trigger(key)
|
||||||
|
puts "Trigger:#{key}"
|
||||||
|
effects = get_subscribers_for(key)
|
||||||
|
effects.each {|effect| effect.call() }
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_subscribers_for(key)
|
||||||
|
key = key.to_sym
|
||||||
|
unless @subscribers.has_key?(key)
|
||||||
|
@subscribers[key] = Set.new
|
||||||
|
end
|
||||||
|
@subscribers[key]
|
||||||
|
end
|
||||||
|
|
||||||
|
def mount(on_class)
|
||||||
|
@mounter = Mounter.new(on_class , self)
|
||||||
|
@mounter.mount
|
||||||
|
end
|
||||||
|
|
||||||
|
def watch_effect( update_proc )
|
||||||
|
effect = Proc.new do
|
||||||
|
@effect = effect
|
||||||
|
update_proc.call
|
||||||
|
@effect = nil
|
||||||
|
end
|
||||||
|
effect.call
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
64
app/assets/javascript/vue_r/mounter.rb
Normal file
64
app/assets/javascript/vue_r/mounter.rb
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
require 'opal-parser'
|
||||||
|
|
||||||
|
module VueR
|
||||||
|
class Mounter
|
||||||
|
HANDLEBARS = /{{\s?([^}]*)\s?}}/
|
||||||
|
def initialize( id , app )
|
||||||
|
@root = $document[id]
|
||||||
|
@application = app
|
||||||
|
end
|
||||||
|
|
||||||
|
def mount
|
||||||
|
mount_Element(@root)
|
||||||
|
end
|
||||||
|
|
||||||
|
def mount_Text elem
|
||||||
|
text = elem.text
|
||||||
|
scan = text.scan(HANDLEBARS)
|
||||||
|
return unless scan.length > 0
|
||||||
|
raise "only one curly per text implemented not:#{scan.length}" if scan.length > 1
|
||||||
|
match = text.match(HANDLEBARS)
|
||||||
|
str_before = text[0 ... match.begin(0)]
|
||||||
|
str_after = text[ match.end(0) .. -1]
|
||||||
|
ruby = match[0][2 ... -2]
|
||||||
|
puts "Text: #{ruby}"
|
||||||
|
proc = Proc.new do
|
||||||
|
elem.text = str_before + @application.eval(ruby).to_s + str_after
|
||||||
|
end
|
||||||
|
@application.watch_effect(proc)
|
||||||
|
end
|
||||||
|
|
||||||
|
def mount_Element(elem)
|
||||||
|
elem.attributes.each do |name , value|
|
||||||
|
mount_attribute(elem , name) if name.start_with?("r_")
|
||||||
|
mount_event(elem , name) if name.start_with?("e_")
|
||||||
|
end
|
||||||
|
elem.children.each do |elem|
|
||||||
|
base_name = elem.class.to_s.split("::").last
|
||||||
|
send "mount_#{base_name}" , elem
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def mount_attribute(element , name)
|
||||||
|
native_name = name[2 .. -1]
|
||||||
|
ruby = element[name]
|
||||||
|
old_value = element[native_name]
|
||||||
|
puts "Attribute: #{ruby}"
|
||||||
|
proc = Proc.new do
|
||||||
|
element[native_name] = old_value + " " + @application.eval(ruby).to_s
|
||||||
|
end
|
||||||
|
@application.watch_effect(proc)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def mount_event(element , name)
|
||||||
|
native_name = name.gsub("e_" , "")
|
||||||
|
ruby = element[name]
|
||||||
|
puts "Event: #{native_name}:#{ruby}"
|
||||||
|
element.on!(native_name) do
|
||||||
|
got = @application.eval(ruby)
|
||||||
|
puts "Clicked #{got}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -11,13 +11,8 @@
|
|||||||
* It is generally better to create a new file per style scope.
|
* It is generally better to create a new file per style scope.
|
||||||
*
|
*
|
||||||
*= require_self
|
*= require_self
|
||||||
|
*= require glightbox.min
|
||||||
*/
|
*/
|
||||||
#thredded--container{
|
#thredded--container{
|
||||||
max-width: 60rem;
|
max-width: 60rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.prose{
|
|
||||||
max-width: 100%;
|
|
||||||
color: inherit;
|
|
||||||
--tw-prose-bullets: #6b7280;
|
|
||||||
}
|
|
||||||
|
1
app/assets/stylesheets/glightbox.min.css
vendored
Normal file
1
app/assets/stylesheets/glightbox.min.css
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.glightbox-container{width:100%;height:100%;position:fixed;top:0;left:0;z-index:999999!important;overflow:hidden;-ms-touch-action:none;touch-action:none;-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;-ms-text-size-adjust:100%;text-size-adjust:100%;-webkit-backface-visibility:hidden;backface-visibility:hidden;outline:0}.glightbox-container.inactive{display:none}.glightbox-container .gcontainer{position:relative;width:100%;height:100%;z-index:9999;overflow:hidden}.glightbox-container .gslider{-webkit-transition:-webkit-transform .4s ease;transition:-webkit-transform .4s ease;transition:transform .4s ease;transition:transform .4s ease,-webkit-transform .4s ease;height:100%;left:0;top:0;width:100%;position:relative;overflow:hidden;display:-webkit-box!important;display:-ms-flexbox!important;display:flex!important;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.glightbox-container .gslide{width:100%;position:absolute;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;opacity:0}.glightbox-container .gslide.current{opacity:1;z-index:99999;position:relative}.glightbox-container .gslide.prev{opacity:1;z-index:9999}.glightbox-container .gslide-inner-content{width:100%}.glightbox-container .ginner-container{position:relative;width:100%;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;max-width:100%;margin:auto;height:100vh}.glightbox-container .ginner-container.gvideo-container{width:100%}.glightbox-container .ginner-container.desc-bottom,.glightbox-container .ginner-container.desc-top{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.glightbox-container .ginner-container.desc-left,.glightbox-container .ginner-container.desc-right{max-width:100%!important}.gslide iframe,.gslide video{outline:0!important;border:none;min-height:165px;-webkit-overflow-scrolling:touch;-ms-touch-action:auto;touch-action:auto}.gslide:not(.current){pointer-events:none}.gslide-image{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.gslide-image img{max-height:100vh;display:block;padding:0;float:none;outline:0;border:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;max-width:100vw;width:auto;height:auto;-o-object-fit:cover;object-fit:cover;-ms-touch-action:none;touch-action:none;margin:auto;min-width:200px}.desc-bottom .gslide-image img,.desc-top .gslide-image img{width:auto}.desc-left .gslide-image img,.desc-right .gslide-image img{width:auto;max-width:100%}.gslide-image img.zoomable{position:relative}.gslide-image img.dragging{cursor:-webkit-grabbing!important;cursor:grabbing!important;-webkit-transition:none;transition:none}.gslide-video{position:relative;max-width:100vh;width:100%!important}.gslide-video .plyr__poster-enabled.plyr--loading .plyr__poster{display:none}.gslide-video .gvideo-wrapper{width:100%;margin:auto}.gslide-video::before{content:'';position:absolute;width:100%;height:100%;background:rgba(255,0,0,.34);display:none}.gslide-video.playing::before{display:none}.gslide-video.fullscreen{max-width:100%!important;min-width:100%;height:75vh}.gslide-video.fullscreen video{max-width:100%!important;width:100%!important}.gslide-inline{background:#fff;text-align:left;max-height:calc(100vh - 40px);overflow:auto;max-width:100%;margin:auto}.gslide-inline .ginlined-content{padding:20px;width:100%}.gslide-inline .dragging{cursor:-webkit-grabbing!important;cursor:grabbing!important;-webkit-transition:none;transition:none}.ginlined-content{overflow:auto;display:block!important;opacity:1}.gslide-external{display:-webkit-box;display:-ms-flexbox;display:flex;width:100%;min-width:100%;background:#fff;padding:0;overflow:auto;max-height:75vh;height:100%}.gslide-media{display:-webkit-box;display:-ms-flexbox;display:flex;width:auto}.zoomed .gslide-media{-webkit-box-shadow:none!important;box-shadow:none!important}.desc-bottom .gslide-media,.desc-top .gslide-media{margin:0 auto;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.gslide-description{position:relative;-webkit-box-flex:1;-ms-flex:1 0 100%;flex:1 0 100%}.gslide-description.description-left,.gslide-description.description-right{max-width:100%}.gslide-description.description-bottom,.gslide-description.description-top{margin:0 auto;width:100%}.gslide-description p{margin-bottom:12px}.gslide-description p:last-child{margin-bottom:0}.zoomed .gslide-description{display:none}.glightbox-button-hidden{display:none}.glightbox-mobile .glightbox-container .gslide-description{height:auto!important;width:100%;position:absolute;bottom:0;padding:19px 11px;max-width:100vw!important;-webkit-box-ordinal-group:3!important;-ms-flex-order:2!important;order:2!important;max-height:78vh;overflow:auto!important;background:-webkit-gradient(linear,left top,left bottom,from(rgba(0,0,0,0)),to(rgba(0,0,0,.75)));background:linear-gradient(to bottom,rgba(0,0,0,0) 0,rgba(0,0,0,.75) 100%);-webkit-transition:opacity .3s linear;transition:opacity .3s linear;padding-bottom:50px}.glightbox-mobile .glightbox-container .gslide-title{color:#fff;font-size:1em}.glightbox-mobile .glightbox-container .gslide-desc{color:#a1a1a1}.glightbox-mobile .glightbox-container .gslide-desc a{color:#fff;font-weight:700}.glightbox-mobile .glightbox-container .gslide-desc *{color:inherit}.glightbox-mobile .glightbox-container .gslide-desc .desc-more{color:#fff;opacity:.4}.gdesc-open .gslide-media{-webkit-transition:opacity .5s ease;transition:opacity .5s ease;opacity:.4}.gdesc-open .gdesc-inner{padding-bottom:30px}.gdesc-closed .gslide-media{-webkit-transition:opacity .5s ease;transition:opacity .5s ease;opacity:1}.greset{-webkit-transition:all .3s ease;transition:all .3s ease}.gabsolute{position:absolute}.grelative{position:relative}.glightbox-desc{display:none!important}.glightbox-open{overflow:hidden}.gloader{height:25px;width:25px;-webkit-animation:lightboxLoader .8s infinite linear;animation:lightboxLoader .8s infinite linear;border:2px solid #fff;border-right-color:transparent;border-radius:50%;position:absolute;display:block;z-index:9999;left:0;right:0;margin:0 auto;top:47%}.goverlay{width:100%;height:calc(100vh + 1px);position:fixed;top:-1px;left:0;background:#000;will-change:opacity}.glightbox-mobile .goverlay{background:#000}.gclose,.gnext,.gprev{z-index:99999;cursor:pointer;width:26px;height:44px;border:none;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.gclose svg,.gnext svg,.gprev svg{display:block;width:25px;height:auto;margin:0;padding:0}.gclose.disabled,.gnext.disabled,.gprev.disabled{opacity:.1}.gclose .garrow,.gnext .garrow,.gprev .garrow{stroke:#fff}.gbtn.focused{outline:2px solid #0f3d81}iframe.wait-autoplay{opacity:0}.glightbox-closing .gclose,.glightbox-closing .gnext,.glightbox-closing .gprev{opacity:0!important}.glightbox-clean .gslide-description{background:#fff}.glightbox-clean .gdesc-inner{padding:22px 20px}.glightbox-clean .gslide-title{font-size:1em;font-weight:400;font-family:arial;color:#000;margin-bottom:19px;line-height:1.4em}.glightbox-clean .gslide-desc{font-size:.86em;margin-bottom:0;font-family:arial;line-height:1.4em}.glightbox-clean .gslide-video{background:#000}.glightbox-clean .gclose,.glightbox-clean .gnext,.glightbox-clean .gprev{background-color:rgba(0,0,0,.75);border-radius:4px}.glightbox-clean .gclose path,.glightbox-clean .gnext path,.glightbox-clean .gprev path{fill:#fff}.glightbox-clean .gprev{position:absolute;top:-100%;left:30px;width:40px;height:50px}.glightbox-clean .gnext{position:absolute;top:-100%;right:30px;width:40px;height:50px}.glightbox-clean .gclose{width:35px;height:35px;top:15px;right:10px;position:absolute}.glightbox-clean .gclose svg{width:18px;height:auto}.glightbox-clean .gclose:hover{opacity:1}.gfadeIn{-webkit-animation:gfadeIn .5s ease;animation:gfadeIn .5s ease}.gfadeOut{-webkit-animation:gfadeOut .5s ease;animation:gfadeOut .5s ease}.gslideOutLeft{-webkit-animation:gslideOutLeft .3s ease;animation:gslideOutLeft .3s ease}.gslideInLeft{-webkit-animation:gslideInLeft .3s ease;animation:gslideInLeft .3s ease}.gslideOutRight{-webkit-animation:gslideOutRight .3s ease;animation:gslideOutRight .3s ease}.gslideInRight{-webkit-animation:gslideInRight .3s ease;animation:gslideInRight .3s ease}.gzoomIn{-webkit-animation:gzoomIn .5s ease;animation:gzoomIn .5s ease}.gzoomOut{-webkit-animation:gzoomOut .5s ease;animation:gzoomOut .5s ease}@-webkit-keyframes lightboxLoader{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes lightboxLoader{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes gfadeIn{from{opacity:0}to{opacity:1}}@keyframes gfadeIn{from{opacity:0}to{opacity:1}}@-webkit-keyframes gfadeOut{from{opacity:1}to{opacity:0}}@keyframes gfadeOut{from{opacity:1}to{opacity:0}}@-webkit-keyframes gslideInLeft{from{opacity:0;-webkit-transform:translate3d(-60%,0,0);transform:translate3d(-60%,0,0)}to{visibility:visible;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);opacity:1}}@keyframes gslideInLeft{from{opacity:0;-webkit-transform:translate3d(-60%,0,0);transform:translate3d(-60%,0,0)}to{visibility:visible;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);opacity:1}}@-webkit-keyframes gslideOutLeft{from{opacity:1;visibility:visible;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}to{-webkit-transform:translate3d(-60%,0,0);transform:translate3d(-60%,0,0);opacity:0;visibility:hidden}}@keyframes gslideOutLeft{from{opacity:1;visibility:visible;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}to{-webkit-transform:translate3d(-60%,0,0);transform:translate3d(-60%,0,0);opacity:0;visibility:hidden}}@-webkit-keyframes gslideInRight{from{opacity:0;visibility:visible;-webkit-transform:translate3d(60%,0,0);transform:translate3d(60%,0,0)}to{-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);opacity:1}}@keyframes gslideInRight{from{opacity:0;visibility:visible;-webkit-transform:translate3d(60%,0,0);transform:translate3d(60%,0,0)}to{-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);opacity:1}}@-webkit-keyframes gslideOutRight{from{opacity:1;visibility:visible;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}to{-webkit-transform:translate3d(60%,0,0);transform:translate3d(60%,0,0);opacity:0}}@keyframes gslideOutRight{from{opacity:1;visibility:visible;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}to{-webkit-transform:translate3d(60%,0,0);transform:translate3d(60%,0,0);opacity:0}}@-webkit-keyframes gzoomIn{from{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}to{opacity:1}}@keyframes gzoomIn{from{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}to{opacity:1}}@-webkit-keyframes gzoomOut{from{opacity:1}50%{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}to{opacity:0}}@keyframes gzoomOut{from{opacity:1}50%{opacity:0;-webkit-transform:scale3d(.3,.3,.3);transform:scale3d(.3,.3,.3)}to{opacity:0}}@media (min-width:769px){.glightbox-container .ginner-container{width:auto;height:auto;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}.glightbox-container .ginner-container.desc-top .gslide-description{-webkit-box-ordinal-group:1;-ms-flex-order:0;order:0}.glightbox-container .ginner-container.desc-top .gslide-image,.glightbox-container .ginner-container.desc-top .gslide-image img{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1}.glightbox-container .ginner-container.desc-left .gslide-description{-webkit-box-ordinal-group:1;-ms-flex-order:0;order:0}.glightbox-container .ginner-container.desc-left .gslide-image{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1}.gslide-image img{max-height:97vh;max-width:100%}.gslide-image img.zoomable{cursor:-webkit-zoom-in;cursor:zoom-in}.zoomed .gslide-image img.zoomable{cursor:-webkit-grab;cursor:grab}.gslide-inline{max-height:95vh}.gslide-external{max-height:100vh}.gslide-description.description-left,.gslide-description.description-right{max-width:275px}.glightbox-open{height:auto}.goverlay{background:rgba(0,0,0,.92)}.glightbox-clean .gslide-media{-webkit-box-shadow:1px 2px 9px 0 rgba(0,0,0,.65);box-shadow:1px 2px 9px 0 rgba(0,0,0,.65)}.glightbox-clean .description-left .gdesc-inner,.glightbox-clean .description-right .gdesc-inner{position:absolute;height:100%;overflow-y:auto}.glightbox-clean .gclose,.glightbox-clean .gnext,.glightbox-clean .gprev{background-color:rgba(0,0,0,.32)}.glightbox-clean .gclose:hover,.glightbox-clean .gnext:hover,.glightbox-clean .gprev:hover{background-color:rgba(0,0,0,.7)}.glightbox-clean .gprev{top:45%}.glightbox-clean .gnext{top:45%}}@media (min-width:992px){.glightbox-clean .gclose{opacity:.7;right:20px}}@media screen and (max-height:420px){.goverlay{background:#000}}
|
7
app/controllers/kanta_controller.rb
Normal file
7
app/controllers/kanta_controller.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
class KantaController < ApplicationController
|
||||||
|
|
||||||
|
def show
|
||||||
|
@image = Merged::Image.first
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -3,7 +3,7 @@ class MembersController < ApplicationController
|
|||||||
|
|
||||||
# GET /members
|
# GET /members
|
||||||
def index
|
def index
|
||||||
@members = Member.order(:name).page params[:page]
|
@members = Member.visible_scope.order(:name).page params[:page]
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /members/1
|
# GET /members/1
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
module MembersHelper
|
module MembersHelper
|
||||||
|
|
||||||
def picture_for(someone , classes = "")
|
def picture_for(someone , classes = "")
|
||||||
if someone.picture.blank?
|
image = someones_path(someone)
|
||||||
image = asset_url("no_image.png")
|
|
||||||
else
|
|
||||||
image = someone.picture.url
|
|
||||||
end
|
|
||||||
if someone.respond_to? :name
|
if someone.respond_to? :name
|
||||||
alt = someone.name
|
alt = someone.name
|
||||||
else
|
else
|
||||||
@ -14,6 +10,13 @@ module MembersHelper
|
|||||||
image_tag(image , alt: alt , class: classes )
|
image_tag(image , alt: alt , class: classes )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def someones_path( someone )
|
||||||
|
if someone.picture.blank?
|
||||||
|
asset_url("no_image.png")
|
||||||
|
else
|
||||||
|
someone.picture.url
|
||||||
|
end
|
||||||
|
end
|
||||||
def stayed(member)
|
def stayed(member)
|
||||||
return "Not arrived" if member.arrived.blank?
|
return "Not arrived" if member.arrived.blank?
|
||||||
text = member.arrived.to_s
|
text = member.arrived.to_s
|
||||||
|
@ -1 +1,10 @@
|
|||||||
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
|
// Configure your import map in config/importmap.rb.
|
||||||
|
// Read more: https://github.com/rails/importmap-rails
|
||||||
|
|
||||||
|
// Currently haml filter does not support modules.
|
||||||
|
// import and make global as workaround
|
||||||
|
//
|
||||||
|
// haml module syntax is really clunky, filing issue and hoping
|
||||||
|
//
|
||||||
|
import GLightbox from 'glightbox';
|
||||||
|
globalThis.GLightbox = GLightbox;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
class Member < ApplicationRecord
|
class Member < ApplicationRecord
|
||||||
|
|
||||||
def self.default_scope
|
def self.visible_scope
|
||||||
where.not(confirmed_at: nil).where.not(picture: nil)
|
where.not(confirmed_at: nil).where.not(picture: nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,5 +5,6 @@ class Picture < ApplicationRecord
|
|||||||
|
|
||||||
validates :text, length: { maximum: 80 }
|
validates :text, length: { maximum: 80 }
|
||||||
validates :happened, presence: true
|
validates :happened, presence: true
|
||||||
|
validates :picture, presence: true
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,7 @@ class Story < ApplicationRecord
|
|||||||
|
|
||||||
validates :text, length: { minimum: 5 , maximum: 1000 }
|
validates :text, length: { minimum: 5 , maximum: 1000 }
|
||||||
validates :header , length: { minimum: 5 , maximum: 400}
|
validates :header , length: { minimum: 5 , maximum: 400}
|
||||||
|
validates :picture, presence: true
|
||||||
|
|
||||||
def name
|
def name
|
||||||
header
|
header
|
||||||
|
10
app/views/kanta/_form.html.haml
Normal file
10
app/views/kanta/_form.html.haml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
= form_for @kantum do |f|
|
||||||
|
- if @kantum.errors.any?
|
||||||
|
#error_explanation
|
||||||
|
%h2= "#{pluralize(@kantum.errors.count, "error")} prohibited this kantum from being saved:"
|
||||||
|
%ul
|
||||||
|
- @kantum.errors.full_messages.each do |message|
|
||||||
|
%li= message
|
||||||
|
|
||||||
|
.actions
|
||||||
|
= f.submit 'Save'
|
7
app/views/kanta/edit.html.haml
Normal file
7
app/views/kanta/edit.html.haml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
%h1 Editing kantum
|
||||||
|
|
||||||
|
= render 'form'
|
||||||
|
|
||||||
|
= link_to 'Show', @kantum
|
||||||
|
\|
|
||||||
|
= link_to 'Back', kanta_path
|
19
app/views/kanta/index.html.haml
Normal file
19
app/views/kanta/index.html.haml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
%h1 Listing kanta
|
||||||
|
|
||||||
|
%table
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th
|
||||||
|
%th
|
||||||
|
%th
|
||||||
|
|
||||||
|
%tbody
|
||||||
|
- @kanta.each do |kantum|
|
||||||
|
%tr
|
||||||
|
%td= link_to 'Show', kantum
|
||||||
|
%td= link_to 'Edit', edit_kantum_path(kantum)
|
||||||
|
%td= link_to 'Destroy', kantum, method: :delete, data: { confirm: 'Are you sure?' }
|
||||||
|
|
||||||
|
%br
|
||||||
|
|
||||||
|
= link_to 'New Kantum', new_kantum_path
|
5
app/views/kanta/new.html.haml
Normal file
5
app/views/kanta/new.html.haml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
%h1 New kantum
|
||||||
|
|
||||||
|
= render 'form'
|
||||||
|
|
||||||
|
= link_to 'Back', kanta_path
|
16
app/views/kanta/show.html.haml
Normal file
16
app/views/kanta/show.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#app
|
||||||
|
.flex.justify-center
|
||||||
|
= #@image.attributes
|
||||||
|
|
||||||
|
.flex.justify-center
|
||||||
|
%a.underline{ e_click: "bg_change" , r_class: 'bg'}
|
||||||
|
{{ bg }}
|
||||||
|
:opal
|
||||||
|
class Clicker < VueR::Application
|
||||||
|
def bg_change
|
||||||
|
self.bg = "bg-cyan-50"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
kanta = Clicker.new(bg: 'bg-cyan-200')
|
||||||
|
kanta.mount("#app")
|
@ -27,6 +27,7 @@
|
|||||||
= csp_meta_tag
|
= csp_meta_tag
|
||||||
= stylesheet_link_tag "tailwind"
|
= stylesheet_link_tag "tailwind"
|
||||||
= stylesheet_link_tag "application"
|
= stylesheet_link_tag "application"
|
||||||
|
= javascript_include_tag "opal_main"
|
||||||
|
|
||||||
= javascript_importmap_tags
|
= javascript_importmap_tags
|
||||||
- if false
|
- if false
|
||||||
|
@ -47,3 +47,7 @@
|
|||||||
= link_to edit_picture_path(picture) do
|
= link_to edit_picture_path(picture) do
|
||||||
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
||||||
Edit Picture
|
Edit Picture
|
||||||
|
:javascript
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
const lightbox = GLightbox({ });
|
||||||
|
});
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
.mx-20.grid.grid-cols-1.md:grid-cols-2.lg:grid-cols-3.2xl:grid-cols-4.gap-8.md:gap-12.lg:gap-16
|
.mx-20.grid.grid-cols-1.md:grid-cols-2.lg:grid-cols-3.2xl:grid-cols-4.gap-8.md:gap-12.lg:gap-16
|
||||||
- Picture.all.limit(4).each do |picture|
|
- Picture.all.limit(4).each do |picture|
|
||||||
= render "pictures/picture" , picture: picture
|
= render "pictures/picture" , picture: picture
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
const lightbox = GLightbox({ });
|
||||||
|
});
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
= distance_of_time_in_words_to_now picture.happened
|
= distance_of_time_in_words_to_now picture.happened
|
||||||
ago
|
ago
|
||||||
.h-0.overflow-hidden.relative{class: "pt-[75%]"}
|
.h-0.overflow-hidden.relative{class: "pt-[75%]"}
|
||||||
|
=link_to someones_path( picture ) , {class: :glightbox ,
|
||||||
|
"data-glightbox" => "title: #{picture.text}" } do
|
||||||
= picture_for( picture , "absolute top-0 left-0 w-full h-full inset-0 object-cover hover:scale-105 ease-in duration-500")
|
= picture_for( picture , "absolute top-0 left-0 w-full h-full inset-0 object-cover hover:scale-105 ease-in duration-500")
|
||||||
-unless picture.text.blank?
|
-unless picture.text.blank?
|
||||||
.absolute.bottom-0.left-0.right-0.px-4.pb-1.bg-gray-800.opacity-70.transition-colors.group-hover:bg-black.group-hover:opacity-100
|
.absolute.bottom-0.left-0.right-0.px-4.pb-1.bg-gray-800.opacity-70.transition-colors.group-hover:bg-black.group-hover:opacity-100
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
= paginate @pictures
|
= paginate @pictures
|
||||||
|
|
||||||
.flex.justify-end.mr-10
|
.flex.justify-end.mr-10
|
||||||
@ -9,9 +10,12 @@
|
|||||||
- @pictures.each do |picture|
|
- @pictures.each do |picture|
|
||||||
= render picture , picture: picture
|
= render picture , picture: picture
|
||||||
|
|
||||||
%br
|
|
||||||
|
|
||||||
.flex.ml-20
|
.flex.ml-20
|
||||||
= link_to new_picture_path do
|
= link_to new_picture_path do
|
||||||
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
||||||
New Picture
|
New Picture
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
const lightbox = GLightbox({ });
|
||||||
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%section.overflow-hidden.grid.grid-cols-1.m-5.md:m-12.lg:m-20.md:grid-cols-2
|
%section.overflow-hidden.grid.grid-cols-1.m-5.md:m-12.lg:m-20.md:grid-cols-2
|
||||||
%div
|
=link_to someones_path( story ) , {class: :glightbox } do
|
||||||
= picture_for( story , "h-56 w-full object-cover sm:h-full")
|
= picture_for( story , "h-56 w-full object-cover sm:h-full")
|
||||||
.p-8.md:p-12.lg:px-16.lg:py-24
|
.p-8.md:p-12.lg:px-16.lg:py-24
|
||||||
.mx-auto.max-w-xl.text-center
|
.mx-auto.max-w-xl.text-center
|
||||||
@ -7,6 +7,7 @@
|
|||||||
= story.header
|
= story.header
|
||||||
%h4.text-xl.mt-10.md:text-2xl
|
%h4.text-xl.mt-10.md:text-2xl
|
||||||
= distance_of_time_in_words_to_now story.happened
|
= distance_of_time_in_words_to_now story.happened
|
||||||
ago
|
ago, by
|
||||||
|
= link_to story.member.name , main_app.member_path(story.member) , class: :underline
|
||||||
.mt-8{ prose_classes }
|
.mt-8{ prose_classes }
|
||||||
= markdown(story.text)
|
= markdown(story.text)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
%section.flex.justify-center.p-8.flex-col.md:flex-row.m-20
|
%section.flex.justify-center.p-8.flex-col.md:flex-row.m-20
|
||||||
.flex.items-center.h-40.md:h-60.lg:h-96.w-full.overflow-hidden{class: "lg:w-2/3"}
|
.flex.items-center.h-40.md:h-60.lg:h-96.w-full.overflow-hidden{class: "lg:w-2/3"}
|
||||||
|
=link_to someones_path( story ) , {class: :glightbox } do
|
||||||
= picture_for(story ,"object-cover")
|
= picture_for(story ,"object-cover")
|
||||||
.flex.items-center.w-full.max-w.px-6.mt-6.mx-auto{:class => "lg:w-1/3"}
|
.flex.items-center.w-full.max-w.px-6.mt-6.mx-auto{:class => "lg:w-1/3"}
|
||||||
.flex-1
|
.flex-1
|
||||||
@ -8,6 +9,7 @@
|
|||||||
= story.header
|
= story.header
|
||||||
%h4.text-xl.mt-4.lg:mt-8.md:text-2xl
|
%h4.text-xl.mt-4.lg:mt-8.md:text-2xl
|
||||||
= distance_of_time_in_words_to_now story.happened
|
= distance_of_time_in_words_to_now story.happened
|
||||||
ago
|
ago, by
|
||||||
|
= link_to story.member.name , main_app.member_path(story.member) , class: :underline
|
||||||
.mt-3{ prose_classes }
|
.mt-3{ prose_classes }
|
||||||
= markdown(story.text)
|
= markdown(story.text)
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
= story.header
|
= story.header
|
||||||
.text-xl.pb-6{ prose_classes }
|
.text-xl.pb-6{ prose_classes }
|
||||||
= distance_of_time_in_words_to_now story.happened
|
= distance_of_time_in_words_to_now story.happened
|
||||||
ago
|
ago, by
|
||||||
|
= link_to story.member.name , main_app.member_path(story.member) , class: :underline
|
||||||
.max-w-full.mt-4.gap-16.columns-1.md:columns-2.lg:columns-3.xl:columns-4{ prose_classes }
|
.max-w-full.mt-4.gap-16.columns-1.md:columns-2.lg:columns-3.xl:columns-4{ prose_classes }
|
||||||
|
=link_to someones_path( story ) , {class: :glightbox } do
|
||||||
= picture_for( story , "h-56 w-full object-cover sm:h-full")
|
= picture_for( story , "h-56 w-full object-cover sm:h-full")
|
||||||
= markdown(story.text)
|
= markdown(story.text)
|
||||||
|
@ -14,3 +14,8 @@
|
|||||||
= link_to new_story_path do
|
= link_to new_story_path do
|
||||||
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
%button.bg-cyan-200.mr-3.inline-block.rounded-lg.px-4.py-3.text-md.font-medium.border.border-gray-400
|
||||||
New Story
|
New Story
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
const lightbox = GLightbox({ });
|
||||||
|
});
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
# Pin npm packages by running ./bin/importmap
|
# Pin npm packages by running ./bin/importmap
|
||||||
|
|
||||||
pin "application", preload: true
|
pin "application", preload: true
|
||||||
|
pin "glightbox", to: "https://ga.jspm.io/npm:glightbox@3.2.0/dist/js/glightbox.min.js"
|
||||||
|
22
config/initializers/opal.rb
Normal file
22
config/initializers/opal.rb
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Check out the full list of the available configuration options at
|
||||||
|
# https://github.com/opal/opal/blob/master/lib/opal/config.rb
|
||||||
|
|
||||||
|
Rails.application.configure do
|
||||||
|
# We suggest keeping the configuration above as default for all environments,
|
||||||
|
# disabling some of them might slightly reduce the bundle size or reduce performance
|
||||||
|
# by degrading some ruby features.
|
||||||
|
config.opal.method_missing_enabled = true
|
||||||
|
config.opal.const_missing_enabled = true
|
||||||
|
config.opal.arity_check_enabled = true
|
||||||
|
config.opal.freezing_stubs_enabled = true
|
||||||
|
config.opal.dynamic_require_severity = :ignore
|
||||||
|
|
||||||
|
# To enable passing assigns from the controller to the opal template handler
|
||||||
|
# change the following configuration to one of these values:
|
||||||
|
#
|
||||||
|
# - true # both locals and instance variables
|
||||||
|
# - :locals # only locals
|
||||||
|
# - :ivars # only instance variables
|
||||||
|
#
|
||||||
|
config.opal.assigns_in_templates = false
|
||||||
|
end
|
@ -1,4 +1,5 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
resources :kanta
|
||||||
resources :pictures
|
resources :pictures
|
||||||
resources :stories
|
resources :stories
|
||||||
|
|
||||||
|
19
lib/opal/rails/haml_filter.rb
Normal file
19
lib/opal/rails/haml_filter.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
require "haml"
|
||||||
|
require "haml/filters"
|
||||||
|
require "haml/filters/base"
|
||||||
|
|
||||||
|
module Haml
|
||||||
|
class Filters
|
||||||
|
class Opal < Base
|
||||||
|
def compile(node)
|
||||||
|
temple = [:multi]
|
||||||
|
temple << [:static, "<script type='text/javascript'>\n"]
|
||||||
|
temple << [:static, ::Opal.compile(node.value[:text]) ]
|
||||||
|
temple << [:static, "\n</script>"]
|
||||||
|
temple
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Haml::Filters.registered[:opal] ||= Haml::Filters::Opal
|
Loading…
Reference in New Issue
Block a user