poodle-rb 0.0.2 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2ca791eda4b23318a33562f0818eadb0d144ae4
4
- data.tar.gz: 79cfb6567c5df79a5d224c4becb1d7b57222db86
3
+ metadata.gz: e4639f86da6f008126a69fa0ccbb2abef87c9c9e
4
+ data.tar.gz: f968ce10264e5061d67c34ddb8f65b7582308d9c
5
5
  SHA512:
6
- metadata.gz: ab99d5ac000f12351abc3b0a0dc0b51c148d2d129144544c4bf9e948ed463321815600fa6dcaf1a5cc42ad54e30326d39c23fc48038f92fe822a3c52c7ad8b47
7
- data.tar.gz: 6b45a6695a6507eea8a8fed409ac743197ca33c5c87592f02843db4d495c2233c6170d90b993d874fc4402069cd60153c3a87929320bead53ff5b59f94092caf
6
+ metadata.gz: f1ac95425ece844e1a44acdd32abce8afcbab171a8fda9ec0ced780ea2db9c56e6aba080de27b2fda4365b5c396f93a3a876d5f4d4ffdc316412051201581d32
7
+ data.tar.gz: 7da690ff6b6aac9684c46c018cfaab55efbb1a9b923b063c910a6c60c293c309044b765446af953427266be9c91febefc7498cb9cd7bda7e2d56c9a6f3dc7991
@@ -48,3 +48,13 @@ function closeModal(modalId){
48
48
  }
49
49
  $('#' + modalId).modal('hide');
50
50
  }
51
+
52
+ function initPopovers(){
53
+ $('[data-toggle="popover"]').popover()
54
+ }
55
+ initPopovers();
56
+
57
+ function initTooltip(){
58
+ $('[data-toggle="tooltip"]').tooltip()
59
+ }
60
+ initTooltip();
@@ -1,15 +1,2 @@
1
1
  class Poodle::ApplicationController < ActionController::Base
2
-
3
- ## This filter method is used to fetch current user
4
- before_filter :current_user
5
-
6
- include Poodle::ParamsParserHelper
7
- include Poodle::FlashHelper
8
- include Poodle::UrlHelper
9
- include Poodle::TitleHelper
10
- include Poodle::ImageHelper
11
- include Poodle::NavigationHelper
12
- include Poodle::SessionsHelper
13
- include Poodle::NotificationHelper
14
-
15
2
  end
@@ -1,7 +1,9 @@
1
1
  module Poodle
2
2
  module DisplayHelper
3
-
4
- def scrap_word(text, char_count_limit, more_text = nil, more_link = nil,style='')
3
+ # Example
4
+ # scrap_word(long_text, 120)
5
+ # scrap_word(long_text, 120, "Read More", read_more_url)
6
+ def scrap_word(text, char_count_limit, more_text = nil, more_link = nil, style='')
5
7
  # remove HTML tags
6
8
  text = text.to_s.gsub(/<\/?[^>]*>/, " ")
7
9
  # remove additional spaces
@@ -28,9 +30,8 @@ module Poodle
28
30
  return teaser
29
31
  end
30
32
 
31
- def display_time(disp_time, class_name = nil)
32
- return distance_of_time_in_words_to_now(disp_time) + " ago"
33
+ def display_time(time)
34
+ distance_of_time_in_words_to_now(time) + (time > Time.now ? " from now" : " ago")
33
35
  end
34
-
35
36
  end
36
37
  end
@@ -1,14 +1,44 @@
1
1
  module Poodle
2
2
  module FlashHelper
3
-
4
- ## This function will set a flash message depending up on the request type (ajax - xml http or direct http)
5
- ## example : store_flash_message("The message has been sent successfully", :success)
6
- def store_flash_message(message, type)
3
+ # This function will set a flash message depending up on the request type (ajax - xml http or direct http)
4
+ # Example
5
+ # set_flash_message("The message has been sent successfully", :success)
6
+ # set_flash_message("Permission denied", :error)
7
+ def set_flash_message(message, type)
7
8
  if request.xhr?
8
9
  flash.now[type] = message
9
10
  else
10
11
  flash[type] = message
11
12
  end
12
13
  end
14
+
15
+ # Example
16
+ # message = get_flash_message()
17
+ def get_flash_message
18
+ if request.xhr?
19
+ message = flash.now[:success] || flash.now[:notice] || flash.now[:alert] || flash.now[:error]
20
+ else
21
+ message = flash[:success] || flash[:notice] || flash[:alert] || flash[:error]
22
+ end
23
+ message
24
+ end
25
+
26
+ # Example
27
+ # <div id="div_flash_message">
28
+ # <%= flash_message() -%>
29
+ # </div>
30
+ def flash_message
31
+ message = get_flash_message
32
+ cls_name = "alert-info"
33
+ cls_name = 'alert-success' if flash.now[:success] || flash[:success]
34
+ cls_name = 'alert-warning' if flash.now[:alert] || flash[:alert]
35
+ cls_name = 'alert-danger' if flash.now[:error] || flash[:error]
36
+
37
+ message = message.strip if message
38
+
39
+ content_tag(:div, class: "alert #{cls_name} fade in mb-10", "data-alert" => "alert") do
40
+ raw(link_to("×",nil, class: "close", "data-dismiss" => "alert") + content_tag(:p, message))
41
+ end unless message.blank?
42
+ end
13
43
  end
14
44
  end
@@ -1,10 +1,5 @@
1
1
  module Poodle
2
2
  module ImageHelper
3
-
4
- DEFAULT_PLACE_HOLDER_HEIGHT = 60
5
- DEFAULT_PLACE_HOLDER_WIDTH = 100
6
- DEFAULT_PLACE_HOLDER_TEXT = "<No Image>"
7
-
8
3
  # This method only works with carrier wave way of doing.
9
4
  # eg: user.profile_picture.image.large.url
10
5
  # Usage:
@@ -47,30 +42,6 @@ module Poodle
47
42
  return image_tag img_url, class: hsh[:class], style: "width:#{hsh[:width]};height:#{hsh[:height]};#{hsh[:style]}"
48
43
  end
49
44
 
50
- def display_user_image(user, hsh)
51
- hsh[:width] = "100%" unless hsh[:width]
52
- hsh[:height] = "auto" unless hsh[:height]
53
-
54
- ph = hsh.has_key?(:place_holder) ? hsh[:place_holder] : {}
55
- ph[:width] = ph.has_key?(:width) ? ph[:width] : DEFAULT_PLACE_HOLDER_WIDTH
56
- ph[:height] = ph.has_key?(:height) ? ph[:height] : DEFAULT_PLACE_HOLDER_HEIGHT
57
- ph[:text] = ph.has_key?(:text) ? ph[:text] : DEFAULT_PLACE_HOLDER_TEXT
58
- hsh[:place_holder] = ph
59
-
60
- hsh[:style] = "" unless hsh[:style]
61
- hsh[:class] = "" unless hsh[:class]
62
- hsh[:size] = "thumb" unless hsh[:size]
63
- hsh[:url_domain] = "http://localhost:3000" unless hsh[:url_domain]
64
-
65
- if user.send("#{hsh[:size]}_url").blank?
66
- url = "http://placehold.it/#{ph[:width]}x#{ph[:height]}&text=#{ph[:text]}"
67
- else
68
- url = hsh[:url_domain] + user.send("#{hsh[:size]}_url")
69
- end
70
-
71
- return image_tag url, class: hsh[:class], style: "width:#{hsh[:width]};height:#{hsh[:height]};#{hsh[:style]}"
72
- end
73
-
74
45
  ## Returns new photo url or edit existing photo url based on
75
46
  # object is associated with photo or not
76
47
  # == Examples
@@ -78,11 +49,10 @@ module Poodle
78
49
  # => "/admin/images/new" OR
79
50
  # => "/admin/images/1/edit"
80
51
  def upload_image_link(object, redirect_url, assoc_name=:photo)
81
-
82
52
  photo_object = nil
83
53
  photo_object = object.send(assoc_name) if object.respond_to?(assoc_name)
84
- #binding.pry
85
- if photo_object.present?
54
+
55
+ if photo_object.present? && photo_object.persisted?
86
56
  edit_admin_image_path(photo_object,
87
57
  :redirect_url => redirect_url,
88
58
  :imageable_id => object.id,
@@ -1,4 +1,39 @@
1
1
  module Poodle
2
2
  module MetaTagsHelper
3
+ def meta_tags
4
+ return "" unless @meta_tags
5
+ @meta_tags.reverse_merge!(
6
+ "robots" => :all,
7
+ "viewport" => "width=device-width, initial-scale=1.0",
8
+ "copyright" => "2015 K P Varma",
9
+ "content-language" => "en",
10
+ "resource-type" => "document",
11
+ "distribution" => "global",
12
+ "rating" => "general"
13
+ )
14
+
15
+ link_tags_list = []
16
+ meta_tags_list = []
17
+
18
+ {
19
+ prev: :rel_prev,
20
+ next: :rel_next,
21
+ canonical: :canonical
22
+ }.each do |k, v|
23
+ link_tags_list << content_tag(:link, "", rel: k, href: v) if @meta_tags[k]
24
+ end
25
+
26
+ {
27
+ meta_description: :meta_description,
28
+ meta_keywords: :meta_keywords,
29
+ keywords: :keywords,
30
+ robots: :robots
31
+ }.each do |k, v|
32
+ meta_tags_list << content_tag(:meta, "", name: k, content: v) if @meta_tags[k]
33
+ end
34
+
35
+ raw(link_tags_list.join(" ") + meta_tags_list.join(" "))
36
+
37
+ end
3
38
  end
4
39
  end
@@ -1,6 +1,5 @@
1
1
  module Poodle
2
2
  module NavigationHelper
3
-
4
3
  def nav_active?(name)
5
4
  @nav == name
6
5
  end
@@ -1,6 +1,5 @@
1
1
  module Poodle
2
2
  module ParamsParserHelper
3
-
4
3
  def parse_pagination_params
5
4
  @current_page = params[:page] || "1"
6
5
  @per_page = params[:per_page] || Poodle.configuration.items_per_list.to_s
@@ -1,6 +1,5 @@
1
1
  module Poodle
2
2
  module TitleHelper
3
-
4
3
  def set_heading(heading)
5
4
  @heading = heading
6
5
  end
@@ -1,6 +1,5 @@
1
1
  module Poodle
2
2
  module UrlHelper
3
-
4
3
  def add_query_params(url, params)
5
4
  parsed_uri = URI(url)
6
5
 
@@ -2,7 +2,7 @@
2
2
  <html lang="en" class="no-js">
3
3
  <head>
4
4
  <title><%= title -%></title>
5
- <%= render :partial=>"/layouts/poodle/common/meta_tags" -%>
5
+ <%= meta_tags %>
6
6
  <link rel="icon" href="/assets/favicon.ico" type="image/png">
7
7
  <%= stylesheet_link_tag "poodle/application", :media => "all" -%>
8
8
  <%= csrf_meta_tags -%>
@@ -25,8 +25,8 @@
25
25
  </div>
26
26
 
27
27
  <%#* Show flash messages if controller has set any. -%>
28
- <div id="div_flash_message" class="container-fluid" >
29
- <%= render :partial=>"/layouts/poodle/common/flash_message" -%>
28
+ <div id="div_flash_message">
29
+ <%= flash_message() -%>
30
30
  </div>
31
31
 
32
32
  <%#* Page Content Starts here -%>
@@ -47,7 +47,7 @@
47
47
  <%= render :partial=>"/layouts/poodle/common/overlays" -%>
48
48
 
49
49
  <%#* Loading Javascripts -%>
50
- <%= javascript_include_tag "poodle/application" -%>
50
+ <%= javascript_include_tag "application" -%>
51
51
 
52
52
  <%= yield :javascript_footer -%>
53
53
 
@@ -2,7 +2,7 @@
2
2
  <html lang="en" class="no-js">
3
3
  <head>
4
4
  <title><%= title -%></title>
5
- <%= render :partial=>"/layouts/poodle/common/meta_tags" -%>
5
+ <%= meta_tags %>
6
6
  <link rel="icon" href="/assets/favicon.ico" type="image/png">
7
7
  <%= stylesheet_link_tag "poodle/application", :media => "all" -%>
8
8
  <%= csrf_meta_tags -%>
@@ -19,8 +19,8 @@
19
19
  </div>
20
20
 
21
21
  <%#* Show flash messages if controller has set any. -%>
22
- <div id="div_flash_message" class="container-fluid" >
23
- <%= render :partial=>"/layouts/poodle/common/flash_message" -%>
22
+ <div id="div_flash_message">
23
+ <%= flash_message() -%>
24
24
  </div>
25
25
 
26
26
  <%#* Page Content Starts here -%>
@@ -39,7 +39,7 @@
39
39
  <%= render :partial=>"/layouts/poodle/common/overlays" -%>
40
40
 
41
41
  <%#* Loading Javascripts -%>
42
- <%= javascript_include_tag "poodle/application" -%>
42
+ <%= javascript_include_tag "application" -%>
43
43
 
44
44
  <%= yield :javascript_footer -%>
45
45
 
@@ -17,7 +17,8 @@
17
17
  %>
18
18
  <div class="panel panel-default mt-10">
19
19
  <div class="panel-heading">
20
- <h3 class="panel-title"><%= heading %>
20
+ <h3 class="panel-title">
21
+ <%= heading %>
21
22
  <span class="pull-right">
22
23
  <% if minimizable %>
23
24
  <a href="#" class="panel-minimize"><i class="fa fa-chevron-up"></i></a>
@@ -0,0 +1,70 @@
1
+ <%
2
+ unless(defined?(heading) && heading)
3
+ heading = "More Details"
4
+ end
5
+ unless(defined?(minimizable) && minimizable)
6
+ minimizable = false
7
+ end
8
+ unless(defined?(closable) && closable)
9
+ closable = false
10
+ end
11
+ unless(defined?(display_footer) && display_footer)
12
+ display_footer = false
13
+ end
14
+ unless(defined?(data_columns) && data_columns)
15
+ data_columns = data_model.class.column_names.map{|x| x.to_sym}
16
+ end
17
+ %>
18
+
19
+ <h4 class="text-color-gray"><%= heading %></h3>
20
+
21
+ <table class="table table-condensed table-hover table-striped mt-20">
22
+ <thead>
23
+ <tr>
24
+ <th>Sl.</th>
25
+ <th>Attribute</th>
26
+ <th>Value</th>
27
+ </tr>
28
+ </thead>
29
+ <tbody>
30
+
31
+ <% data_model.class.column_names.each_with_index do |column, index| %>
32
+ <% next unless data_columns.include?(column.to_sym) %>
33
+ <% next if (column.include?("token") || column.include?("password")) %>
34
+ <% if column.include?("_id") %>
35
+ <% assoc_object = data_model.send(column.gsub("_id", "").to_sym) %>
36
+ <tr class="text-color-gray">
37
+ <td><%= index + 1 %>.</td>
38
+ <td class="bold"><%= column.titleize %></td>
39
+ <% case assoc_object.class.name %>
40
+ <% when "Designation" %>
41
+ <td><%= assoc_object.title %></td>
42
+ <% when "Department" %>
43
+ <td><%= assoc_object.name %></td>
44
+ <% else %>
45
+ <td><%= assoc_object.class %> not recogonized</td>
46
+ <% end %>
47
+ </tr>
48
+ <% else %>
49
+ <% value = data_model.send(column) %>
50
+ <tr class="text-color-gray">
51
+ <td><%= index + 1 %>.</td>
52
+ <td class="bold"><%= column.titleize %></td>
53
+ <% case value.class.to_s %>
54
+ <% when "Time" %>
55
+ <td><%= display_time(value) %></td>
56
+ <% else %>
57
+ <td><%= value.blank? ? "<not set>" : value %></td>
58
+ <% end %>
59
+ </tr>
60
+ <% end %>
61
+
62
+ <% end %>
63
+
64
+ </tbody>
65
+ </table>
66
+
67
+ <% if display_footer %>
68
+ <%= link_to raw("<i class=\"icon-pencil icon-white mr-5\"></i> Edit"), edit_link, :class=>"btn btn-default btn-xs pull-right ml-10", :remote=>true if defined?(edit_link) && edit_link %>
69
+ <%= link_to raw("<i class=\"icon-remove \"></i> Delete"), delete_link, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-xs pull-right", :remote=>true if defined?(delete_link) && delete_link %>
70
+ <% end %>
@@ -0,0 +1,224 @@
1
+ module Poodle
2
+ module ActionView
3
+ # This module creates Bootstrap wrappers around basic View Tags
4
+ module FormHelper
5
+ # Example 1
6
+ #
7
+ # theme_form_group("Student Name") do
8
+ # text_field_tag(:student, :name)
9
+ # end
10
+ #
11
+ # is equivalent to:
12
+ #
13
+ # <div class="form-group ">
14
+ # <label for="inp_name" class="col-md-4 control-label">Student Name
15
+ # <span class="text-color-red ml-10 mr-5 pull-right">*</span>
16
+ # </label>
17
+ # <div class="col-md-8">
18
+ # <%= text_field_tag(:student, :name) %>
19
+ # </div>
20
+ # </div>
21
+ #
22
+ # ---------------------------
23
+ #
24
+ # Example 2
25
+ #
26
+ # theme_form_group("Please select a Movie", required: false) do
27
+ # collection_select(@movie_ticket, :movie_id, movies_list, :id, name, {:prompt=>true}, {:class => 'form-control'})
28
+ # end
29
+ #
30
+ # is equivalent to:
31
+ #
32
+ # <div class="form-group ">
33
+ # <label for="inp_movie_id" class="col-md-4 control-label">
34
+ # Please select a Movie
35
+ # </label>
36
+ # <div class="col-md-8">
37
+ # <%= collection_select(@movie_ticket, :movie_id, movies_list, :id, name, {:prompt=>true}, {:class => 'form-control'}) %>
38
+ # </div>
39
+ # </div>
40
+
41
+ # Example 3
42
+ # if you want to change the label div column width which is by default set to "col-md-4"
43
+ # and field div column width which is by default set to "col-md-8" by passing label_col_class and field_col_class
44
+ #
45
+ # theme_form_group("Please select a Movie", label_col_class: "col-md-6", field_col_class: "col-md-6") do
46
+ # ....
47
+ # end
48
+ #
49
+
50
+ # Example 4
51
+ # If you want to add error_class to form-group div tag you can pass it through options
52
+ #
53
+ # theme_form_group("Please select a Movie", error_class: "error-class") do
54
+ # ....
55
+ # end
56
+ #
57
+
58
+ def theme_form_group(label, **options)
59
+ options.reverse_merge!(
60
+ error_class: "",
61
+ param_name: label.gsub(" ", "_").underscore,
62
+ required: true,
63
+ label_col_class: "col-md-4",
64
+ field_col_class: "col-md-8"
65
+ )
66
+
67
+ content_tag(:div, class: "form-group #{options[:error_class]}") do
68
+ content_tag(:label, class: "#{options[:label_col_class]} control-label") do
69
+ star_content = options[:required] ? "*" : raw("&nbsp;&nbsp;")
70
+ raw(label + content_tag(:span, star_content, class: "text-color-red ml-10 mr-5 pull-right"))
71
+ end +
72
+ content_tag(:div, class: options[:field_col_class]) do
73
+ if block_given?
74
+ yield
75
+ else
76
+ "No Block Passed"
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ # Creates the form group with label, and text field
83
+ # Supports the following input type: "text", "email", "search", "password", "date", "time", "tel", "url", "month"
84
+ # Example
85
+ # theme_form_field(@project, :name)
86
+ #
87
+ # <div class="form-group ">
88
+ # <label class="col-md-4 control-label" for="inp_name">
89
+ # Name
90
+ # <span class="text-color-red ml-10 mr-5 pull-right">*</span>
91
+ # </label>
92
+ # <div class="col-md-8">
93
+ # <input class="text input form-control" id="inp_name" name="link_type[name]" placeholder="" type="text">
94
+ # </div>
95
+ # </div>
96
+
97
+ def theme_form_field(object, field_name, **options)
98
+ options.symbolize_keys!
99
+ options.reverse_merge!(
100
+ object_name: object.class.name.underscore,
101
+ label: field_name.to_s.gsub("_", " ").titleize,
102
+ required: true,
103
+ error_class: "has-errors",
104
+ html_options: {}
105
+ )
106
+ options.reverse_merge!(
107
+ param_name: "#{options[:object_name]}[#{field_name}]"
108
+ )
109
+ error_class = object.errors[field_name.to_s].any? ? options[:error_class] : ""
110
+
111
+ theme_form_group(options[:label], required: options[:required], error_class: error_class) do
112
+ options[:html_options].reverse_merge!(
113
+ type: "text",
114
+ id: "inp_#{options[:label].to_s.gsub(" ", "_").downcase}",
115
+ class: "text input form-control",
116
+ place_holder: ""
117
+ )
118
+ case options[:html_options][:type].to_sym
119
+ when :text, :email, :search, :password, :date, :time, :tel, :url, :month
120
+ text_field_tag(options[:param_name], object.send(field_name.to_s), **options[:html_options])
121
+ when :textarea
122
+ options[:html_options].merge!(style: "height: 80px;")
123
+ text_area_tag(options[:param_name], object.send(field_name.to_s), **options[:html_options])
124
+ when :file
125
+ file_field_tag(options[:param_name], object.send(field_name.to_s), **options[:html_options])
126
+ when :checkbox
127
+ options[:html_options][:class] = "checkbox mt-10"
128
+ check_box_tag(options[:param_name], field_name, object.send(field_name.to_s), **options[:html_options])
129
+ end
130
+ end
131
+
132
+ end
133
+
134
+ # Example
135
+ # assoc_collection = Client.select("id, name").order("name ASC").all
136
+ # options = {assoc_object: client, assoc_display_method: :name, assoc_collection: Client.select("id, name").order("name ASC").all, label: "Client", required: true}
137
+ # theme_form_assoc_group(project, :client_id, **options)
138
+ # is equivalent to:
139
+ # ---------------------------
140
+ # <% Choose Client - Drop Down %>
141
+ # <div class="form-group ">
142
+ # <label for="inp_name" class="col-md-4 control-label">
143
+ # Client
144
+ # <span class="text-color-red ml-10 mr-5 pull-right">*</span>
145
+ # </label>
146
+ # <div class="col-md-8">
147
+ # <% if editable && @client %>
148
+ # <%= @client.name %>
149
+ # <%= hidden_field_tag "project[client_id]", @client.id %>
150
+ # <% else %>
151
+ # <%= collection_select(:project, :client_id, Client.select("id, name").order("name ASC").all, :id, :name, {:prompt=>true}, {:class => 'form-control'}) %>
152
+ # <% end %>
153
+ # </div>
154
+ # </div>
155
+ def theme_form_assoc_group(object, foreign_key, **options)
156
+ options.symbolize_keys!
157
+ assoc_method_name = foreign_key.to_s.chomp("_id")
158
+ options.reverse_merge!(
159
+ assoc_object: object.respond_to?(assoc_method_name) ? object.send(assoc_method_name) : nil,
160
+ assoc_display_method: :name,
161
+ assoc_collection: [],
162
+ param_name: object.class.name.underscore,
163
+ object_name: object.class.name.underscore,
164
+ required: true,
165
+ label: foreign_key.to_s.titleize,
166
+ prompt: true,
167
+ editable: true,
168
+ error_class: "has-errors"
169
+ )
170
+
171
+ error_class = object.errors[foreign_key.to_s].any? ? options[:error_class] : ""
172
+
173
+ theme_form_group(options[:label], required: options[:required], error_class: options[:error_class]) do
174
+ if !options[:editable] && options[:assoc_object]
175
+ raw(options[:assoc_object].send(options[:assoc_display_method]) + hidden_field_tag("#{options[:param_name]}[#{foreign_key}]", options[:assoc_object].id))
176
+ else
177
+ collection_select(options[:object_name], foreign_key, options[:assoc_collection], :id, options[:assoc_display_method], {:prompt=>options[:prompt]}, {:class => 'form-control'})
178
+ end
179
+ end
180
+
181
+ end
182
+
183
+ # Example
184
+ # roles = ConfigCenter::Roles::LIST
185
+ # options_list = Array[*roles.collect {|v,i| [v,v] }].sort
186
+ # theme_form_select_group(f, @proposal, :plan, options_list, label: "Choose Plan", param_name: "proposal[:plan]", prompt: true)
187
+ # is equivalent to:
188
+ # ---------------------------
189
+ # <div class="form-group ">
190
+ # <label for="inp_name" class="col-md-4 control-label">Choose Plan
191
+ # <span class="text-color-red ml-10 mr-5 pull-right">*</span>
192
+ # </label>
193
+ # <div class="col-md-8">
194
+ # <% options_list = ConfigCenter::Roles::LIST %>
195
+ # <%= f.select("proposal[:plan]", options_for_select(options_list, :selected => f.object.name), {:prompt=>true}, {:class => 'form-control'}) %>
196
+ # </div>
197
+ # </div>
198
+ def theme_form_select_group(form, object, field_name, options_list, **options)
199
+ options.reverse_merge!(
200
+ label: "Label",
201
+ param_name: "Param",
202
+ prompt: true,
203
+ error_class: "has-errors",
204
+ required: false
205
+ )
206
+ error_class = object.errors[field_name.to_s].any? ? options[:error_class] : ""
207
+ theme_form_group(options[:label], required: options[:required], error_class: options[:error_class]) do
208
+ form.select(options[:param_name], options_for_select(options_list, :selected => form.object.name), {:prompt=>options[:prompt]}, {:class => 'form-control'})
209
+ end
210
+ end
211
+
212
+ # Creates a submit button with basic styles
213
+ # Example
214
+ # submit_tag button_text, "data-reset-text"=>button_text, "data-loading-text"=>"Saving ...", :class=>"btn btn-primary ml-10"
215
+ # is equivalent to:
216
+ # ---------------------------
217
+ # submit_tag button_text, "data-reset-text"=>button_text, "data-loading-text"=>"Saving ...", :class=>"btn btn-primary ml-10"
218
+ def theme_form_button(object, button_text="", saving_message="Saving ...")
219
+ button_text = "#{object.new_record? ? "Create" : "Update"}" if button_text.blank?
220
+ submit_tag(button_text, "data-reset-text"=>button_text, "data-loading-text"=>saving_message, :class=>"btn btn-primary ml-10")
221
+ end
222
+ end
223
+ end
224
+ end
@@ -0,0 +1,7 @@
1
+ module Poodle
2
+ module ActionView
3
+ # This module creates Bootstrap wrappers around basic View Tags
4
+ module ModalHelper
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,350 @@
1
+ module Poodle
2
+ module ActionView
3
+ # This module creates Bootstrap wrappers around basic View Tags
4
+ module ThemeHelper
5
+ # theme_fa_icon('plus')
6
+ # <i class='fa fa-plus mr-10'></i>
7
+ # theme_fa_icon('plus', 'lg')
8
+ # <i class='fa fa-plus fa-lg mr-10'></i>
9
+ def theme_fa_icon(icon_text, size="")
10
+ "<i class='fa fa-#{icon_text} #{size.blank? ? "" : "fa-"+size}'></i>"
11
+ end
12
+
13
+ # theme_button_text('New Project')
14
+ # <span class='btn-text'> New Project</span>
15
+ def theme_button_text(text)
16
+ "<span class='btn-text'> #{text}</span>"
17
+ end
18
+
19
+ # theme_button is used to create poodle like buttons which has built in classes and icons
20
+ # e.g:
21
+ # theme_button('New Project', 'plus', new_admin_project_path)
22
+ # The above is equivalent to
23
+ # link_to raw("<i class='fa fa-plus mr-10'></i><span class='btn-text'> New Project</span>"), new_admin_project_path, :class=>"btn btn-primary pull-right ml-5", :remote=>true
24
+ # And produces the following html
25
+ # <a class="btn btn-primary pull-right ml-5" data-remote="true" href="/admin/projects/new"><i class="fa fa-plus mr-10"></i><span class="btn-text"> New Project</span></a>
26
+ def theme_button(text, icon, url, options={})
27
+ options.reverse_merge!(
28
+ method: :get,
29
+ remote: true,
30
+ btn_type: :primary,
31
+ btn_size: :md,
32
+ classes: "pull-right ml-5 mb-5",
33
+ data: {}
34
+ )
35
+ display_content = raw(theme_fa_icon(icon)+theme_button_text(text))
36
+ link_to(display_content, url, :class=>"btn btn-#{options[:btn_type]} btn-#{options[:btn_size]} #{options[:classes]}", :remote=>options[:remote], method: options[:method], data: options[:data])
37
+ end
38
+
39
+ # Example
40
+ # theme_edit_button(edit_admin_project_path(@project))
41
+ # is equivalent to:
42
+ # ---------------------------
43
+ # link_to raw("<i class=\"fa fa-edit mr-5\"></i> Edit"), edit_admin_project_path(@project), :class=>"btn btn-default btn-xs pull-right ml-10", :remote=>true %>
44
+ def theme_edit_button(url, options={})
45
+ options.reverse_merge!(
46
+ text: "Edit",
47
+ icon: "edit",
48
+ method: :get,
49
+ remote: true,
50
+ btn_type: :default,
51
+ btn_size: :xs,
52
+ classes: "pull-right ml-10"
53
+ )
54
+ theme_button(options[:text], options[:icon], url, options)
55
+ end
56
+
57
+ # Example
58
+ # theme_delete_button(admin_project_path(@project))
59
+ # is equivalent to:
60
+ # ---------------------------
61
+ # link_to raw("<i class=\"fa fa-trash \"></i> Delete"), admin_project_path(@project), method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-xs pull-right", :remote=>true
62
+ def theme_delete_button(url, options={})
63
+ options.reverse_merge!(
64
+ text: "Delete",
65
+ icon: "trash",
66
+ method: :delete,
67
+ remote: true,
68
+ btn_type: :danger,
69
+ btn_size: :xs,
70
+ classes: "pull-right ml-10",
71
+ data: { confirm: 'Are you sure?' }
72
+ )
73
+ theme_button(options[:text], options[:icon], url, options)
74
+ end
75
+
76
+ # theme_heading(heading)
77
+ # theme_heading(heading, icon='cog')
78
+ # <div class="row mb-10">
79
+ # <div class="fs-22 col-sm-12"><i class='fa fa-rub fa-lg mr-10'></i>Manage Projects</div>
80
+ # </div>
81
+ def theme_heading(heading, icon='rub')
82
+ content_tag :div, class: "row mb-10" do
83
+ content_tag :div, class: "fs-22 col-sm-12" do
84
+ raw((icon ? theme_fa_icon(icon, 'lg') : "") + " #{heading}")
85
+ end
86
+ end
87
+ end
88
+
89
+ # theme_search_form is a helper to create a form to filter the results by entering a search query
90
+ def theme_search_form(cls, url, method=:get, remote=true, text="Search!")
91
+ form_for cls.new, :url => url,
92
+ :method => method, :remote=>remote,
93
+ :html=>{:class=>"pull-right", :style=>"margin-bottom:0px;"} do |f|
94
+ content_tag :div, class: "input-group" do
95
+ text_field_tag('query','', :class => 'form-control', :placeholder => 'Search ...') +
96
+ content_tag(:span, class: "input-group-btn") do
97
+ button_tag(type: 'submit', class: "btn btn-default") do
98
+ raw(theme_fa_icon('search') +
99
+ content_tag(:span, class: "btn-text") do
100
+ " " + text
101
+ end)
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ def theme_drop_down(collection, method_name)
109
+ content_tag(:div, class: "btn-group mt-10 mb-10", style: "width:100%;") do
110
+ button_tag(type: 'button', :class => "btn btn-default btn-block dropdown-toggle", "data-toggle" => "dropdown") do
111
+ raw("Choose a Project" + content_tag(:span, "", class: "caret"))
112
+ end +
113
+ content_tag(:ul, class: "dropdown-menu", role: "menu") do
114
+ li_array = []
115
+ collection.each do |item|
116
+ li_array << content_tag(:li) do
117
+ link_to item.send(method_name), url_for([:admin, item]), :remote => true
118
+ end
119
+ end
120
+ raw(li_array.join(" ")) +
121
+ content_tag(:li, link_to_next_page(collection, 'Next Page', :remote => true)) +
122
+ content_tag(:li, link_to_previous_page(collection, 'Previous Page', :remote => true))
123
+ end
124
+ end
125
+ end
126
+
127
+ def clear_tag(height)
128
+ content_tag(:div, "", class: "cl-#{height}")
129
+ end
130
+
131
+ # Example
132
+ # theme_paginate(@projects)
133
+ #
134
+ # is equivalent to:
135
+ # ---------------------------
136
+ # <div class="cl"></div>
137
+ # <% if @projects.any? %>
138
+ # <%= content_tag :div, :class=>"pull-right" do %>
139
+ # <%= paginate @projects, :remote => true %>
140
+ # <% end %>
141
+ # <% end %>
142
+ # <div class="cl"></div>
143
+ # ---------------------------
144
+ def theme_paginate(collection)
145
+ return "" if collection.empty?
146
+ clear_tag(10) +
147
+ content_tag(:div, :class=>"pull-right") do
148
+ paginate(collection, :remote => true)
149
+ end +
150
+ clear_tag(10)
151
+ end
152
+
153
+ # Example
154
+ # theme_panel_message("No Results found")
155
+ #
156
+ # is equivalent to:
157
+ # ---------------------------
158
+ # <div class="panel panel-default text-color-grey p-80 text-align-center" style="height:200px;">
159
+ # "No Results found"
160
+ # </div>
161
+ def theme_panel_message(message)
162
+ content_tag(:div, class: "panel panel-default panel-message text-color-grey p-80 text-align-center", style: "height:200px;") do
163
+ raw(message)
164
+ end
165
+ end
166
+
167
+ # Example
168
+ # theme_panel_title("Team Members")
169
+ #
170
+ # is equivalent to:
171
+ # ---------------------------
172
+ # <h3 class="panel-title">Team Members</h3>
173
+ def theme_panel_title(title)
174
+ content_tag(:h3, title, class: "panel-title")
175
+ end
176
+
177
+ # Example
178
+ # theme_item_title(project.name, admin_project_path(project))
179
+ #
180
+ # is equivalent to:
181
+ # ---------------------------
182
+ # <%= link_to project.name, admin_project_path(project), :remote=>true, :class=>"text-color-blue fs-16" %>
183
+ def theme_item_title(title, url, classes = "text-color-blue fs-16")
184
+ link_to(title, url, :remote=>true, :class=>classes)
185
+ end
186
+
187
+ # Example
188
+ # theme_item_sub_title(project.client.name)
189
+ #
190
+ # is equivalent to:
191
+ # ---------------------------
192
+ # <div class="text-color-red fs-14"><%= project.client.name if project.client %></div>
193
+ def theme_item_sub_title(text, classes = "text-color-red fs-14")
194
+ content_tag(:div, text, class: classes)
195
+ end
196
+
197
+ # Example
198
+ # theme_item_description(project.client.name, 120)
199
+ #
200
+ # is equivalent to:
201
+ # ---------------------------
202
+ # <div class="text-color-grey fs-12"><%= project.client.description %></div>
203
+ def theme_item_description(text, limit=120, classes = "text-color-grey fs-12")
204
+ description = scrap_word(text, limit)
205
+ content_tag(:div, description, class: classes)
206
+ end
207
+
208
+ def theme_detail_box(collection)
209
+ case params[:action]
210
+ when "show"
211
+ render partial: params[:action]
212
+ when "index"
213
+ collection.empty? ? (theme_panel_message(I18n.translate("forms.no_results_found"))) : render(partial: "show")
214
+ else
215
+ theme_panel_message(I18n.translate("forms.no_results_found"))
216
+ end
217
+ end
218
+
219
+ #<% if request.xhr? %>
220
+ # <%= render :partial=>"layouts/poodle/common/flash_message" %>
221
+ #<% end %>
222
+ def theme_flash_message
223
+ render :partial=>"layouts/poodle/common/flash_message" if request.xhr?
224
+ end
225
+
226
+ # Example
227
+ # theme_more_widget(object, data_columns=[:id, :created_at, :updated_at], super_admin = true)
228
+ # is equivalent to:
229
+ # ---------------------------
230
+ # <% if @current_user.is_super_admin? %>
231
+ # <%= render :partial => "widgets/more_details", :locals=>{
232
+ # :data_model => @project,
233
+ # :data_columns => [:id, :created_at, :updated_at],
234
+ # :heading => "Technical Details",
235
+ # :display_footer => false} %>
236
+ # <% end %>
237
+ def theme_more_widget(object, **options)
238
+ options.reverse_merge!(
239
+ data_columns: [:id, :created_at, :updated_at],
240
+ super_admin: false,
241
+ heading: "Technical Details"
242
+ )
243
+ display = options[:super_admin] ? @current_user.is_super_admin? : true
244
+ render(:partial => "widgets/more_details",
245
+ :locals=>{:data_model => object,
246
+ :data_columns => options[:data_columns],
247
+ :heading => options[:heading],
248
+ :display_footer => false}) if display
249
+ end
250
+
251
+ # Example
252
+ # theme_image(@project, admin_project_path(@project), :url, "logo.image.url")
253
+ # is equivalent to:
254
+ # ---------------------------
255
+ # <% change_picture_url = upload_image_link(@project, admin_project_path(@project), :logo) %>
256
+ # <% img_tag = display_image(@project, "logo.image.url", width: "100%", place_holder: {width: 300, height: 180, text: "<No Image>"}) %>
257
+ # <%= link_to img_tag, change_picture_url, :remote => true %>
258
+ # <%= link_to raw("<i class=\"fa fa-photo mr-5\"></i> Change Picture"), change_picture_url, :class=>"btn btn-default btn-xs mt-10", :remote=>true %>
259
+ def theme_image(object, url, assoc_name, assoc_url, options={})
260
+ options.reverse_merge!(
261
+ width: "100%",
262
+ ph: {
263
+ width: 300,
264
+ height: 180,
265
+ text: "<No Image>"
266
+ },
267
+ remote: true,
268
+ text: "Change Image",
269
+ icon: "photo",
270
+ classes: "btn btn-default btn-xs mt-10"
271
+ )
272
+ change_picture_url = upload_image_link(object, url, assoc_name)
273
+ img_tag = display_image(object, assoc_url, width: options[:width], place_holder: options[:ph])
274
+ btn_display = raw(theme_fa_icon(options[:icon])+theme_button_text(options[:text]))
275
+ link_to(img_tag, change_picture_url, :remote => options[:remote]) +
276
+ link_to(btn_display, change_picture_url, :class=>options[:classes], :remote=>options[:remote])
277
+ end
278
+
279
+ # Example
280
+ # theme_panel_heading(@project.name)
281
+ # is equivalent to:
282
+ # ---------------------------
283
+ # <div class="fs-24 text-color-green"><%= @project.name %></div>
284
+ def theme_panel_heading(text, classes="fs-24 text-color-green")
285
+ content_tag(:div, text, class: classes)
286
+ end
287
+
288
+ # Example
289
+ # theme_panel_sub_heading(@project.name, admin_client_path(@project.client))
290
+ # is equivalent to:
291
+ # ---------------------------
292
+ # link_to(@project.client.name, admin_client_path(@project.client), class: "fs-16 text-color-red")
293
+ def theme_panel_sub_heading(text, url, classes="fs-16 text-color-red")
294
+ link_to(text, url, class: classes)
295
+ end
296
+
297
+ # Example
298
+ # theme_panel_description(@project.pretty_url, "fs-14")
299
+ # theme_panel_description(@project.description, "fs-14 mt-10")
300
+ # is equivalent to:
301
+ # ---------------------------
302
+ # <div class="fs-14"><%= @project.pretty_url %></div>
303
+ # <div class="fs-14 mt-10"><%= @project.description %></div>
304
+ def theme_panel_description(text, classes="fs-14")
305
+ content_tag(:div, text, class: classes)
306
+ end
307
+
308
+ # Example
309
+ # theme_user_image(@user, @role)
310
+ # is equivalent to:
311
+ def theme_user_image(user, **options)
312
+
313
+ url_domain = defined?(QAuthRubyClient) ? QAuthRubyClient.configuration.q_auth_url : "http://localhost:3000"
314
+
315
+ options.reverse_merge!(
316
+ role: nil,
317
+ width: 60,
318
+ height: options[:width],
319
+ popover: true,
320
+ size: "thumb",
321
+ url_domain: url_domain,
322
+ place_holder: { width: options[:width], height: options[:height], text: "<No Image>" },
323
+ html_options: {
324
+ class: "",
325
+ style: "width:100%;height:auto;cursor:pointer;"
326
+ }
327
+ )
328
+
329
+ options[:html_options].reverse_merge!(
330
+ "data-toggle" => "popover",
331
+ "data-placement" => "bottom",
332
+ title: user.name,
333
+ "data-content" => (options[:role] ? options[:role].name : "")
334
+ ) if options[:popover]
335
+
336
+ if user.send("#{options[:size]}_url").blank?
337
+ url = "http://placehold.it/#{options[:place_holder][:width]}x#{options[:place_holder][:height]}&text=#{options[:place_holder][:text]}"
338
+ else
339
+ url = options[:url_domain] + user.send("#{options[:size]}_url")
340
+ end
341
+
342
+ content_tag(:div) do
343
+ content_tag(:div, class: "rounded", style: "width:#{options[:width]}px;height:#{options[:width]}px;") do
344
+ image_tag(url, options[:html_options])
345
+ end
346
+ end
347
+ end
348
+ end
349
+ end
350
+ end
data/lib/poodle/engine.rb CHANGED
@@ -1,5 +1,31 @@
1
1
  module Poodle
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace Poodle
4
+
5
+ initializer "poodle.configure_rails_initialization" do |app|
6
+ ActiveSupport.on_load :action_view do
7
+ include Poodle::ActionView::FormHelper
8
+ include Poodle::ActionView::ModalHelper
9
+ include Poodle::ActionView::ThemeHelper
10
+ end
11
+ ActiveSupport.on_load :action_controller do
12
+ include Poodle::DisplayHelper
13
+ include Poodle::FlashHelper
14
+ include Poodle::ImageHelper
15
+ include Poodle::MetaTagsHelper
16
+ include Poodle::NavigationHelper
17
+ include Poodle::ParamsParserHelper
18
+ include Poodle::TitleHelper
19
+ include Poodle::UrlHelper
20
+ helper Poodle::DisplayHelper
21
+ helper Poodle::FlashHelper
22
+ helper Poodle::ImageHelper
23
+ helper Poodle::MetaTagsHelper
24
+ helper Poodle::NavigationHelper
25
+ helper Poodle::ParamsParserHelper
26
+ helper Poodle::TitleHelper
27
+ helper Poodle::UrlHelper
28
+ end
29
+ end
4
30
  end
5
31
  end
@@ -0,0 +1,4 @@
1
+ module Poodle
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module Poodle
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/poodle-rb.rb CHANGED
@@ -1,5 +1,10 @@
1
1
  require "poodle/engine"
2
2
  require "poodle/configuration"
3
+ require 'poodle/action_view/form_helper'
4
+ require 'poodle/action_view/modal_helper'
5
+ require 'poodle/action_view/theme_helper'
6
+
7
+ require 'poodle/railtie' if defined?(Rails)
3
8
 
4
9
  module Poodle
5
10
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poodle-rb
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
  - Krishnaprasad Varma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-14 00:00:00.000000000 Z
11
+ date: 2015-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -105,7 +105,6 @@ files:
105
105
  - app/helpers/poodle/image_helper.rb
106
106
  - app/helpers/poodle/meta_tags_helper.rb
107
107
  - app/helpers/poodle/navigation_helper.rb
108
- - app/helpers/poodle/notification_helper.rb
109
108
  - app/helpers/poodle/params_parser_helper.rb
110
109
  - app/helpers/poodle/title_helper.rb
111
110
  - app/helpers/poodle/url_helper.rb
@@ -113,17 +112,18 @@ files:
113
112
  - app/views/layouts/poodle/application/_footer.html.erb
114
113
  - app/views/layouts/poodle/application/_header.html.erb
115
114
  - app/views/layouts/poodle/application/_sidebar.html.erb
116
- - app/views/layouts/poodle/common/_field.html.erb
117
- - app/views/layouts/poodle/common/_flash_message.html.erb
118
- - app/views/layouts/poodle/common/_meta_tags.html.erb
119
115
  - app/views/layouts/poodle/common/_overlays.html.erb
120
116
  - app/views/layouts/poodle/public.html.erb
121
117
  - app/views/widgets/_more_details.html.erb
122
- - config/initializers/api_errors.rb
118
+ - app/views/widgets/_more_details_table.html.erb
123
119
  - config/routes.rb
124
120
  - lib/poodle-rb.rb
121
+ - lib/poodle/action_view/form_helper.rb
122
+ - lib/poodle/action_view/modal_helper.rb
123
+ - lib/poodle/action_view/theme_helper.rb
125
124
  - lib/poodle/configuration.rb
126
125
  - lib/poodle/engine.rb
126
+ - lib/poodle/railtie.rb
127
127
  - lib/poodle/version.rb
128
128
  - lib/tasks/poodle_tasks.rake
129
129
  - test/dummy/README.rdoc
@@ -1,20 +0,0 @@
1
- module Poodle
2
- module NotificationHelper
3
-
4
- ## This function will set a flash message depending up on the request type (ajax - xml http or direct http)
5
- ## example : store_flash_message("The message has been sent successfully", :success)
6
- def store_flash_message(message, type)
7
- if request.xhr?
8
- flash.now[type] = message
9
- else
10
- flash[type] = message
11
- end
12
- end
13
-
14
- def set_notification_messages(heading, alert, not_type)
15
- @heading = heading
16
- @alert = alert
17
- store_flash_message("#{@heading}: #{@alert}", not_type) if defined?(flash) && flash
18
- end
19
- end
20
- end
@@ -1,46 +0,0 @@
1
- <%
2
- unless defined?(required)
3
- required = false
4
- end
5
- unless defined?(place_holder)
6
- place_holder = ""
7
- end
8
- inp_id = "inp_#{display_name.underscore.split(" ").join("_")}"
9
- error_class = object.errors[field_name.to_s].any? ? "has-errors" : ""
10
- %>
11
-
12
- <div class="form-group <%= error_class %>">
13
-
14
- <% if ["text", "email", "search", "password", "date", "time", "tel", "url", "month", "file", "image", ""].include?(input_type) %>
15
-
16
- <label for="inp_<%= display_name.underscore.split(" ").join("_") %>" class="col-md-4 control-label">
17
- <%= display_name %>
18
- <span class="text-color-red ml-10 mr-5 pull-right"><%= required ? "*" : raw("&nbsp;&nbsp;") %></span>
19
- </label>
20
- <div class="col-md-8">
21
- <input name="<%= object_name %>[<%= field_name %>]" id="inp_<%= display_name.underscore.split(" ").join("_") %>" class="text input form-control" type="<%= input_type %>" placeholder="<%= place_holder %>" value="<%= object.send(field_name.to_s) %>" />
22
- </div>
23
-
24
- <% elsif input_type == "checkbox" %>
25
-
26
- <label for="inp_<%= display_name.underscore.split(" ").join("_") %>" class="col-md-4 control-label">
27
- <%= display_name %>
28
- <span class="text-color-red ml-10 mr-5 pull-right"><%= required ? "*" : raw("&nbsp;&nbsp;") %></span>
29
- </label>
30
- <div class="col-md-8">
31
- <input name="<%= object_name %>[<%= field_name %>]" id="inp_<%= display_name.underscore.split(" ").join("_") %>" type="<%= input_type %>" class="checkbox input form-control" <%= object.send(field_name.to_s) ? "checked='checked'" : "" %> />
32
- </div>
33
-
34
- <% elsif input_type == "textarea" %>
35
-
36
- <label for="inp_<%= display_name.underscore.split(" ").join("_") %>" class="col-md-4 control-label">
37
- <%= display_name %>
38
- <span class="text-color-red ml-10 mr-5 pull-right"><%= required ? "*" : raw("&nbsp;&nbsp;") %></span>
39
- </label>
40
- <div class="col-md-8">
41
- <textarea name="<%= object_name %>[<%= field_name %>]" style="height:200px;" class="textarea input form-control" id="inp_<%= display_name.underscore.split(" ").join("_") %> placeholder="<%= place_holder %>" "><%= object.send(field_name.to_s) %></textarea>
42
- </div>
43
-
44
- <% end %>
45
-
46
- </div>
@@ -1,23 +0,0 @@
1
- <%
2
- if request.xhr?
3
- flash_message = flash.now[:success] || flash.now[:notice] || flash.now[:alert] || flash.now[:error]
4
- style_classes = ""
5
- else
6
- style_classes = ""
7
- flash_message = flash[:success] || flash[:notice] || flash[:alert] || flash[:error]
8
- end
9
- cls_name = "alert-info"
10
- cls_name = 'alert-success' if flash.now[:success] || flash[:success]
11
- cls_name = 'alert-warning' if flash.now[:alert] || flash[:alert]
12
- cls_name = 'alert-danger' if flash.now[:error] || flash[:error]
13
-
14
- flash_message = flash_message.strip if flash_message
15
-
16
- %>
17
-
18
- <% unless flash_message.blank? %>
19
- <div class="<%= style_classes %> alert <%= cls_name %> fade in mb-10" data-alert="alert">
20
- <a class="close" data-dismiss='alert' href="#">×</a>
21
- <p><%= flash_message %></p>
22
- </div>
23
- <% end %>
@@ -1,42 +0,0 @@
1
-
2
- <%# meta tags%>
3
- <% if @meta_tags %>
4
- <% if @meta_tags[:rel_prev] %>
5
- <link rel="prev" href="<%%= @meta_tags[:rel_prev] %>" />
6
- <% end %>
7
- <% if @meta_tags[:rel_next] %>
8
- <link rel="next" href="<%%= @meta_tags[:rel_next] %>" />
9
- <% end %>
10
- <% if @meta_tags[:canonical] %>
11
- <link rel="canonical" href="<%%= @meta_tags[:canonical] %>" />
12
- <% end %>
13
- <% if @meta_tags[:meta_description] %>
14
- <meta name="description" content="<%%= @meta_tags[:meta_description] %>"></meta>
15
- <% else %>
16
- <meta name="description" content="Twitter Like App = A learning app."></meta>
17
- <% end %>
18
- <% if @meta_tags[:meta_keywords] %>
19
- <meta name="keywords" content="<%%= @meta_tags[:meta_keywords] %>"></meta>
20
- <% else %>
21
- <% meta_keywords = "Twitter Like App = A learning app." %>
22
- <meta name="keywords" content="<%%= meta_keywords %>"></meta>
23
- <% end %>
24
- <% if @meta_tags[:robots] %>
25
- <meta name="robots" content="<%%= @meta_tags[:robots] %>" />
26
- <% else %>
27
- <meta name="robots" content="all" />
28
- <% end %>
29
- <% end %>
30
-
31
- <meta charset="utf-8">
32
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
33
- <meta name="copyright" content="2014 kpvarma" />
34
- <meta name="content-language" content="en" />
35
- <meta name="author" content="K P Varma" />
36
- <meta name="resource-type" content="document" />
37
- <meta name="distribution" content="global" />
38
- <meta name="rating" content="general" />
39
-
40
-
41
-
42
-
@@ -1,32 +0,0 @@
1
- class ApiError < RuntimeError
2
-
3
- attr_accessor :alert, :heading, :data, :errors, :redirect_on_failure, :redirect_on_success
4
-
5
- def initialize(options={})
6
- self.alert = options[:alert]
7
- self.heading = options[:heading]
8
- self.data = options[:data]
9
- self.errors = options[:errors]
10
- self.redirect_on_failure = options[:redirect_on_failure]
11
- self.redirect_on_success = options[:redirect_on_success]
12
- end
13
-
14
- end
15
-
16
- class InvalidLoginError < ApiError
17
- end
18
-
19
- class ValidationError < ApiError
20
- end
21
-
22
- class FailedToCreateError < ApiError
23
- end
24
-
25
- class FailedToUpdateError < ApiError
26
- end
27
-
28
- class FailedToDeleteError < ApiError
29
- end
30
-
31
- class AuthenticationError < ApiError
32
- end