drg_cms 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  module DrgCms #:nodoc:
2
2
  # drg_cms gem version
3
- VERSION = "0.5.2"
3
+ VERSION = "0.5.3"
4
4
  end
@@ -0,0 +1,19 @@
1
+ require_dependency DrgCms.model 'dc_user'
2
+
3
+ class DcUser
4
+ include DcUserConcern
5
+
6
+ field :member, type: Boolean, default: false
7
+ field :card_number, type: String
8
+
9
+ index( { 'card_number' => 1 } )
10
+
11
+ validate :my_control
12
+
13
+ def my_control
14
+ if member and card_number.to_s.size < 8
15
+ errors.add(:card_number, "Card number is not valid!")
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,11 @@
1
+
2
+ extend: drg_cms.dc_user
3
+ form:
4
+ tabs:
5
+ tab2:
6
+ 10:
7
+ name: member
8
+ type: check_box
9
+ 20:
10
+ name: card_number
11
+ type: text_field
@@ -0,0 +1,13 @@
1
+ en:
2
+ helpers:
3
+ label:
4
+ dc_user:
5
+ tab2: Membership
6
+ member: Is member
7
+ card_number: Card number
8
+
9
+ help:
10
+ dc_user:
11
+ member: User is member of our organization
12
+ card_number: Membership card number
13
+
@@ -0,0 +1,13 @@
1
+ sl:
2
+ helpers:
3
+ label:
4
+ dc_user:
5
+ tab2: Članstvo
6
+ member: Je član
7
+ card_number: Številka kartice
8
+
9
+ help:
10
+ dc_user:
11
+ member: Uporabnik je naš član
12
+ card_number: Številka članske kartice
13
+
@@ -0,0 +1,58 @@
1
+ table: dc_part
2
+ index:
3
+ actions:
4
+ 1: new
5
+
6
+ result_set:
7
+ actions: standard
8
+
9
+ columns:
10
+ 1:
11
+ name: name
12
+ 2:
13
+ name: div_id
14
+ 3:
15
+ name: updated_by
16
+ eval: dc_name4_id,dc_user,name
17
+ 4:
18
+ name: updated_at
19
+
20
+ form:
21
+ actions: standard
22
+ title:
23
+ new: New image
24
+ edit: Edit image
25
+ field: name
26
+ fields:
27
+ 05:
28
+ name: div_id
29
+ type: readonly
30
+ html:
31
+ size: 10
32
+ 10:
33
+ name: name
34
+ type: text_field
35
+ text: Image title
36
+ html:
37
+ size: 50
38
+ 20:
39
+ name: description
40
+ type: text_field
41
+ text: Image description
42
+ html:
43
+ size: 50
44
+ 30:
45
+ name: thumbnail
46
+ type: file_select
47
+ html:
48
+ size: 50
49
+ 40:
50
+ name: picture
51
+ type: file_select
52
+ html:
53
+ size: 50
54
+ 60:
55
+ name: order
56
+ type: text_field
57
+ html:
58
+ size: 2
@@ -0,0 +1,74 @@
1
+ #coding: utf-8
2
+ #--
3
+ # Copyright (c) 2014+ Damjan Rems
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #++
24
+
25
+ ########################################################################
26
+ #
27
+ ########################################################################
28
+ class GalleryRenderer < DcRenderer
29
+
30
+ #######################################################################
31
+ # Will render picture gallery
32
+ #######################################################################
33
+ def gallery(page=nil)
34
+ page ||= @parent.page
35
+ return '' if page.gallery.blank?
36
+ #
37
+ html = '<div class="picture-gallery">'
38
+ if @parent.dc_edit_mode?
39
+ opts = { controller: 'cmsedit', action: 'create', formname: 'gallery',
40
+ table: "#{@parent.site.page_table};dc_part", ids: page._id,
41
+ 'dc_part.div_id' => page.gallery, 'dc_part.name' => page.subject,
42
+ title: 'Add new picture to gallery.' }
43
+ html << @parent.dc_link_for_create(opts)
44
+ end
45
+ html << '<h2>Picture gallery:</h2>'
46
+ page.dc_parts.where(:div_id => page.gallery).order(order: 1).each do |part|
47
+ html << '<span class="gallery-pic">'
48
+ if @parent.dc_edit_mode?
49
+ opts.merge!({ action: 'edit', ids: page._id, id: part._id, title: 'Edit picture.' })
50
+ html << @parent.dc_link_for_edit(opts)
51
+ end
52
+ # Display thumbnail if defined. Otherwise use picture. Picture height should be limited by CSS
53
+ pic = part.thumbnail.blank? ? part.picture : part.thumbnail
54
+ # Use part.name as title. If not use page title (subject) field
55
+ title = part.name.blank? ? page.subject : part.name
56
+ html << @parent.link_to(@parent.image_tag(pic, title: title), part.picture)
57
+ # Description under picture
58
+ html << "<h6>#{part.description}</h6>" unless part.description.blank?
59
+ html << '</span>'
60
+ end
61
+ # At the end we use baguetteBox javascript library to transparently display gallery on phone or pc
62
+ html << @parent.javascript_tag( "baguetteBox.run('.picture-gallery', {});" )
63
+ html << '</div>'
64
+ end
65
+
66
+ ########################################################################
67
+ #
68
+ ########################################################################
69
+ def render_html
70
+ method = @opts[:method] || 'default'
71
+ respond_to?(method) ? send(method) : "#{self.class}. Method #{method} not found!"
72
+ end
73
+
74
+ end
@@ -0,0 +1,74 @@
1
+ #coding: utf-8
2
+ #--
3
+ # Copyright (c) 2014+ Damjan Rems
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #++
24
+
25
+ ########################################################################
26
+ #
27
+ ########################################################################
28
+ class GalleryRenderer < DcRenderer
29
+
30
+ #######################################################################
31
+ # Will render picture gallery
32
+ #######################################################################
33
+ def gallery(page=nil)
34
+ page = @parent.page if page.nil?
35
+ return '' if page.gallery.blank?
36
+ #
37
+ html = '<div class="picture-gallery">'
38
+ if @parent.dc_edit_mode?
39
+ opts = { controller: 'cmsedit', action: 'create', formname: 'gallery',
40
+ table: "#{@parent.site.page_table};dc_part", ids: page._id,
41
+ 'dc_part.div_id' => page.gallery, 'dc_part.name' => page.subject,
42
+ title: 'Add new picture to gallery.' }
43
+ html << @parent.dc_link_for_create(opts)
44
+ end
45
+ html << '<h2>Picture gallery:</h2>'
46
+ page.dc_parts.where(:div_id => page.gallery).order(order: 1).each do |part|
47
+ html << '<span class="gallery-pic">'
48
+ if @parent.dc_edit_mode?
49
+ opts.merge!({ action: 'edit', ids: page._id, id: part._id, title: 'Edit picture.' })
50
+ html << @parent.dc_link_for_edit(opts)
51
+ end
52
+ # Display thumbnail if defined. Otherwise use picture. Picture height should be limited by CSS
53
+ pic = part.thumbnail.blank? ? part.picture : part.thumbnail
54
+ # Use part.name as title. If not use page title (subject) field
55
+ title = part.name.blank? ? page.subject : part.name
56
+ html << @parent.link_to(@parent.image_tag(pic, title: title), part.picture)
57
+ # Description under picture
58
+ html << "<h6>#{part.description}</h6>" unless part.description.blank?
59
+ html << '</span>'
60
+ end
61
+ # At the end we use baguetteBox javascript library to transparently display gallery on phone or pc
62
+ html << @parent.javascript_tag( "baguetteBox.run('.picture-gallery', {});" )
63
+ html << '</div>'
64
+ end
65
+
66
+ ########################################################################
67
+ #
68
+ ########################################################################
69
+ def render_html
70
+ method = @opts[:method] || 'default'
71
+ respond_to?(method) ? send(method) : "#{self.class}. Method #{method} not found!"
72
+ end
73
+
74
+ end
@@ -0,0 +1,35 @@
1
+ <!-- dc_site.design field data -->
2
+ <div id="site">
3
+ <ul id='meni-site' class='small-block-grid-3'>
4
+ <%= dc_render(:dc_simple_menu, name: 'meni-site', method: 'as_responsive') %>
5
+ </ul>
6
+
7
+ <div class="site-top picture-top">
8
+ <img src="/files/logos/top-bg-pic.jpg" />
9
+ </div>
10
+
11
+ <div id="page" class="row">
12
+ <div id="div-main" class="small-12 large-7 columns">
13
+ <div class="show-for-medium-down" style="padding: 10px;"><%= dc_render(:responsive, method: 'i_move') %></div>
14
+ [main]
15
+ </div>
16
+ <div id="div-right" class="small-12 large-5 columns">
17
+ <div class="show-for-medium-up"><%= dc_render(:responsive, method: 'i_move') %></div>
18
+ <%= dc_render(:responsive, method: 'roller') %>
19
+ <div class="na-mailing"><%= dc_render(:dc_poll, poll_id: 'mail-subscribe') %></div>
20
+ <div class="na-mailing"><%= dc_render(:sport, method: 'send_mail') %></div>
21
+ </div>
22
+ </div>
23
+
24
+ <div id="site-footer">
25
+ <%= dc_render(:dc_piece, id: 'site-footer') %>
26
+ </div>
27
+
28
+ </div>
29
+ <%= dc_render(:responsive, method: 'eu_cookies') %>
30
+ <%= dc_render(:dc_common, method: 'google_analytics') %>
31
+
32
+ <!-- dc_design.body field data -->
33
+ <% main="\<\%= dc_render(:sport, method: 'seznam') \%\>" %>
34
+
35
+ <%= dc_replace_in_design(replace: '[main]', with: main) %>
@@ -0,0 +1,32 @@
1
+ #--
2
+ # Copyright (c) 2012+ Damjan Rems
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ class Mailing
25
+ include Mongoid::Document
26
+ include Mongoid::Timestamps
27
+
28
+ field :email, type: String, default: ''
29
+ field :active, type: Boolean, default: true
30
+
31
+ validates :email, presence: true
32
+ end
@@ -0,0 +1,27 @@
1
+ /* This will center and automatically resize top picture. Picture size is 1280x480px */
2
+ .site-top {
3
+ text-align: center;
4
+ position: relative;
5
+ height: 0;
6
+ overflow: hidden;
7
+ }
8
+ .picture-top { padding-bottom:37.5%; }
9
+
10
+ /* Prevent too much padding when resized past 1400 px */
11
+ @media screen and (min-width: 1400px) {
12
+ .picture-top { padding-bottom:28%; }
13
+ }
14
+
15
+ #page {max-width: 820px; margin: 0 auto;}
16
+
17
+ #site-footer {
18
+ color: white;
19
+ background: linear-gradient(#474748 4%, #191a1a 100%);
20
+ }
21
+ #site-footer div { max-width: 820px; margin: 0 auto;}
22
+ #site-footer a {color: #fff; font-weight: normal;}
23
+ #site-footer a:hover {color: #222;}
24
+
25
+ @media screen and (max-width: 640px) {
26
+ html { font-size: 18px; }
27
+ }
@@ -0,0 +1,56 @@
1
+ #coding: utf-8
2
+ #--
3
+ # Copyright (c) 2012-2013 Damjan Rems
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #++
24
+ class ResponsiveController < DcApplicationController
25
+ protect_from_forgery
26
+
27
+ ####################################################################
28
+ # Checks if email is OK.
29
+ ####################################################################
30
+ def email_ok(email)
31
+ email = email.downcase.strip
32
+ return 'e-mail is empty!' unless email.size > 0
33
+ return 'e-mail is not validd!' unless email =~ /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
34
+ ''
35
+ end
36
+
37
+ ####################################################################
38
+ # This action is called when submit is selected on subscribe poll form.
39
+ ####################################################################
40
+ def subscribe
41
+ check = emyil_ok(params[:record][:email])
42
+ if check.size > 0
43
+ flash[:error] = check
44
+ else
45
+ email = params[:record][:email].strip.downcase
46
+ if Mailing.find_by(email: email)
47
+ flash[:error] = 'e-mail already exists!'
48
+ else
49
+ Mailing.create(email: email)
50
+ flash[:info] = 'e-mail recorded. Thank you for your interest.'
51
+ end
52
+ end
53
+ redirect_to params[:return_to]
54
+ end
55
+
56
+ end
@@ -0,0 +1,104 @@
1
+ #coding: utf-8
2
+ #--
3
+ # Copyright (c) 2014+ Damjan Rems
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining
6
+ # a copy of this software and associated documentation files (the
7
+ # "Software"), to deal in the Software without restriction, including
8
+ # without limitation the rights to use, copy, modify, merge, publish,
9
+ # distribute, sublicense, and/or sell copies of the Software, and to
10
+ # permit persons to whom the Software is furnished to do so, subject to
11
+ # the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be
14
+ # included in all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ #++
24
+
25
+ ########################################################################
26
+ #
27
+ ########################################################################
28
+ class ResponsiveRenderer < DcRenderer
29
+
30
+ ########################################################################
31
+ # i_move may move between right and main part.
32
+ ########################################################################
33
+ def i_move
34
+ html = '<div id="i-move"><h2>I MOVE WHEN ON PHONE<h2>'
35
+ html << 'Contents'
36
+ html << '</div>'
37
+ end
38
+
39
+ ########################################################################
40
+ # Roller rolls ads in it's div. With little help of slick javascript library.
41
+ ########################################################################
42
+ def roller
43
+ html = '<div class="sponsors">'
44
+ # Ads are saved in home page parts which have 'ads' written in div_id field.
45
+ home = DcPage.find_by(dc_site_id: @parent.dc_get_site._id, subject_link: 'home')
46
+ ads = home.dc_parts.where(div_id: 'ads')
47
+ ads = ads.and(active: true) unless @parent.dc_edit_mode? # active only
48
+ ads = ads.order_by(order: 1).to_a
49
+ html << 'OUR SPONSORS' if ads.size > 0 or @parent.dc_edit_mode?
50
+ ads.each do |ad|
51
+ # Edit link for ad
52
+ if @parent.dc_edit_mode?
53
+ opts = { controller: 'cmsedit', action: 'edit', formname: 'ad',
54
+ table: "#{@parent.site.page_table};dc_part", ids: home._id,
55
+ id: ad._id, title: 'Edit sponsor\'s ad.' }
56
+ html << @parent.dc_link_for_edit(opts)
57
+ end
58
+ html << "<div>#{@parent.link_to(@parent.image_tag(ad.picture),ad.link, target: '_blank')}</div>"
59
+ end
60
+ # Link for new ad
61
+ if @parent.dc_edit_mode?
62
+ opts = { controller: 'cmsedit', action: 'create', formname: 'ad',
63
+ table: "#{@parent.site.page_table};dc_part", ids: home._id,
64
+ 'dc_part.div_id' => 'ads', title: 'Add new sponsor\'s ad!' }
65
+ html << @parent.dc_link_for_create(opts)
66
+ end
67
+ html << '</div>'
68
+ html << @parent.javascript_tag( "$('.sponsors').slick({
69
+ autoplay: true, infinite: true, autoplaySpeed: 2000, speed: 2000,
70
+ arrows: false});" ) unless @parent.dc_edit_mode?
71
+ html
72
+ end
73
+
74
+ ########################################################################
75
+ # EU cookies message.
76
+ ########################################################################
77
+ def eu_cookies
78
+ html =<<EOT
79
+ <div id="cookies-msg">
80
+ Our web site is using cookies in order to ensure best user experience.
81
+ By visiting our web site you agree to our conditions.
82
+ <span class="cookies-yes">Close</span>
83
+ #{@parent.link_to('More information about cookies!','/cookies')}
84
+ </div>
85
+ EOT
86
+ html.html_safe
87
+ end
88
+
89
+ ########################################################################
90
+ # Send mail dialog. Data can also be rendered by Rails render method.
91
+ ########################################################################
92
+ def send_mail
93
+ @parent.render(partial: 'responsive_views/send_email')
94
+ end
95
+
96
+ ########################################################################
97
+ #
98
+ ########################################################################
99
+ def render_html
100
+ method = @opts[:method] || 'default'
101
+ respond_to?(method) ? send(method) : "#{self.class}. Method #{method} not found!"
102
+ end
103
+
104
+ end