timepiece 0.0.5 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +4 -0
  3. data/app/assets/javascripts/timepiece.js +26 -2
  4. data/app/helpers/timepiece_helper.rb +32 -3
  5. data/lib/timepiece/version.rb +1 -1
  6. data/test/dummy/README.rdoc +28 -28
  7. data/test/dummy/Rakefile +6 -6
  8. data/test/dummy/app/assets/javascripts/application.js +13 -13
  9. data/test/dummy/app/assets/stylesheets/application.css +13 -13
  10. data/test/dummy/app/controllers/application_controller.rb +5 -5
  11. data/test/dummy/app/helpers/application_helper.rb +2 -2
  12. data/test/dummy/app/views/layouts/application.html.erb +14 -14
  13. data/test/dummy/bin/bundle +3 -3
  14. data/test/dummy/bin/rails +4 -4
  15. data/test/dummy/bin/rake +4 -4
  16. data/test/dummy/config/application.rb +23 -23
  17. data/test/dummy/config/boot.rb +5 -5
  18. data/test/dummy/config/database.yml +25 -25
  19. data/test/dummy/config/environment.rb +5 -5
  20. data/test/dummy/config/environments/development.rb +29 -29
  21. data/test/dummy/config/environments/production.rb +80 -80
  22. data/test/dummy/config/environments/test.rb +36 -36
  23. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -7
  24. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  25. data/test/dummy/config/initializers/inflections.rb +16 -16
  26. data/test/dummy/config/initializers/mime_types.rb +5 -5
  27. data/test/dummy/config/initializers/secret_token.rb +12 -12
  28. data/test/dummy/config/initializers/session_store.rb +3 -3
  29. data/test/dummy/config/initializers/wrap_parameters.rb +14 -14
  30. data/test/dummy/config/locales/en.yml +23 -23
  31. data/test/dummy/config/routes.rb +56 -56
  32. data/test/dummy/config.ru +4 -4
  33. data/test/dummy/public/404.html +58 -58
  34. data/test/dummy/public/422.html +58 -58
  35. data/test/dummy/public/500.html +57 -57
  36. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88a46caefda0bb52a083fccf0ea4c4858f94a8fb
4
- data.tar.gz: c2b38d82e014e605763f2f5d2ace5582faf278a1
3
+ metadata.gz: 7988876cb63edcc687f8622dd61acb1246fe81e3
4
+ data.tar.gz: ca69fd7980c09311268d8888394bdfcea50fef9d
5
5
  SHA512:
6
- metadata.gz: 866a31dba6c09a7189bf4b0c6c65def2d9f3e8ce388dba1c0d487c25ce5045e945fb5a134db1ef721b354a0f8cf21ffd7575be469903516773899af108330cb8
7
- data.tar.gz: 300accf774345bcf8db695e9aae5e113e3737a86a5fc1370d3d72f6ad1a80c715a8f17d3f7bc303f752adf17587c6fe71a02813fc1e2c88bd006866a70a62378
6
+ metadata.gz: e22b8e474607ee36a4a2893d2b997b16e6157f8da82552a62f6dc6cc6e16f06452f6a182d30ad623dcd12157d9342d5f1bd29d06846a417a4d4381d368626538
7
+ data.tar.gz: 5e0422adbf7c7cfaaacdd016fde7a7b731b2d66cab80661085771e463f04140b04184c94d0a4c3720b5e72ea6c48e819bd8c3e01655caf476ef9b45326119410
data/README.rdoc CHANGED
@@ -24,4 +24,8 @@ Timepiece is a Rails plugin providing a simple digital clock, accurate to your s
24
24
 
25
25
  <%= timepiece('London') %>
26
26
 
27
+ * By default, Timepiece shows a 24 hour digital clock. You can show a 12 hour clock by specifying it explicitly.
28
+
29
+ <%= timepiece('London', '12') %>
30
+
27
31
  * Timepiece will automatically generate a digital clock and keep it updated.
@@ -4,7 +4,7 @@ get_seconds = []
4
4
 
5
5
  function get_time(){
6
6
  var zones = []
7
- $(".timepiece").each(function(){ zones.push($(this).attr('title')) })
7
+ $(".timepiece").each(function(){ zones.push($(this).attr('data-timezone')) })
8
8
  var timezones = { 'timezones' : zones }
9
9
  $.ajax({ type: "POST", url: "/timepiece/clock.json", data: timezones, dataType: "json", cache: false }).success(function(time){
10
10
  for(var i = 0; i < time.length; i++){
@@ -38,7 +38,31 @@ function show_time(){
38
38
  }
39
39
  }
40
40
  $(".timepiece").each(function(i, e){
41
- $(e).html(( hours[i] < 10 ? "0" : "" ) + hours[i] + ':' + ( minutes[i] < 10 ? "0" : "" ) + minutes[i] + ':' + ( seconds[i] < 10 ? "0" : "" ) + seconds[i])
41
+ $(e).html(function(){
42
+ if($(e).attr("data-tptype") == '12'){
43
+ if(hours[i] > 12){
44
+ $(e).data('hours', hours[i] - 12)
45
+ abbr = 'pm'
46
+ }else if(hours[i] == 0){
47
+ $(e).data('hours', 12)
48
+ abbr = 'am'
49
+ }else if(hours[i] == 12){
50
+ $(e).data('hours', 12)
51
+ abbr = 'pm'
52
+ }else if(hours[i] < 12){
53
+ $(e).data('hours', hours[i])
54
+ abbr = 'am'
55
+ }
56
+ $('.timepiece-hours', $(e)).html(( $(e).data('hours') < 10 ? "0" : "" ) + $(e).data('hours'));
57
+ $('.timepiece-minutes', $(e)).html(( minutes[i] < 10 ? "0" : "" ) + minutes[i]);
58
+ $('.timepiece-seconds', $(e)).html(( seconds[i] < 10 ? "0" : "" ) + seconds[i]);
59
+ $('.timepiece-abbr', $(e)).html(abbr);
60
+ }else{
61
+ $('.timepiece-hours', $(e)).html(( hours[i] < 10 ? "0" : "" ) + hours[i]);
62
+ $('.timepiece-minutes', $(e)).html(( minutes[i] < 10 ? "0" : "" ) + minutes[i]);
63
+ $('.timepiece-seconds', $(e)).html(( seconds[i] < 10 ? "0" : "" ) + seconds[i]);
64
+ }
65
+ })
42
66
  })
43
67
  }, 1000)
44
68
  }
@@ -1,7 +1,36 @@
1
1
  module TimepieceHelper
2
- def timepiece(location = 'UTC')
2
+ def timepiece(location = 'UTC', type = '24')
3
3
  Time.zone = location
4
- time = Time.now.in_time_zone.strftime('%H:%M:%S')
5
- content_tag(:span, time, class: 'timepiece', title: location)
4
+ hours = Time.now.in_time_zone.strftime('%H')
5
+ minutes = Time.now.in_time_zone.strftime('%M')
6
+ seconds = Time.now.in_time_zone.strftime('%S')
7
+ if type == '12' && hours.to_i > 12
8
+ hours = hours.to_i - 12
9
+ if hours < 10
10
+ hours = '0' + hours.to_s
11
+ end
12
+ var = 'pm'
13
+ elsif type == '12' && hours.to_i == 0
14
+ hours = 12
15
+ var = 'am'
16
+ elsif type == '12' && hours.to_i == 12
17
+ var = 'pm'
18
+ elsif type == '12' && hours.to_i < 12
19
+ var = 'am'
20
+ end
21
+ time = "<span class='timepiece-hours'>#{hours}</span>"\
22
+ "<span class='timepiece-separator tp-separator-1'>:</span>"\
23
+ "<span class='timepiece-minutes'>#{minutes}</span>"\
24
+ "<span class='timepiece-separator tp-separator-2'>:</span>"\
25
+ "<span class='timepiece-seconds'>#{seconds}</span>"
26
+ if type == '12'
27
+ time = time + "<span class='timepiece-abbr'>#{var}</span>"
28
+ end
29
+ content_tag(:span, time.html_safe, class: 'timepiece', 'data-timezone' => location, 'data-tptype' => type)
6
30
  end
7
31
  end
32
+
33
+
34
+ # Note: add class to timepiece-abbr: timepiece-abbr-#{var} . Working this on the JS side shouldn't be too difficult just...
35
+ # element.addClass('timepiece-abbr-' + var) right? Except, you have to remove old and add new, toggle or something-something.
36
+ # Therein lies the difficulty.
@@ -1,3 +1,3 @@
1
1
  module Timepiece
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,28 +1,28 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
data/test/dummy/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Dummy::Application.load_tasks
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -1,13 +1,13 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -1,13 +1,13 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
- *= require_self
12
- *= require_tree .
13
- */
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -1,5 +1,5 @@
1
- class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
- end
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -1,2 +1,2 @@
1
- module ApplicationHelper
2
- end
1
+ module ApplicationHelper
2
+ end
@@ -1,14 +1,14 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
- <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env ruby.exe
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
1
+ #!/usr/bin/env ruby.exe
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
data/test/dummy/bin/rails CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby.exe
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
1
+ #!/usr/bin/env ruby.exe
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
data/test/dummy/bin/rake CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby.exe
2
- require_relative '../config/boot'
3
- require 'rake'
4
- Rake.application.run
1
+ #!/usr/bin/env ruby.exe
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -1,23 +1,23 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- Bundler.require(*Rails.groups)
6
- require "timepiece"
7
-
8
- module Dummy
9
- class Application < Rails::Application
10
- # Settings in config/environments/* take precedence over those specified here.
11
- # Application configuration should go into files in config/initializers
12
- # -- all .rb files in that directory are automatically loaded.
13
-
14
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
- # config.time_zone = 'Central Time (US & Canada)'
17
-
18
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
- # config.i18n.default_locale = :de
21
- end
22
- end
23
-
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "timepiece"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+ end
22
+ end
23
+
@@ -1,5 +1,5 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,25 +1,25 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- development:
7
- adapter: sqlite3
8
- database: db/development.sqlite3
9
- pool: 5
10
- timeout: 5000
11
-
12
- # Warning: The database defined as "test" will be erased and
13
- # re-generated from your development database when you run "rake".
14
- # Do not set this db to the same as development or production.
15
- test:
16
- adapter: sqlite3
17
- database: db/test.sqlite3
18
- pool: 5
19
- timeout: 5000
20
-
21
- production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
24
- pool: 5
25
- timeout: 5000
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -1,5 +1,5 @@
1
- # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the Rails application.
5
- Dummy::Application.initialize!
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Dummy::Application.initialize!
@@ -1,29 +1,29 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb.
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Do not eager load code on boot.
10
- config.eager_load = false
11
-
12
- # Show full error reports and disable caching.
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send.
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger.
20
- config.active_support.deprecation = :log
21
-
22
- # Raise an error on page load if there are pending migrations
23
- config.active_record.migration_error = :page_load
24
-
25
- # Debug mode disables concatenation and preprocessing of assets.
26
- # This option may cause significant delays in view rendering with a large
27
- # number of complex assets.
28
- config.assets.debug = true
29
- end
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+ end