my_timeline 0.0.5 → 0.1.0

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: 3b1e4e734b8ba08d97b8c8b37940ce764ddc25a7
4
- data.tar.gz: ec08da26e73fbcecd5fc7ea2259b3428bf272b0f
3
+ metadata.gz: c900ff1d59717d4d8b507507360f9a0acb785387
4
+ data.tar.gz: ded000abf734348cd2fbf1938f66e3122424aa75
5
5
  SHA512:
6
- metadata.gz: 84358a06da83329cc1800936b42361c81093f4a616272616c9b74f5a90f131318ad45ce4517e2b018eb44702e61535ac83b0bb6043610fbed0d30dbf88ad92ab
7
- data.tar.gz: 8a55367c195632241c959e9efc07ad11b327f5e895b36fc3c3362a71fca778a02843053fdafafffca6ef47f67498610a337e11cef6a7dafc62e066fa1e5eedb0
6
+ metadata.gz: fbef9bb8f0e43e3c60bdd4ff17b4789c47c27c83c54c8f85fc5fd043377b651b8a75e332eecf9c715827daec21952d6c682253f149cc0cc49e197ed3681a0798
7
+ data.tar.gz: 04f35066cd299b80460f6f80de144f2f6e689d84c57fab2d45c05aa26842177f512da9b899474a667de58c6960fb35817c9238899e1fe2e7bc4cc448ff048613
@@ -1,3 +1,9 @@
1
+ # 0.1.0
2
+ * [BUGFIX] Fix the settings to reload in development mode
3
+ * [BUGFIX] Fix the user stub
4
+ * [FEATURE] Display event's times with the User's timezone, and make the time formatting configurable
5
+ * [BUGFIX] Make the plugin registry a Set instead of an Array to avoid duplicates
6
+
1
7
  # 0.0.5
2
8
  * [FEATURE] Added a detail view that expands below the summary post, if that model supports an expandable view (defaults to not.)
3
9
  * [BUGFIX] Dehardcode header text
@@ -9,7 +9,7 @@ module MyTimeline
9
9
  if rails4?
10
10
  @user.time_zone = user_params[:time_zone]
11
11
  else
12
- @user.time_zone = params[:user][:time_zone]
12
+ @user.time_zone = params[user_param][:time_zone]
13
13
  end
14
14
 
15
15
  @user.save!
@@ -20,8 +20,12 @@ module MyTimeline
20
20
 
21
21
  if rails4?
22
22
  define_method :user_params do
23
- params.required(:user).permit :time_zone
23
+ params.required(user_param).permit :time_zone
24
24
  end
25
25
  end
26
+
27
+ def user_param
28
+ MyTimeline.user_class.model_name.param_key.to_sym
29
+ end
26
30
  end
27
31
  end
@@ -12,13 +12,30 @@ module MyTimeline
12
12
  end
13
13
 
14
14
  def happened_on
15
- event.happened_on.strftime("%-l:%M %P")
15
+ time.strftime MyTimeline.time_formatter
16
16
  end
17
17
 
18
18
  def id
19
19
  event.id
20
20
  end
21
21
 
22
+ private
23
+
24
+ def time
25
+ return event.happened_on if event.linkable.class.respond_to? :keep_original_time_zone?
26
+ return event.happened_on unless user.time_zone.present?
27
+
28
+ event.happened_on.in_time_zone user.time_zone
29
+ end
30
+
31
+ def user
32
+ if MyTimeline.user_class == MyTimeline::UserStub
33
+ MyTimeline::UserStub
34
+ else
35
+ event.user
36
+ end
37
+ end
38
+
22
39
  def method_missing(meth, *args, &blk)
23
40
  if event.respond_to?(meth)
24
41
  event.send meth, *args
@@ -7,7 +7,7 @@
7
7
  <%= link_to event.external_link do %>
8
8
  <%= image_tag event.icon_path, size: "32x32" %>
9
9
  <% end %>
10
- <%= event.happened_on %> -
10
+ <%= event.happened_on %>
11
11
  <%= raw event.description %>
12
12
  <% if @owner_viewing %>
13
13
  <%= link_to edit_event_path(event.id) do %>
@@ -13,4 +13,7 @@ MyTimeline.setup do |config|
13
13
 
14
14
  # What classes to style the table with
15
15
  # config.table_class = "table table-striped"
16
+
17
+ # How to format the time of the event; default looks like "3:33 pm - "
18
+ # config.time_formatter = %-l:%M %P - "
16
19
  end
@@ -5,7 +5,7 @@ require "my_timeline/engine"
5
5
 
6
6
  module MyTimeline
7
7
 
8
- mattr_accessor :user_class, :user_slug, :render_method, :table_class, :config_object, :enabled_plugins
8
+ mattr_accessor :user_class, :user_slug, :render_method, :table_class, :config_object, :enabled_plugins, :time_formatter
9
9
 
10
10
  @@user_class = 'MyTimeline::UserStub'
11
11
  def self.user_class
@@ -19,8 +19,11 @@ module MyTimeline
19
19
 
20
20
  @@table_class = "table table-striped"
21
21
 
22
- @@enabled_plugins = []
23
- def self.register_plugin(plugin_name)
22
+ @@time_formatter = "%-l:%M %P - "
23
+
24
+ @@enabled_plugins = Set.new
25
+ def self.register_plugin(plugin_name, options = {})
26
+ MyTimeline.config_object.key plugin_name, options
24
27
  @@enabled_plugins << plugin_name
25
28
  end
26
29
 
@@ -3,7 +3,6 @@ require 'my_timeline/core_ext/rails4'
3
3
 
4
4
  module MyTimeline
5
5
  class Engine < ::Rails::Engine
6
- include SettingsExt
7
6
 
8
7
  isolate_namespace MyTimeline
9
8
 
@@ -18,7 +17,11 @@ module MyTimeline
18
17
  end
19
18
 
20
19
  config.after_initialize do |app|
21
- extend_rails_settings
20
+ MyTimeline::SettingsExt.extend_rails_settings
22
21
  end
22
+
23
+ config.to_prepare do |app|
24
+ MyTimeline::SettingsExt.extend_rails_settings
25
+ end if Rails.env.development?
23
26
  end
24
27
  end
@@ -2,7 +2,7 @@ require 'rails-settings'
2
2
 
3
3
  module MyTimeline
4
4
  module SettingsExt
5
- def extend_rails_settings
5
+ def self.extend_rails_settings
6
6
 
7
7
  RailsSettings::SettingObject.class_eval do
8
8
  self.table_name = "my_timeline_settings"
@@ -35,3 +35,4 @@ module MyTimeline
35
35
  end
36
36
  end
37
37
  end
38
+
@@ -1,38 +1,50 @@
1
+ require 'singleton'
2
+
1
3
  module MyTimeline
2
4
  class UserStub
5
+ include Singleton
6
+
7
+ include ActiveModel::Validations
8
+ include ActiveModel::Conversion
9
+ extend ActiveModel::Naming
3
10
 
4
- def self.events
11
+ def events
5
12
  Event
6
13
  end
7
14
 
8
- def self.settings
9
- RailsSettings::SettingObject
15
+ def settings(var = :core)
16
+ RailsSettings::SettingObject.find_by_var var
10
17
  end
11
18
 
12
- def self.id
19
+ def id
13
20
  nil
14
21
  end
15
22
 
16
- def self.save!
23
+ def save!
17
24
  true
18
25
  end
19
26
 
27
+ def persisted?
28
+ false
29
+ end
30
+
20
31
  def self.method_missing(meth, *args, &blk)
21
32
  if meth.to_s =~ /^find_by/
22
33
  UserStub
23
34
  else
24
- super
35
+ instance.send meth, *args, &blk
36
+ # super
25
37
  end
26
38
  end
27
39
 
28
40
  def self.settings_attr_accessor(*args)
29
41
  args.each do |method_name|
30
42
  eval "
31
- def #{method_name}
32
- self.settings(:core).send(:#{method_name})
43
+ def self.#{method_name.to_s}
44
+ RailsSettings::SettingObject.find_by_var(:core).send('#{method_name}')
33
45
  end
34
- def #{method_name}=(value)
35
- self.settings(:core).send(:#{method_name}=, value)
46
+ def self.#{method_name.to_s}=(value)
47
+ RailsSettings::SettingObject.find_by_var(:core).send('#{method_name}=', value)
36
48
  end
37
49
  "
38
50
  end
@@ -1,3 +1,3 @@
1
1
  module MyTimeline
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_timeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Aiken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-21 00:00:00.000000000 Z
11
+ date: 2014-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails