torquebox-stompbox 0.1.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.
@@ -0,0 +1,37 @@
1
+ #
2
+ # Copyright 2011 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'torquebox-messaging'
18
+ require 'deployer'
19
+ require 'models'
20
+
21
+ class DeployerTask < TorqueBox::Messaging::Task
22
+
23
+ def deploy(payload)
24
+ push = Push.get(payload[:id])
25
+ if push
26
+ Deployer.undeploy_branch(push.branch)
27
+ Deployer.new(push).deploy
28
+ end
29
+ end
30
+
31
+ def undeploy(payload)
32
+ push = Push.get(payload[:id])
33
+ if push
34
+ Deployer.new(push).undeploy
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,82 @@
1
+ /* html5doctor.com Reset Stylesheet
2
+ /* v1.6
3
+ /* Last Updated: 2010-08-18
4
+ /* Author: Richard Clark - http://richclarkdesign.com
5
+ /* Twitter: @rich_clark
6
+
7
+ html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video
8
+ margin: 0
9
+ padding: 0
10
+ border: 0
11
+ outline: 0
12
+ font-size: 100%
13
+ vertical-align: baseline
14
+ background: transparent
15
+
16
+ body
17
+ line-height: 1
18
+
19
+ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section
20
+ display: block
21
+
22
+ nav ul
23
+ list-style: none
24
+
25
+ blockquote, q
26
+ quotes: none
27
+
28
+ blockquote
29
+ &:before, &:after
30
+ content: ''
31
+ content: none
32
+
33
+ q
34
+ &:before, &:after
35
+ content: ''
36
+ content: none
37
+
38
+ a
39
+ margin: 0
40
+ padding: 0
41
+ font-size: 100%
42
+ vertical-align: baseline
43
+ background: transparent
44
+
45
+ /* change colours to suit your needs
46
+
47
+ ins
48
+ background-color: #ff9
49
+ color: #000
50
+ text-decoration: none
51
+
52
+ /* change colours to suit your needs
53
+
54
+ mark
55
+ background-color: #ff9
56
+ color: #000
57
+ font-style: italic
58
+ font-weight: bold
59
+
60
+ del
61
+ text-decoration: line-through
62
+
63
+ abbr[title], dfn[title]
64
+ border-bottom: 1px dotted inherit
65
+ cursor: help
66
+
67
+ table
68
+ border-collapse: collapse
69
+ border-spacing: 0
70
+
71
+ /* change border colour to suit your needs
72
+
73
+ hr
74
+ display: block
75
+ height: 1px
76
+ border: 0
77
+ border-top: 1px solid #cccccc
78
+ margin: 1em 0
79
+ padding: 0
80
+
81
+ input, select
82
+ vertical-align: middle
@@ -0,0 +1,198 @@
1
+ footer {
2
+ text-align: center;
3
+ font-size: smallest;
4
+ color: #768994;
5
+ margin-top: 30px;
6
+ }
7
+
8
+ #facebox .popup .content {
9
+ font-family: Arial, Helvetica, sans-serif;
10
+ h2 {
11
+ border-bottom: #295666 2px solid;
12
+ font-size: 18px;
13
+ margin-bottom: 20px;
14
+ margin-top: 20px;
15
+ color: #295666;
16
+ }
17
+ label {
18
+ font-size: 14px;
19
+ }
20
+ }
21
+
22
+ .panel a[rel=facebox] {
23
+ background-color: #ddd;
24
+ color: #1e317f;
25
+ font-size: 11px;
26
+ padding: 3px 6px;
27
+ }
28
+
29
+ #push-url {
30
+ padding: 20px;
31
+ margin: 20px;
32
+ border: 3px solid #295666;
33
+ }
34
+
35
+ .action {
36
+ margin: 10px 10px 15px 0;
37
+ font-size: 16px;
38
+ color: #768994;
39
+ }
40
+
41
+ .container {
42
+ padding: 20px;
43
+ margin: auto auto 40px;
44
+ font-size: 12px;
45
+ font-family: Arial, Helvetica, sans-serif;
46
+ }
47
+
48
+ .flash {
49
+ text-align: center;
50
+ margin: 0 40px;
51
+ font-size: 14px;
52
+ padding: 12px;
53
+ border: #999 3px solid;
54
+ color: #295666;
55
+ }
56
+
57
+ .container a {
58
+ text-decoration: none;
59
+ color: #768974;
60
+ }
61
+
62
+ .container a:hover {
63
+ color: #768930;
64
+ border-bottom: #768930 1px dotted;
65
+ }
66
+
67
+
68
+ .container h1, .container h2, .container h3 {
69
+ font-family: Arial, Helvetica, sans-serif;
70
+ }
71
+
72
+ .container h1 {
73
+ font-size: 24px;
74
+ margin-bottom: 10px;
75
+ color: #295666;
76
+ text-align: right;
77
+ text-shadow: #aaa 2px 2px 2px;
78
+ }
79
+
80
+ .container h2 {
81
+ border-bottom: #295666 2px solid;
82
+ font-size: 18px;
83
+ margin-bottom: 10px;
84
+ margin-top: 20px;
85
+ color: #295666;
86
+ }
87
+
88
+ .container h3 {
89
+ border-bottom: #3A402B 1px dotted;
90
+ font-size: 14px;
91
+ margin: 10px 0;
92
+ color: #3A402B;
93
+ }
94
+
95
+ .repositories {
96
+ display: inline-block;
97
+ margin-bottom: 20px;
98
+ }
99
+
100
+ form { display: inline-block; }
101
+
102
+ input[type=submit] {
103
+ background-color: #ddd;
104
+ border: none;
105
+ cursor: pointer;
106
+ color: #1e317f;
107
+ }
108
+
109
+ #header {
110
+ background-color: #295666;
111
+ padding: 20px 10px 5px;
112
+ margin-bottom: 10px;
113
+ h1 {
114
+ color: #eee;
115
+ text-align: left;
116
+ text-shadow: #111 2px 2px 2px;
117
+ }
118
+ .menu {
119
+ float: right;
120
+ display: inline-block;
121
+ a { color: #eee; }
122
+ }
123
+ }
124
+
125
+ #login_form {
126
+ margin: 40px auto;
127
+ width: 240px;
128
+ padding: 20px;
129
+ background-color: #295666;
130
+ color: #ddd;
131
+ font-size: larger;
132
+ border: #aaa 1px solid;
133
+
134
+ p { margin-bottom: 20px; }
135
+ }
136
+
137
+ ul {
138
+ list-style: none;
139
+ padding-bottom: 10px;
140
+ margin-bottom: 10px;
141
+ border-bottom: #ddd 1px dotted;
142
+ li {
143
+ list-stlye: none;
144
+ padding: 2px;
145
+ }
146
+ }
147
+
148
+ .container .pushes {
149
+ width: 100%;
150
+ table { width: 100%; }
151
+ th, td {
152
+ padding: 10px;
153
+ width: 20%;
154
+ }
155
+ th {
156
+ font-size: 120%;
157
+ background-color: #fff;
158
+ color: #3a402b;
159
+ text-align: left;
160
+ }
161
+ td {
162
+ border: #ddd 1px solid;
163
+ }
164
+ th.side {
165
+ border-bottom: #ddd 1px solid;
166
+ text-align: center;
167
+ }
168
+ tr.commits th {
169
+ color: #768994;
170
+ font-weight: normal;
171
+ }
172
+ tr.received.push, tr.undeployed.push, tr.undeploying.push {
173
+ border-left: 10px solid #FFC950;
174
+ }
175
+ tr.ignored {
176
+ border-left: 10px solid #E55714;
177
+ display: none;
178
+ }
179
+ tr.deployed.push th, tr.deploying.push th {
180
+ border-left: 10px solid #17B034;
181
+ background-color: #17B034;
182
+ }
183
+ tr.commits td { font-size: smaller; padding-bottom: 40px; }
184
+ tr.failed.push th {
185
+ border-left: 10px solid #E55714;
186
+ background-color: #E55714;
187
+ }
188
+ }
189
+
190
+ .container .repository {
191
+ padding: 10px;
192
+ background-color: #eee;
193
+ margin: 0 15px 10px 0;
194
+ display: inline-block;
195
+ min-width: 250px;
196
+ float: left;
197
+ }
198
+
@@ -0,0 +1,52 @@
1
+ !!! 5
2
+ %html{:lang=>'en'}
3
+ %head
4
+ %meta{:charset=>"utf-8"}
5
+ %title Stomp Box
6
+ %link{:rel=>"stylesheet", :type=>"text/css", :href=>"#{to('css/html5reset.css')}"}
7
+ %link{:rel=>"stylesheet", :type=>"text/css", :href=>"#{to('css/styles.css')}"}
8
+ %link{:rel=>"stylesheet", :type=>"text/css", :href=>"#{to('css/facebox.css')}"}
9
+ %script{:src=>"https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"}
10
+ %script{:src=>"#{to('javascript/facebox.js')}"}
11
+ :javascript
12
+ $.facebox.settings.closeImage = "#{to('/images/closelabel.png')}"
13
+ $.facebox.settings.loadingImage = "#{to('/images/loading.gif')}"
14
+ jQuery(document).ready(function($) { $('a[rel*=facebox]').facebox() })
15
+
16
+
17
+
18
+ /[if IE]
19
+ %script{:src=>"http://html5shiv.googlecode.com/svn/trunk/html5.js"}
20
+ %style{:type=>"text/css"} .clear { zoom: 1; display: block; }
21
+
22
+ %body
23
+ .container
24
+ #header
25
+ .menu{:style=>'float:right;display:inline-block'}
26
+ %a{:href=>home_path} Dashboard
27
+ \|
28
+ %a{:href=>to("repositories")} Repositories
29
+ \|
30
+ %a{:href=>"#push-popup", :rel=>'facebox'}
31
+ GitHub Push URL
32
+ - if ENV['REQUIRE_AUTHENTICATION']
33
+ \|
34
+ %a{:href=>to("logout")} Logout
35
+
36
+ #push-popup{:style=>'display:none'}
37
+ #push-url= push_path
38
+
39
+ %h1 TorqueBox::StompBox
40
+
41
+
42
+ #content
43
+ = yield
44
+
45
+ - [:error, :notice].each do |level|
46
+ - if flash.has? level
47
+ .flash{:class=>level}= flash[level]
48
+
49
+ %footer#footer
50
+ This software brought to you by
51
+ %a{:href=>'http://projectodd.org'} project : odd
52
+
@@ -0,0 +1,63 @@
1
+ %h1 Dashboard
2
+
3
+ - if @pushes
4
+ %h2 Pushes Received
5
+ .pushes
6
+ %table
7
+ %tr
8
+ %th.side &nbsp;
9
+ %th Date
10
+ %th Status
11
+ %th Commit
12
+ %th Repository
13
+ %th Branch
14
+ - untracked_pushes = false
15
+ - @pushes.each do |push|
16
+ - untracked_pushes = untracked_pushes || !push.tracked?
17
+ %tr{:class=>classes_for(push) << 'push'}
18
+ %th.side Push
19
+ %td
20
+ =push.created_at.strftime("%B %d - %H:%M")
21
+ %td
22
+ =push.status
23
+ - if push.tracked? && !push.deployed?
24
+ %form{:method=>:post, :action=>'deploy'}
25
+ %input{:type=>:hidden, :name=>:id, :value=>push.id}
26
+ %input{:type=>:submit, :value=>:deploy}
27
+ - elsif push.deployed?
28
+ %form{:method=>:post, :action=>'undeploy'}
29
+ %input{:type=>:hidden, :name=>:id, :value=>push.id}
30
+ %input{:type=>:submit, :value=>:undeploy}
31
+ - if push.deployment
32
+ %span.deployment
33
+ %br
34
+ %a{:href=>push.deployment.context}
35
+ =push.deployment.context
36
+
37
+ %td
38
+ %a{:href=>push['compare']}
39
+ =push.short_commit_hash
40
+ %td.repo
41
+ %a{:href=>push.repo_url}
42
+ =push.repo_name
43
+ %td=push.branch
44
+ - unless push['commits'].empty?
45
+ %tr.commits{:class=>classes_for(push)}
46
+ %th.side Commits
47
+ %td{:colspan=>5}
48
+ - push['commits'].each do |commit|
49
+ %ul
50
+ %li=commit['author']['name']
51
+ %li
52
+ %a{:href=>commit['url']}
53
+ =commit['id']
54
+ %li=commit['timestamp']
55
+ %li=commit['message']
56
+
57
+ - if untracked_pushes
58
+ %h2 Untracked Pushes
59
+ You have some untracked pushes.
60
+ %a{:href=>'#', :id=>'toggler'}
61
+ Have a look &rarr;
62
+ :javascript
63
+ $('#toggler').click(function() { $('.ignored').toggle();return false; });
@@ -0,0 +1,7 @@
1
+ - repository ||= Repository.new
2
+ %input{:type=>:text, :name=>'repository[name]', :value=>repository.name}
3
+ %label{:for=>'repository[name]'} Name
4
+ %br
5
+ %input{:type=>:text, :name=>'repository[branch]', :value=>repository.branch}
6
+ %label{:for=>'repository[branch]'} Branch
7
+
@@ -0,0 +1,38 @@
1
+ %h1 Repositories
2
+
3
+ .repositories
4
+ - if @repositories
5
+ - if @repositories.empty?
6
+ %h2 You Haven't Setup Any Repositories Yet
7
+
8
+ - @repositories.each do |repo|
9
+ .repository
10
+ %h3= "#{repo.name} : #{repo.branch}"
11
+ %p
12
+ .panel
13
+ %a{:href=>"#repo-#{repo.id}", :rel=>'facebox'} change
14
+ or
15
+ %form{:action=>"repositories/#{repo.id}", :method=>:post}
16
+ %input{:type=>:hidden, :name=>:_method, :value=>:delete}
17
+ %input.delete{:type=>:submit, :value=>:delete}
18
+
19
+ .panel{:style=>'display:none', :id=>"repo-#{repo.id}"}
20
+ %form{:action=>"repositories/#{repo.id}", :method=>:post}
21
+ = haml :'repositories/form', :locals => { :repository => repo }
22
+ %input{:type=>:hidden, :name=>:_method, :value=>:put}
23
+ %br
24
+ %input{:type=>:submit, :value=>:update, :style=>'margin-top:15px'}
25
+
26
+ .new-repository-link.action
27
+ %a{:href=>'#new-repository', :rel=>'facebox'} New Repository
28
+
29
+ #new-repository{:style=>'display:none'}
30
+ %h2 Add a new repository
31
+ %form{:action=>'repositories', :method=>:post}
32
+ =haml :'repositories/form'
33
+ %input{:type=>:hidden, :name=>:_method, :value=>:post}
34
+ %input{:type=>:submit, :value=>:create}
35
+
36
+ :javascript
37
+ $('.panel .delete').click(function(e) {
38
+ alert("Are you sure you want to do this? It can't be undone.") });
@@ -0,0 +1,8 @@
1
+ %h1 Login
2
+
3
+ #login_form
4
+ %p You need to login before continuing
5
+ %form{:method=>'POST', :action=>login_path}
6
+ %input{:type=>:text, :name=>:user}
7
+ %input{:type=>:password, :name=>:password}
8
+ %input{:type=>:submit, :value=>'Log in!'}
data/bin/dbsetup ADDED
@@ -0,0 +1,97 @@
1
+ #!/bin/sh
2
+ NAME="$(basename $0)"
3
+
4
+ function success_or_failure() {
5
+ if [ $RETVAL -eq 0 ]; then
6
+ echo "Success"
7
+ else
8
+ echo "Failure"
9
+ fi
10
+ echo
11
+ }
12
+
13
+ function setup_database_user() {
14
+ psql -U postgres -c '\du stompbox' | grep stompbox > /dev/null
15
+ if [ $? != 0 ] ; then
16
+ echo " - Create database user 'stompbox'"
17
+ RETVAL=0
18
+ psql -U postgres -q -c "create user stompbox password 'stompbox' createdb"
19
+ RETVAL=$?
20
+ success_or_failure
21
+ else
22
+ echo " - Database user 'stompbox' already exists"
23
+ RETVAL=0
24
+ success_or_failure
25
+ fi
26
+ }
27
+
28
+ function remove_database_user() {
29
+ psql -U postgres -c '\du stompbox' | grep stompbox > /dev/null
30
+ if [ $? == 0 ] ; then
31
+ echo " - Remove database user 'stompbox'"
32
+ RETVAL=0
33
+ psql -U postgres -q -c "drop user stompbox" > /dev/null
34
+ RETVAL=$?
35
+ success_or_failure
36
+ else
37
+ echo " - No database user 'stompbox' to remove"
38
+ RETVAL=0
39
+ success_or_failure
40
+ fi
41
+ }
42
+
43
+ function setup_database() {
44
+ psql -U postgres -l | grep stompbox > /dev/null
45
+ if [ $? != 0 ] ; then
46
+ echo " - Create database 'stompbox'"
47
+ RETVAL=0
48
+ psql -U postgres -q -c "create database stompbox owner stompbox encoding 'utf8'"
49
+ RETVAL=$?
50
+ success_or_failure
51
+ else
52
+ echo " - Database 'stompbox' already exists"
53
+ RETVAL=0
54
+ success_or_failure
55
+ fi
56
+ }
57
+
58
+ function remove_database() {
59
+ psql -U postgres -l | grep stompbox > /dev/null
60
+ if [ $? == 0 ] ; then
61
+ echo " - Remove database 'stompbox'"
62
+ RETVAL=0
63
+ psql -U postgres -q -c "drop database stompbox" > /dev/null
64
+ RETVAL=$?
65
+ success_or_failure
66
+ else
67
+ echo " - No database 'stompbox' to remove"
68
+ RETVAL=0
69
+ success_or_failure
70
+ fi
71
+ }
72
+
73
+ install() {
74
+ setup_database_user
75
+ setup_database
76
+ }
77
+
78
+ uninstall() {
79
+ remove_database
80
+ remove_database_user
81
+ }
82
+
83
+
84
+ case "$1" in
85
+ install)
86
+ install
87
+ ;;
88
+ uninstall)
89
+ uninstall
90
+ ;;
91
+ *)
92
+ echo "usage: ${NAME} (install|uninstall)"
93
+ exit 1
94
+ esac
95
+
96
+ exit $RETVAL
97
+