yodel_queue 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in yodel_queue.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,129 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <title><%= site.name %> Queue</title>
5
+ <style>
6
+ body {
7
+ font-family: Helvetica;
8
+ margin: 0px;
9
+ padding: 0px;
10
+ font-size: 12px;
11
+ }
12
+
13
+ h1 {
14
+ font-size: 20px;
15
+ color: white;
16
+ font-weight: bold;
17
+ margin: 0px 0px 10px 0px;
18
+ padding: 15px 20px;
19
+ }
20
+
21
+ h1#overview {
22
+ background-color: #444;
23
+ margin-bottom: 20px;
24
+ }
25
+
26
+ h1#failed {
27
+ background-color: #CC1111;
28
+ margin-top: 20px;
29
+ }
30
+
31
+ article {
32
+ padding-left: 20px;
33
+ }
34
+
35
+ dl {
36
+ width: 800px;
37
+ padding: 0px;
38
+ margin: 0px;
39
+ }
40
+
41
+ dt, dd {
42
+ padding: 4px 0px;
43
+ margin: 0px;
44
+ }
45
+
46
+ dt {
47
+ width: 100px;
48
+ padding-right: 20px;
49
+ text-align: right;
50
+ font-weight: bold;
51
+ color: #777;
52
+ float: left;
53
+ clear: right;
54
+ }
55
+
56
+ dd {
57
+ width: 670px;
58
+ float: right;
59
+ }
60
+
61
+ li {
62
+ border-bottom: 1px dotted #ccc;
63
+ padding: 20px 0px;
64
+ list-style-type: none;
65
+ }
66
+
67
+ li:last-child {
68
+ border-bottom: none;
69
+ }
70
+
71
+ pre {
72
+ margin: 0px;
73
+ padding: 0px;
74
+ }
75
+
76
+ .clear {
77
+ clear: both;
78
+ }
79
+ </style>
80
+ </head>
81
+ <body>
82
+ <h1 id="overview">Overview</h1>
83
+ <article>
84
+ <dl>
85
+ <dt>Total Tasks:</dt>
86
+ <dd><%= @task_count %></dd>
87
+ <dt>Instant Tasks:</dt>
88
+ <dd><%= @instant_task_count %></dd>
89
+ <dt>Delayed Tasks:</dt>
90
+ <dd><%= @delayed_task_count %></dd>
91
+ <dt>Failed Tasks:</dt>
92
+ <dd><%= @failed_tasks.size %></dd>
93
+ </dl>
94
+ <div class="clear"></div>
95
+ </article>
96
+
97
+ <h1 id="failed">Failed</h1>
98
+ <article>
99
+ <% unless @failed_tasks.empty? %>
100
+ <ul>
101
+ <% @failed_tasks.each do |task| %>
102
+ <li>
103
+ <dl>
104
+ <dt>Type:</dt>
105
+ <dd><%= task.type %></dd>
106
+ <dt>Params:</dt>
107
+ <dd><%= task.params.inspect %></dd>
108
+ <dt>Attempts:</dt>
109
+ <dd><%= task.attempts %></dd>
110
+ <dt>Stack Trace:</dt>
111
+ <dd><pre><%= task.stack_trace %></pre></dd>
112
+ <dt></dt>
113
+ <dd>
114
+ <form action="<%= path %>" method="post">
115
+ <input type="hidden" name="id" value="<%= task.id %>">
116
+ <input type="submit" value="Restart">
117
+ </form>
118
+ </dd>
119
+ </dl>
120
+ <div class="clear"></div>
121
+ </li>
122
+ <% end %>
123
+ </ul>
124
+ <% else %>
125
+ <p>No failed tasks.</p>
126
+ <% end %>
127
+ </article>
128
+ </body>
129
+ </html>
@@ -0,0 +1,21 @@
1
+ class QueuePageModelMigration < Migration
2
+ def self.up(site)
3
+ site.pages.create_model :queue_pages do |queue_pages|
4
+ queue_pages.record_class_name = 'QueuePage'
5
+ queue_pages.allowed_children = []
6
+ queue_pages.allowed_parents = []
7
+ queue_pages.hide_in_admin = true
8
+ end
9
+
10
+ # default queue page
11
+ home_page = site.pages.where(path: '/').first
12
+ qp = site.queue_pages.new
13
+ qp.parent = home_page
14
+ qp.title = "Queue"
15
+ qp.save
16
+ end
17
+
18
+ def self.down(site)
19
+ site.queue_pages.destroy
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ class QueuePage < Page
2
+ respond_to :get do
3
+ with :html do
4
+ @task_count = site.tasks.count
5
+ @delayed_task_count = site.tasks.where(due: {'$ne' => nil}, attempts: 0).count
6
+ @instant_task_count = site.tasks.where(due: nil).count
7
+ @failed_tasks = site.tasks.where(attempts: {'$gt' => 0}).all
8
+
9
+ render_or_default(:html) do
10
+ "<p>Sorry, a layout couldn't be found for this page</p>" # FIXME: better error message
11
+ end
12
+ end
13
+ end
14
+
15
+ respond_to :post do
16
+ with :html do
17
+ task = site.tasks.find(BSON::ObjectId.from_string(params['id']))
18
+ if task
19
+ task.due = nil
20
+ task.locked = nil
21
+ task.attempts = 0
22
+ task.stack_trace = nil
23
+ task.save
24
+ end
25
+ response.redirect(self.path)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module YodelQueue
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'yodel_queue'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'yodel_queue'
7
+ s.version = YodelQueue::VERSION
8
+ s.authors = ['Will Cannings']
9
+ s.email = ['me@willcannings.com']
10
+ s.homepage = 'http://yodelcms.com'
11
+ s.summary = 'Yodel CMS Queue Extension'
12
+ s.description = 'Yodel CMS Queue Extension'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ # specify any dependencies here; for example:
20
+ # s.add_development_dependency "rspec"
21
+ # s.add_runtime_dependency "rest-client"
22
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yodel_queue
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Will Cannings
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-09 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Yodel CMS Queue Extension
15
+ email:
16
+ - me@willcannings.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - Rakefile
24
+ - lib/layouts/queue_page.html
25
+ - lib/migrations/01_queue_page_model.rb
26
+ - lib/models/queue_page.rb
27
+ - lib/yodel_queue.rb
28
+ - yodel_queue.gemspec
29
+ homepage: http://yodelcms.com
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.10
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: Yodel CMS Queue Extension
53
+ test_files: []