outpost-publishing 1.0.0
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +70 -0
- data/Rakefile +1 -0
- data/lib/assets/javascripts/outpost/content_alarm.js.coffee +62 -0
- data/lib/assets/javascripts/outpost/publishing.js.coffee +50 -0
- data/lib/assets/javascripts/outpost/publishing_helper.js.coffee +71 -0
- data/lib/outpost/publishing.rb +9 -0
- data/lib/outpost/publishing/version.rb +5 -0
- data/outpost-publishing.gemspec +24 -0
- metadata +106 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 Bryan Ricker
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Outpost::Publishing
|
2
|
+
|
3
|
+
Adds some helper UI for publishing in Outpost. Also adds the ability to use
|
4
|
+
auto-publishing for any content.
|
5
|
+
|
6
|
+
This gem assumes that the models you want to use it with have at least a
|
7
|
+
"Published" and "Pending" status, and that they respond to `#published?` and
|
8
|
+
`#pending?`.
|
9
|
+
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
gem 'outpost-publishing'
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Drop it into your javascript manifest:
|
18
|
+
|
19
|
+
```javascript
|
20
|
+
//= require outpost/publishing
|
21
|
+
//= require outpost/content_alarms
|
22
|
+
```
|
23
|
+
|
24
|
+
Then instantiate using Javascript. Initialize by passing in a few options:
|
25
|
+
|
26
|
+
* the form selector (such as `#post_99`),
|
27
|
+
* the selector of the div wrapper around the publishing fields,
|
28
|
+
* the selector for where to render the notifications,
|
29
|
+
* the selector for the status input
|
30
|
+
* (optional) `statusPending` and `statusPublished` to indicate the value
|
31
|
+
for each of those. Default is 3 and 5, respectively.
|
32
|
+
|
33
|
+
```javascript
|
34
|
+
$(function() {
|
35
|
+
publishing = new outpost.Publishing({
|
36
|
+
form: "#<%=f.options[:html][:id]%>",
|
37
|
+
container: ".publishing-fields",
|
38
|
+
notifications: "<%= options[:notifications] || "#scheduled_status" %>",
|
39
|
+
statusField: "#status-select"
|
40
|
+
});
|
41
|
+
});
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
### Content Alarms
|
46
|
+
|
47
|
+
This gem only provides UI for content alarms. You'll need to do the
|
48
|
+
server-side stuff yourself.
|
49
|
+
|
50
|
+
An alarm might look like this:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
create_table :publish_alarms do |t|
|
54
|
+
t.integer :content_id
|
55
|
+
t.string :content_type
|
56
|
+
t.datetime :fire_at
|
57
|
+
t.timestamps
|
58
|
+
end
|
59
|
+
|
60
|
+
add_index :publish_alarms, [:content_type, :content_id]
|
61
|
+
add_index :publish_alarms, :fire_at
|
62
|
+
```
|
63
|
+
|
64
|
+
The only things that the UI script requires is a "fire_at" field, and a status
|
65
|
+
field to read.
|
66
|
+
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
Yes, please. PR's are appreciated.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#= require outpost/publishing_helper
|
2
|
+
|
3
|
+
##
|
4
|
+
# ContentAlarm
|
5
|
+
#
|
6
|
+
# Show/hide ContentAlarm fields based on status.
|
7
|
+
# Also renders messages based on status & timestamp
|
8
|
+
#
|
9
|
+
class outpost.ContentAlarm extends outpost.PublishingHelper
|
10
|
+
constructor: (@options={}) ->
|
11
|
+
super
|
12
|
+
|
13
|
+
# The actual datetime input
|
14
|
+
@datetimeField = @container.find("input.datetime")
|
15
|
+
|
16
|
+
# Alerts
|
17
|
+
@alerts =
|
18
|
+
isScheduled: new outpost.Notification(@notifications, "success", "This content is <strong>scheduled</strong> to be published.")
|
19
|
+
isNotScheduled: new outpost.Notification(@notifications, "info", "This content is <strong>not scheduled</strong> to be published.")
|
20
|
+
|
21
|
+
# Notify the scheduled status
|
22
|
+
@originalStatus = @setStatus() # also sets @status
|
23
|
+
@hideFields() # Hidden by default.
|
24
|
+
@setTimestamp()
|
25
|
+
@notify()
|
26
|
+
|
27
|
+
# Event for when the timestamp field is changed
|
28
|
+
@datetimeField.on
|
29
|
+
update: (event) =>
|
30
|
+
@setTimestamp()
|
31
|
+
@notify()
|
32
|
+
|
33
|
+
#----------
|
34
|
+
# Set @timestamp to the current value of the timestamp field
|
35
|
+
setTimestamp: ->
|
36
|
+
@timestamp = @datetimeField.val()
|
37
|
+
|
38
|
+
#----------
|
39
|
+
|
40
|
+
notify: ->
|
41
|
+
@clearAlerts()
|
42
|
+
|
43
|
+
timestampFilled = !_.isEmpty(@timestamp)
|
44
|
+
isPending = @isPending()
|
45
|
+
isPublished = @isPublished()
|
46
|
+
|
47
|
+
# Show the fields if it's pending.
|
48
|
+
if isPending then @showFields() else @hideFields()
|
49
|
+
|
50
|
+
# When it IS scheduled
|
51
|
+
if isPending and timestampFilled
|
52
|
+
return @alert 'isScheduled'
|
53
|
+
|
54
|
+
# When it ISN'T scheduled
|
55
|
+
if isPending and !timestampFilled
|
56
|
+
return @alert 'isNotScheduled'
|
57
|
+
|
58
|
+
# This one assumes that the PublishingUI script
|
59
|
+
# will let the user know about Publishing Immediately.
|
60
|
+
if !isPending and !isPublished and timestampFilled
|
61
|
+
@hideFields()
|
62
|
+
return @alert 'isNotScheduled'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#= require outpost/publishing_helper
|
2
|
+
|
3
|
+
##
|
4
|
+
# PublishingUI
|
5
|
+
#
|
6
|
+
# Show/hide Publishing fields based on status.
|
7
|
+
# Also renders messages based on status
|
8
|
+
#
|
9
|
+
class outpost.Publishing extends outpost.PublishingHelper
|
10
|
+
constructor: (@options={}) ->
|
11
|
+
super
|
12
|
+
|
13
|
+
# Alerts
|
14
|
+
@alerts =
|
15
|
+
willPublish: new outpost.Notification(@notifications, "warning", "This content <strong>will be published</strong> immediately.")
|
16
|
+
isPublished: new outpost.Notification(@notifications, "success", "This content is <strong>published</strong>")
|
17
|
+
willUnpublish: new outpost.Notification(@notifications, "danger", "<strong>Warning!</strong> This content <strong>will be unpublished</strong> immediately.")
|
18
|
+
|
19
|
+
# Notify the scheduled status
|
20
|
+
@originalStatus = @setStatus() # also sets @status
|
21
|
+
@hideFields() # Hidden by default.
|
22
|
+
@notify()
|
23
|
+
|
24
|
+
#----------
|
25
|
+
|
26
|
+
notify: ->
|
27
|
+
@clearAlerts()
|
28
|
+
|
29
|
+
# No need to run these methods more than once
|
30
|
+
isPublished = @isPublished()
|
31
|
+
wasPublished = @wasPublished()
|
32
|
+
|
33
|
+
# Show the fields if it's published.
|
34
|
+
@showFields() if isPublished
|
35
|
+
|
36
|
+
# All the different scenarios
|
37
|
+
# Already published
|
38
|
+
if isPublished and wasPublished
|
39
|
+
@showFields()
|
40
|
+
return @alert 'isPublished'
|
41
|
+
|
42
|
+
# Publishing
|
43
|
+
if isPublished and !wasPublished
|
44
|
+
@hideFields()
|
45
|
+
return @alert 'willPublish'
|
46
|
+
|
47
|
+
# Unpublishing
|
48
|
+
if !isPublished and wasPublished
|
49
|
+
@hideFields()
|
50
|
+
return @alert 'willUnpublish'
|
@@ -0,0 +1,71 @@
|
|
1
|
+
##
|
2
|
+
# PublishingHelper
|
3
|
+
#
|
4
|
+
# Some shared code for rendering alerts, and toggling fields
|
5
|
+
#
|
6
|
+
class outpost.PublishingHelper
|
7
|
+
defaults:
|
8
|
+
statusPending: "3"
|
9
|
+
statusPublished: "5"
|
10
|
+
|
11
|
+
constructor: (@options={}) ->
|
12
|
+
_.defaults @options, @defaults
|
13
|
+
|
14
|
+
@statusPending = @options.statusPending
|
15
|
+
@statusPublished = @options.statusPublished
|
16
|
+
|
17
|
+
# Elements
|
18
|
+
@form = $ @options.form
|
19
|
+
@container = $ @options.container, @form # Wrapper for the fields
|
20
|
+
@statusField = $ @options.statusField, @form # Status select
|
21
|
+
@notifications = $ @options.notifications, @form # Notification bucket
|
22
|
+
|
23
|
+
# Event for when the status field is changed
|
24
|
+
@statusField.on
|
25
|
+
change: (event) =>
|
26
|
+
@setStatus()
|
27
|
+
@notify()
|
28
|
+
|
29
|
+
#----------
|
30
|
+
# Get the current status from the dropdown
|
31
|
+
setStatus: ->
|
32
|
+
@status = $("option:selected", @statusField).val()
|
33
|
+
|
34
|
+
#----------
|
35
|
+
# Helpers for finding current and original status
|
36
|
+
isPending: ->
|
37
|
+
@status is @statusPending
|
38
|
+
|
39
|
+
isPublished: ->
|
40
|
+
@status is @statusPublished
|
41
|
+
|
42
|
+
wasPending: ->
|
43
|
+
@originalStatus is @statusPending
|
44
|
+
|
45
|
+
wasPublished: ->
|
46
|
+
@originalStatus is @statusPublished
|
47
|
+
|
48
|
+
#----------
|
49
|
+
# Handles scenarios
|
50
|
+
notify: ->
|
51
|
+
# Override me
|
52
|
+
|
53
|
+
#----------
|
54
|
+
# Render the notification
|
55
|
+
alert: (key) ->
|
56
|
+
@alerts[key].render()
|
57
|
+
|
58
|
+
#----------
|
59
|
+
# Mass-Detach all of the alerts
|
60
|
+
clearAlerts: ->
|
61
|
+
alert.detach() for name,alert of @alerts
|
62
|
+
|
63
|
+
#----------
|
64
|
+
|
65
|
+
showFields: ->
|
66
|
+
@container.show()
|
67
|
+
|
68
|
+
#----------
|
69
|
+
|
70
|
+
hideFields: ->
|
71
|
+
@container.hide()
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'outpost/publishing/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "outpost-publishing"
|
8
|
+
spec.version = Outpost::Publishing::VERSION
|
9
|
+
spec.authors = ["Bryan Ricker"]
|
10
|
+
spec.email = ["bricker88@gmail.com"]
|
11
|
+
spec.description = %q{Enhanced content publishing for Outpost.}
|
12
|
+
spec.summary = %q{Outpost plugin for publishing helper UI.}
|
13
|
+
spec.homepage = "https://github.com/SCPR/outpost-publishing"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec-rails"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: outpost-publishing
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Bryan Ricker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec-rails
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: Enhanced content publishing for Outpost.
|
63
|
+
email:
|
64
|
+
- bricker88@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- MIT-LICENSE
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- lib/assets/javascripts/outpost/content_alarm.js.coffee
|
75
|
+
- lib/assets/javascripts/outpost/publishing.js.coffee
|
76
|
+
- lib/assets/javascripts/outpost/publishing_helper.js.coffee
|
77
|
+
- lib/outpost/publishing.rb
|
78
|
+
- lib/outpost/publishing/version.rb
|
79
|
+
- outpost-publishing.gemspec
|
80
|
+
homepage: https://github.com/SCPR/outpost-publishing
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.8.25
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: Outpost plugin for publishing helper UI.
|
105
|
+
test_files: []
|
106
|
+
has_rdoc:
|