gubbara 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b180c17e9b04468098b457d14fd4e89f00029c16
4
- data.tar.gz: dcff530806919bf0d2f0fb01a9faabf58d1890e7
3
+ metadata.gz: ebf4b07c28b80ae36e8b76a67bc39a2f179bb694
4
+ data.tar.gz: 069c8a642bcb7124adf837777af5088ddffb4ed2
5
5
  SHA512:
6
- metadata.gz: e92ce7ae929ef14cf95d7b566c2861a262428108cd68cdc84bc2cc4ee48627aab477e9981b04cf5bd5fe2f7434b3418cbf2adfab5585024db38b4cc33fdcf4fa
7
- data.tar.gz: c3c8b4fea8306dd177f597eaa621290477be82752e61beab311405da0c3d8679fbacc7c90a5ae630572be7bbf76b5cadc34f1156c219b0788ff04c5b256588d3
6
+ metadata.gz: c05e17995d850242ed3862bf5f184603b0caf668d53afb400e0fd78448d14d733d8953b94d2a79cf30ce8a10c1cafb7116bcb31d5d60d32ce90ce99c99b330fd
7
+ data.tar.gz: 7108fd14e66964d95131a9568c9731921401c89eeb4f167483349d718a85de0b68883fd0605c13a7436742ee04051206e244d7873d6cfa7f8593e49addb4ddb5
data/README.rdoc CHANGED
@@ -1,6 +1,9 @@
1
1
  = Gubbara
2
2
 
3
- It helps admin to announce anything to every user in the system in a form of a notice which is configurable also every user has an option to hide it and will not appear till session expires or disabled by admin.
3
+ It helps admin to announce anything including pasrsed html in a form a notice.It consists two types of announcements:
4
+
5
+ - Session Based: Only for logged in users.(Application Layout)
6
+ - Cookie Based: For all users visting the website.(Public Layout)
4
7
 
5
8
  == Installation
6
9
 
@@ -26,25 +29,57 @@ To use this gem you just need to mount it in your route file *config/routes.rb*
26
29
 
27
30
  <tt>mount Gubbara::Engine => '/gubbara'</tt>
28
31
 
29
- Place this helper method in any layout or any view page where you want to place your notice.
32
+ Place the helper method according to your requirement in any layout or any view page where you want to place your notice.
30
33
 
31
- example: place this in *app/views/layouts/application.html.erb* file
34
+ === Session Based Announcements
32
35
 
33
- <tt><%= list_notices %></tt>
36
+ For session based announcements place this helper method in the layout which is not publicly accessible.
34
37
 
35
- == Hide
38
+ example: place this in *app/views/layouts/application.html.erb* file.
36
39
 
37
- When a user clicks on the cross button it hides the template for that session and will not show till the session expires or disabled by admin.
40
+ <tt><%= user_announcements %></tt>
41
+
42
+ === Cookie Based Announcements
43
+
44
+ For cookie based announcements place this helper method in the layout which is publicly accessible.
45
+
46
+ example: place this in *app/views/layouts/public.html.erb* file.
38
47
 
39
- == Admin Accesss
48
+ <tt><%= public_announcements %></tt>
40
49
 
41
- You can access 'Gubbara Admin Panel'.
50
+ == Features
42
51
 
43
- Please ensure that only admin can access this gubbara panel to do that you can use *http_basic_authenticate_with*.
52
+ === Admin Panel
44
53
 
45
- == Configuration
54
+ You can access Gubbara Admin Panel.
55
+
56
+ Please ensure that only admin can access this gubbara panel to do that you can use *http_basic_authenticate_with* or some other methods to prevent that url.
57
+
58
+ === Configuration
46
59
 
47
60
  You can configure *background_color*, *font_color*, *font_size*, *text_alignment*, *z_index* and even *cross_button_color* of that notice.
48
61
 
49
62
  It also can disable the notice when notice will not be needed any more.
50
63
 
64
+ === Disable
65
+
66
+ You can disable the announcement from the admin panel when you don't want your users to see that announcement anymore.
67
+
68
+ === Html Parsing
69
+
70
+ You can even put your complete html in the text field and the output would be html parsed announcement.
71
+
72
+ === Hide
73
+
74
+ ==== Session
75
+
76
+ When a user clicks on the cross button it hides the template for that session and will not show till the session expires or disabled by admin.
77
+
78
+ ==== Cookie
79
+
80
+ When a user clicks on the cross button it hides the template and user will not be able to see that annoucement again on that broswer because cookies are permanent and also the expiry date of cookies are 1 year.
81
+
82
+ == Note
83
+
84
+ There may be the situations that you want to play with the CSS of annoucements so you can play with it.
85
+ Structure of it is like Notices is parent class for all the annoucements.
@@ -2,8 +2,8 @@ require_dependency "gubbara/application_controller"
2
2
 
3
3
  module Gubbara
4
4
  class NoticesController < ApplicationController
5
-
6
- before_action :find_notice, only: [:edit, :update, :destroy]
5
+ skip_filter *_process_action_callbacks.map(&:filter), :only => [:hide]
6
+ before_action :find_notice, only: [:edit, :update, :destroy, :hide]
7
7
 
8
8
  def new
9
9
  @notice = Gubbara::Notice.new
@@ -32,18 +32,24 @@ module Gubbara
32
32
  end
33
33
 
34
34
  def hide
35
- session[:hidden_notices] ||= []
36
- session[:hidden_notices].push(params[:id])
35
+ if @notice.base == 'session'
36
+ session[:hidden_notices] ||= []
37
+ session[:hidden_notices].push(@notice.id)
38
+ else
39
+ cookies.permanent[:hidden_public_notices] ||= ''
40
+ cookies[@notice.id.to_s] = {value: @notice.id.to_s, expires: 1.year.from_now}
41
+ cookies.permanent[:hidden_public_notices] += " #{@notice.id.to_s}"
42
+ end
37
43
  end
38
44
 
39
45
  private
40
46
 
41
47
  def find_notice
42
- @notice = Gubbara::Notice.where(id: params[:id]).take
48
+ @notice = Gubbara::Notice.where(id: params[:id]).take
43
49
  end
44
50
 
45
51
  def notice_params
46
- params.require(:notice).permit(:message, :active, :background_color, :font_color, :font_size, :text_align, :cross_button_color, :z_index)
52
+ params.require(:notice).permit(:message, :active, :background_color, :font_color, :font_size, :text_align, :cross_button_color, :z_index, :base)
47
53
  end
48
54
  end
49
55
  end
@@ -1,7 +1,12 @@
1
1
  module Gubbara
2
2
  module ApplicationHelper
3
- def list_notices
4
- session[:hidden_notices] ? @notices = Gubbara::Notice.where("gubbara_notices.id not in (?) and gubbara_notices.active not in (?)", session[:hidden_notices], false) : @notices = Gubbara::Notice.where("gubbara_notices.active not in (?)", false)
3
+ def user_announcements
4
+ session[:hidden_notices] ? @notices = Gubbara::Notice.where("gubbara_notices.id not in (?) and gubbara_notices.active not in (?) and gubbara_notices.base not in (?)", session[:hidden_notices], false, 'cookie') : @notices = Gubbara::Notice.where("gubbara_notices.active not in (?) and gubbara_notices.base not in (?)", false, 'cookie')
5
+ render(:partial => 'gubbara/application/fetch_notices', locale: {notices: @notices})
6
+ end
7
+
8
+ def public_announcements
9
+ cookies[:hidden_public_notices] ? @notices = Gubbara::Notice.where("gubbara_notices.id not in (?) and gubbara_notices.active not in (?) and gubbara_notices.base not in (?)", cookies[:hidden_public_notices].split, false, 'session') : @notices = Gubbara::Notice.where("gubbara_notices.active not in (?) and gubbara_notices.base not in (?)", false, 'session')
5
10
  render(:partial => 'gubbara/application/fetch_notices', locale: {notices: @notices})
6
11
  end
7
12
  end
@@ -1,5 +1,5 @@
1
1
  <div class="notice_panel notice_<%= user_notice.id %>" style="background: <%= user_notice.background_color %>; width: 100%; position: relative; float: left; clear: both; padding: 10px 10px; text-align: <%= user_notice.text_align %>; font-size: <%= user_notice.font_size %>; z-index: <%= user_notice.z_index %>; line-height: normal;">
2
- <p style="margin: 0px; padding: 0px; line-height: normal; color: <%= user_notice.font_color%>;"><%= user_notice.message %></p>
2
+ <p style="margin: 0px; padding: 0px; line-height: normal; color: <%= user_notice.font_color%>;"><%= user_notice.message.html_safe %></p>
3
3
 
4
4
  <div style="position: absolute; top: 8px; color: #ffffff; font-size: 14px; right: 15px; z-index: 101;"><%= link_to 'X', gubbara.hide_notice_path(user_notice), method: :post, remote: true, title: 'X', class: 'cross_button', style: "color: #{user_notice.cross_button_color};" %></div>
5
5
  </div>
@@ -47,6 +47,13 @@
47
47
  <%= f.check_box :active %>
48
48
  </div>
49
49
  </div>
50
+ <div class="form-group">
51
+ <%= f.label :base, class: 'control-label col-sm-4' %>
52
+ <div class="col-sm-4">
53
+ Session <%= f.radio_button :base, 'session', checked: true %>
54
+ Cookie <%= f.radio_button :base, 'cookie' %>
55
+ </div>
56
+ </div>
50
57
  <div class="actions">
51
58
  <div class="col-sm-offset-4 col-sm-4">
52
59
  <% if params[:action] == 'edit' %>
@@ -14,6 +14,7 @@
14
14
  <th>text_align</th>
15
15
  <th>cross_button_color</th>
16
16
  <th>z_index</th>
17
+ <th>base</th>
17
18
  <th>Actions</th>
18
19
  </tr>
19
20
  </thead>
@@ -29,6 +30,7 @@
29
30
  <td><%= notice.text_align %></td>
30
31
  <td><%= notice.cross_button_color %></td>
31
32
  <td><%= notice.z_index %></td>
33
+ <td><%= notice.base %></td>
32
34
  <td><%= link_to 'Edit', edit_notice_path(notice) %>
33
35
  <%= link_to 'Delete', notice, action: :delete, method: :delete %></td>
34
36
  </tr>
@@ -9,6 +9,7 @@ class CreateGubbaraNotices < ActiveRecord::Migration
9
9
  t.string :text_align, default: 'center'
10
10
  t.string :cross_button_color, default: '#ffffff'
11
11
  t.string :z_index, default: '9999'
12
+ t.string :base
12
13
 
13
14
  t.timestamps
14
15
  end
@@ -1,3 +1,3 @@
1
1
  module Gubbara
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gubbara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - nitanshu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-26 00:00:00.000000000 Z
11
+ date: 2017-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,9 +24,10 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: It helps admin to announce anything to every user in the system in a
28
- form of a notice which is configurable also every user has an option to hide it
29
- and will not appear till session expires or disabled by admin.
27
+ description: 'It helps admin to announce anything including pasrsed html in a form
28
+ a notice.It consists two types of announcements: Session Based: Only for logged
29
+ in users.(Application Layout), Cookie Based: For all users visting the website.(Public
30
+ Layout)'
30
31
  email:
31
32
  - nitanshu1991@gmail.com
32
33
  executables: []