cartoonist 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ module BelongsToEntity
2
+ def entity
3
+ @entity ||= Cartoonist::Entity[entity_type.to_sym].find(entity_id)
4
+ end
5
+
6
+ def description
7
+ "#{entity.entity_localized_label}: #{entity.entity_description}"
8
+ end
9
+
10
+ private
11
+ def entity_doesnt_change
12
+ if entity_id_changed?
13
+ errors.add :entity_id, "can't change"
14
+ end
15
+
16
+ if entity_type_changed?
17
+ errors.add :entity_id, "can't change"
18
+ end
19
+ end
20
+ end
data/app/models/entity.rb CHANGED
@@ -15,6 +15,22 @@ module Entity
15
15
  self.class.entity_description.call self
16
16
  end
17
17
 
18
+ def entity_relative_previewable_url(preview)
19
+ if preview
20
+ entity_relative_preview_url
21
+ else
22
+ entity_relative_url
23
+ end
24
+ end
25
+
26
+ def entity_relative_preview_url
27
+ if self.class.entity_preview_url
28
+ self.class.entity_preview_url.call self
29
+ else
30
+ entity_relative_url
31
+ end
32
+ end
33
+
18
34
  def entity_relative_url
19
35
  self.class.entity_url.call self if self.class.entity_url
20
36
  end
@@ -90,6 +106,14 @@ module Entity
90
106
  end
91
107
  end
92
108
 
109
+ def entity_preview_url(&block)
110
+ if block
111
+ @entity_preview_url = block
112
+ else
113
+ @entity_preview_url
114
+ end
115
+ end
116
+
93
117
  def entity_edit_url(&block)
94
118
  if block
95
119
  @entity_edit_url = block
@@ -11,10 +11,12 @@ module Postable
11
11
  self.class.postable_now
12
12
  end
13
13
 
14
- def formatted_posted_at(default_msg = "not yet posted")
14
+ def formatted_posted_at(default_msg = "not yet posted", options = {})
15
15
  return default_msg unless posted_at
16
16
 
17
- if postable_type == :date
17
+ if options[:format]
18
+ posted_at.to_time.localtime.strftime options[:format]
19
+ elsif postable_type == :date
18
20
  posted_at.strftime "%-m/%-d/%Y"
19
21
  else
20
22
  posted_at.localtime.strftime "%-m/%-d/%Y at %-l:%M %P"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cartoonist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-24 00:00:00.000000000 Z
12
+ date: 2012-05-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
16
- requirement: &12204220 !ruby/object:Gem::Requirement
16
+ requirement: &19623020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *12204220
24
+ version_requirements: *19623020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &12203580 !ruby/object:Gem::Requirement
27
+ requirement: &19620660 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *12203580
35
+ version_requirements: *19620660
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: railties
38
- requirement: &12203040 !ruby/object:Gem::Requirement
38
+ requirement: &19620080 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 3.2.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *12203040
46
+ version_requirements: *19620080
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: redcarpet
49
- requirement: &12273440 !ruby/object:Gem::Requirement
49
+ requirement: &19619620 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.1.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *12273440
57
+ version_requirements: *19619620
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rubyzip
60
- requirement: &12272860 !ruby/object:Gem::Requirement
60
+ requirement: &19619160 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.9.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *12272860
68
+ version_requirements: *19619160
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitar
71
- requirement: &12272340 !ruby/object:Gem::Requirement
71
+ requirement: &19618700 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 0.5.0
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *12272340
79
+ version_requirements: *19618700
80
80
  description: This provides the main functionality and plugin api for Cartoonist.
81
81
  email: reasonnumber@gmail.com
82
82
  executables: []
@@ -97,6 +97,7 @@ files:
97
97
  - app/helpers/admin/settings_helper.rb
98
98
  - app/helpers/cartoonist_helper.rb
99
99
  - app/models/backup.rb
100
+ - app/models/belongs_to_entity.rb
100
101
  - app/models/database_file.rb
101
102
  - app/models/entity.rb
102
103
  - app/models/markdown.rb