reqless 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +8 -0
  3. data/README.md +648 -0
  4. data/Rakefile +117 -0
  5. data/bin/docker-build-and-test +22 -0
  6. data/exe/reqless-web +11 -0
  7. data/lib/reqless/config.rb +31 -0
  8. data/lib/reqless/failure_formatter.rb +43 -0
  9. data/lib/reqless/job.rb +496 -0
  10. data/lib/reqless/job_reservers/ordered.rb +29 -0
  11. data/lib/reqless/job_reservers/round_robin.rb +46 -0
  12. data/lib/reqless/job_reservers/shuffled_round_robin.rb +21 -0
  13. data/lib/reqless/lua/reqless-lib.lua +2965 -0
  14. data/lib/reqless/lua/reqless.lua +2545 -0
  15. data/lib/reqless/lua_script.rb +90 -0
  16. data/lib/reqless/middleware/requeue_exceptions.rb +94 -0
  17. data/lib/reqless/middleware/retry_exceptions.rb +72 -0
  18. data/lib/reqless/middleware/sentry.rb +66 -0
  19. data/lib/reqless/middleware/timeout.rb +63 -0
  20. data/lib/reqless/queue.rb +189 -0
  21. data/lib/reqless/queue_priority_pattern.rb +16 -0
  22. data/lib/reqless/server/static/css/bootstrap-responsive.css +686 -0
  23. data/lib/reqless/server/static/css/bootstrap-responsive.min.css +12 -0
  24. data/lib/reqless/server/static/css/bootstrap.css +3991 -0
  25. data/lib/reqless/server/static/css/bootstrap.min.css +689 -0
  26. data/lib/reqless/server/static/css/codemirror.css +112 -0
  27. data/lib/reqless/server/static/css/docs.css +839 -0
  28. data/lib/reqless/server/static/css/jquery.noty.css +105 -0
  29. data/lib/reqless/server/static/css/noty_theme_twitter.css +137 -0
  30. data/lib/reqless/server/static/css/style.css +200 -0
  31. data/lib/reqless/server/static/favicon.ico +0 -0
  32. data/lib/reqless/server/static/img/glyphicons-halflings-white.png +0 -0
  33. data/lib/reqless/server/static/img/glyphicons-halflings.png +0 -0
  34. data/lib/reqless/server/static/js/bootstrap-alert.js +94 -0
  35. data/lib/reqless/server/static/js/bootstrap-scrollspy.js +125 -0
  36. data/lib/reqless/server/static/js/bootstrap-tab.js +130 -0
  37. data/lib/reqless/server/static/js/bootstrap-tooltip.js +270 -0
  38. data/lib/reqless/server/static/js/bootstrap-typeahead.js +285 -0
  39. data/lib/reqless/server/static/js/bootstrap.js +1726 -0
  40. data/lib/reqless/server/static/js/bootstrap.min.js +6 -0
  41. data/lib/reqless/server/static/js/codemirror.js +2972 -0
  42. data/lib/reqless/server/static/js/jquery.noty.js +220 -0
  43. data/lib/reqless/server/static/js/mode/javascript.js +360 -0
  44. data/lib/reqless/server/static/js/theme/cobalt.css +18 -0
  45. data/lib/reqless/server/static/js/theme/eclipse.css +25 -0
  46. data/lib/reqless/server/static/js/theme/elegant.css +10 -0
  47. data/lib/reqless/server/static/js/theme/lesser-dark.css +45 -0
  48. data/lib/reqless/server/static/js/theme/monokai.css +28 -0
  49. data/lib/reqless/server/static/js/theme/neat.css +9 -0
  50. data/lib/reqless/server/static/js/theme/night.css +21 -0
  51. data/lib/reqless/server/static/js/theme/rubyblue.css +21 -0
  52. data/lib/reqless/server/static/js/theme/xq-dark.css +46 -0
  53. data/lib/reqless/server/views/_job.erb +259 -0
  54. data/lib/reqless/server/views/_job_list.erb +8 -0
  55. data/lib/reqless/server/views/_pagination.erb +7 -0
  56. data/lib/reqless/server/views/about.erb +130 -0
  57. data/lib/reqless/server/views/completed.erb +11 -0
  58. data/lib/reqless/server/views/config.erb +14 -0
  59. data/lib/reqless/server/views/failed.erb +48 -0
  60. data/lib/reqless/server/views/failed_type.erb +18 -0
  61. data/lib/reqless/server/views/job.erb +17 -0
  62. data/lib/reqless/server/views/layout.erb +451 -0
  63. data/lib/reqless/server/views/overview.erb +137 -0
  64. data/lib/reqless/server/views/queue.erb +125 -0
  65. data/lib/reqless/server/views/queues.erb +45 -0
  66. data/lib/reqless/server/views/tag.erb +6 -0
  67. data/lib/reqless/server/views/throttles.erb +38 -0
  68. data/lib/reqless/server/views/track.erb +75 -0
  69. data/lib/reqless/server/views/worker.erb +34 -0
  70. data/lib/reqless/server/views/workers.erb +14 -0
  71. data/lib/reqless/server.rb +549 -0
  72. data/lib/reqless/subscriber.rb +74 -0
  73. data/lib/reqless/test_helpers/worker_helpers.rb +55 -0
  74. data/lib/reqless/throttle.rb +57 -0
  75. data/lib/reqless/version.rb +5 -0
  76. data/lib/reqless/worker/base.rb +237 -0
  77. data/lib/reqless/worker/forking.rb +215 -0
  78. data/lib/reqless/worker/serial.rb +41 -0
  79. data/lib/reqless/worker.rb +5 -0
  80. data/lib/reqless.rb +309 -0
  81. metadata +399 -0
@@ -0,0 +1,105 @@
1
+
2
+ /* CORE STYLES */
3
+
4
+ /* noty bar */
5
+ .noty_bar {
6
+ position: fixed;
7
+ display: none;
8
+ z-index: 9999999;
9
+ }
10
+
11
+ /* noty_message */
12
+ .noty_bar .noty_message {
13
+ text-align: center;
14
+ }
15
+
16
+ /* noty close button */
17
+ .noty_bar .noty_close {
18
+ cursor: pointer;
19
+ }
20
+
21
+ /* noty modal */
22
+ .noty_modal {
23
+ position: fixed;
24
+ width: 100%;
25
+ height: 100%;
26
+ background-color: #000;
27
+ z-index: 10000;
28
+ opacity: 0.6;
29
+ display: none;
30
+ left: 0;
31
+ top: 0;
32
+ }
33
+
34
+ /* noty container for noty_layout_topLeft & noty_layout_topRight */
35
+ ul.noty_cont {
36
+ position: fixed;
37
+ z-index: 10000000;
38
+ margin: 0px;
39
+ padding: 0px;
40
+ list-style: none;
41
+ width: 300px;
42
+ }
43
+ ul.noty_cont li {
44
+ position: relative;
45
+ float: left;
46
+ clear: both;
47
+ list-style: none;
48
+ padding: 0px;
49
+ margin: 10px 0 0 0;
50
+ width: 300px; /* Fix for: http://bugs.jquery.com/ticket/2278 */
51
+ }
52
+ ul.noty_cont.noty_layout_topLeft {left:20px; top:20px;}
53
+ ul.noty_cont.noty_layout_topRight {right:40px; top:20px;}
54
+ ul.noty_cont.noty_layout_bottomLeft {left:20px; bottom:20px}
55
+ ul.noty_cont.noty_layout_bottomRight {right:40px; bottom:20px}
56
+ ul.noty_cont.noty_layout_topRight li {float:right}
57
+
58
+ /* LAYOUTS */
59
+
60
+ /* noty_layout_top */
61
+ .noty_bar.noty_layout_top {
62
+ top: 0;
63
+ left: 0;
64
+ width: 100%;
65
+ -webkit-border-radius: 0px;
66
+ -moz-border-radius: 0px;
67
+ border-radius: 0px;
68
+ }
69
+
70
+ /* noty_layout_bottom */
71
+ .noty_bar.noty_layout_bottom {
72
+ bottom: 0;
73
+ left: 0;
74
+ width: 100%;
75
+ -webkit-border-radius: 0px;
76
+ -moz-border-radius: 0px;
77
+ border-radius: 0px;
78
+ }
79
+
80
+ /* noty_layout_center */
81
+ .noty_bar.noty_layout_center {
82
+ top: 40%;
83
+ }
84
+
85
+ /* noty_layout_topLeft & noty_layout_topRight */
86
+ .noty_bar.noty_layout_topLeft,
87
+ .noty_bar.noty_layout_topRight,
88
+ .noty_bar.noty_layout_bottomLeft,
89
+ .noty_bar.noty_layout_bottomRight {
90
+ width: 100%;
91
+ clear: both;
92
+ position: relative;
93
+ }
94
+
95
+ .noty_bar.noty_layout_topLeft .noty_message,
96
+ .noty_bar.noty_layout_topRight .noty_message,
97
+ .noty_bar.noty_layout_bottomLeft .noty_message,
98
+ .noty_bar.noty_layout_bottomRight .noty_message {
99
+ text-align: left;
100
+ }
101
+
102
+ /* noty_layout_topCenter */
103
+ .noty_bar.noty_layout_topCenter {
104
+ top: 20px;
105
+ }
@@ -0,0 +1,137 @@
1
+
2
+ /* CORE STYLES*/
3
+
4
+ /* noty bar */
5
+ .noty_bar.noty_theme_twitter {
6
+ font-size: 13px;
7
+ line-height: 18px;
8
+ text-shadow: 0 1px 0 #fff;
9
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
10
+ }
11
+
12
+ /* custom container */
13
+ .noty_custom_container.noty_theme_twitter.noty_layout_inline {
14
+ position: relative;
15
+ }
16
+
17
+ /* custom growl container */
18
+ .noty_custom_container.noty_theme_twitter.noty_layout_inline .noty_cont.noty_layout_inline {
19
+ position: static;
20
+ }
21
+ /* custom noty bar */
22
+ .noty_custom_container.noty_theme_twitter.noty_layout_inline .noty_bar {
23
+ position: static;
24
+ }
25
+ .noty_custom_container.noty_theme_twitter.noty_layout_inline .noty_bar .noty_message {
26
+ font-size: 13px;
27
+ padding: 4px;
28
+ }
29
+ .noty_custom_container.noty_theme_twitter.noty_layout_inline .noty_bar .noty_message .noty_buttons {
30
+ margin-top: -1px;
31
+ }
32
+
33
+ /* noty_message */
34
+ .noty_bar.noty_theme_twitter .noty_message {
35
+ padding: 8px 14px;
36
+ }
37
+ /* noty_has_close_button */
38
+ .noty_bar.noty_theme_twitter.noty_closable .noty_message {
39
+ padding: 8px 35px 8px 14px;
40
+ }
41
+
42
+ /* noty_buttons */
43
+ .noty_bar.noty_theme_twitter .noty_message .noty_buttons {
44
+ float: right;
45
+ margin-top: -5px;
46
+ margin-left: 4px;
47
+ }
48
+
49
+ /* noty_button */
50
+ .noty_bar.noty_theme_twitter .noty_message .noty_buttons button {
51
+ margin-left: 5px;
52
+ }
53
+
54
+ /* noty close button */
55
+ .noty_bar.noty_theme_twitter .noty_close {
56
+ position: absolute;
57
+ top: 7px;
58
+ right: 16px;
59
+ font-size: 18px;
60
+ line-height: 18px;
61
+ font-weight: bold;
62
+ color: #000;
63
+ opacity: 0.2;
64
+ text-shadow: 0 1px 0 #fff;
65
+ }
66
+
67
+ /* noty close button hover */
68
+ .noty_bar.noty_theme_twitter .noty_close:hover {
69
+ opacity: 0.4;
70
+ }
71
+
72
+ .noty_bar.noty_theme_twitter .noty_close:after {
73
+ content: "x";
74
+ }
75
+
76
+ /* noty modal */
77
+ .noty_modal.noty_theme_twitter {
78
+ opacity: 0.7;
79
+ }
80
+
81
+ /* LAYOUTS */
82
+
83
+ /* noty_layout_topLeft & noty_layout_topRight */
84
+ .noty_bar.noty_theme_twitter.noty_layout_center,
85
+ .noty_bar.noty_theme_twitter.noty_layout_topCenter,
86
+ .noty_bar.noty_theme_twitter.noty_layout_topLeft,
87
+ .noty_bar.noty_theme_twitter.noty_layout_topRight,
88
+ .noty_bar.noty_theme_twitter.noty_layout_bottomLeft,
89
+ .noty_bar.noty_theme_twitter.noty_layout_bottomRight {
90
+ -webkit-border-radius: 4px;
91
+ -moz-border-radius: 4px;
92
+ border-radius: 4px;
93
+ }
94
+ .noty_bar.noty_theme_twitter.noty_layout_topLeft .noty_message .noty_buttons,
95
+ .noty_bar.noty_theme_twitter.noty_layout_topRight .noty_message .noty_buttons,
96
+ .noty_bar.noty_theme_twitter.noty_layout_bottomLeft .noty_message .noty_buttons,
97
+ .noty_bar.noty_theme_twitter.noty_layout_bottomRight .noty_message .noty_buttons {
98
+ float: none;
99
+ border-top: 1px solid #FBEED5;
100
+ margin-left: 0;
101
+ margin-top: 10px;
102
+ padding-top: 10px;
103
+ text-align: right;
104
+ }
105
+
106
+ .noty_bar.noty_theme_twitter.noty_layout_center .noty_message .noty_buttons,
107
+ .noty_bar.noty_theme_twitter.noty_layout_topCenter .noty_message .noty_buttons {
108
+ margin-left: 15px;
109
+ margin-top: -2px
110
+ }
111
+
112
+ /* NOTIFICATION TYPES */
113
+
114
+ /* noty_alert */
115
+ .noty_bar.noty_theme_twitter.noty_alert {
116
+ background-color: #FCF8E3;
117
+ border: 1px solid #FBEED5;
118
+ color: #C09853;
119
+ }
120
+ /* noty_error */
121
+ .noty_bar.noty_theme_twitter.noty_error {
122
+ background-color: #F2DEDE;
123
+ border: 1px solid #EED3D7;
124
+ color: #B94A48;
125
+ }
126
+ /* noty_success */
127
+ .noty_bar.noty_theme_twitter.noty_success {
128
+ background-color: #DFF0D8;
129
+ border: 1px solid #D6E9C6;
130
+ color: #468847;
131
+ }
132
+ /* noty_information */
133
+ .noty_bar.noty_theme_twitter.noty_information {
134
+ background-color: #D9EDF7;
135
+ border: 1px solid #BCE8F1;
136
+ color: #3A87AD;
137
+ }
@@ -0,0 +1,200 @@
1
+ /* @override http://localhost:4567/css/style.css */
2
+
3
+ .queue-name {
4
+ font-size: 25px;
5
+ font-weight: bold;
6
+ }
7
+
8
+ .queue-summary {
9
+ font-size: 20px;
10
+ }
11
+
12
+ .queue-summary-description {
13
+ font-size: 12px;
14
+ color: lightgrey;
15
+ }
16
+
17
+ .queue-stats {
18
+ margin-top: 10px;
19
+ }
20
+
21
+ .queue-stats-date {}
22
+ .queue-stats-failures {}
23
+ .queue-stats-time {}
24
+ .queue-stats-wait {}
25
+
26
+ .queue-stats-time-title {
27
+ font-size: 20px;
28
+ width: 100%;
29
+ text-align: center;
30
+ margin-bottom: 10px;
31
+ margin-top: 10px;
32
+ }
33
+
34
+ .queue-stats-time-summary {
35
+ text-align: center;
36
+ }
37
+
38
+ .queue-stats-time-histogram-wait {}
39
+ .queue-stats-time-histogram-run {}
40
+
41
+ .job-id {
42
+ float: left;
43
+ font-size: 20px;
44
+ font-weight: bold;
45
+ padding-bottom: 10px;
46
+ }
47
+
48
+ .job-priority {
49
+ font-size: 16px;
50
+ padding-left: 5px;
51
+ }
52
+
53
+ .button {
54
+ background-color: darkgray;
55
+ float: left;
56
+ -webkit-border-radius: 5px;
57
+ -moz-border-radius: 5px;
58
+ border-radius: 5px;
59
+ color: white;
60
+ font-weight: bold;
61
+ padding-top: 2px;
62
+ padding-left: 7px;
63
+ padding-right: 7px;
64
+ padding-bottom: 3px;
65
+ margin-left: 5px;
66
+
67
+ }
68
+
69
+ .cancel-button {
70
+ background-color: red;
71
+ }
72
+
73
+ .job-tags {
74
+ clear: both;
75
+ margin-left: 15px;
76
+ }
77
+
78
+ .job-tag {
79
+ border: none;
80
+ -webkit-border-radius: 15px;
81
+ -moz-border-radius: 15px;
82
+ border-radius: 15px;
83
+ padding-left: 10px;
84
+ padding-right: 10px;
85
+ }
86
+
87
+ .job-summary-container > .job-tags {
88
+ float: left;
89
+ clear: none;
90
+ margin-top: 1px;
91
+ }
92
+
93
+ .job-summary-container > .job-summary {
94
+ float: left;
95
+ clear: none;
96
+ margin-top: -7px;
97
+ padding-left: 12px;
98
+ }
99
+
100
+ .job-summary {
101
+ clear: both;
102
+ padding-top: 10px;
103
+ font-size: 16px;
104
+ }
105
+
106
+ .job-state, .job-queue, .job-worker {
107
+ font-weight: bold;
108
+ }
109
+
110
+ .job-data-container {
111
+ margin-top: 10px;
112
+ border: 2px solid black;
113
+ }
114
+
115
+ html { background:#efefef; font-family:Arial, Verdana, sans-serif; font-size:13px; }
116
+ body { padding:0; margin:0; }
117
+
118
+ .header { background:#000; padding:8px 5% 0 5%; border-bottom:1px solid #444;border-bottom:5px solid #4d87e2;}
119
+ .header h1 { color:#333; font-size:90%; font-weight:bold; margin-bottom:6px;}
120
+ .header ul li { display:inline;}
121
+ .header ul li a { color:#fff; text-decoration:none; margin-right:10px; display:inline-block; padding:8px; -webkit-border-top-right-radius:6px; -webkit-border-top-left-radius:6px; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; }
122
+ .header ul li a:hover { background:#333;}
123
+ .header ul li.current a { background:#ce1212; font-weight:bold; color:#fff;}
124
+
125
+ .header .namespace { position: absolute; right: 75px; top: 10px; color: #7A7A7A; }
126
+
127
+ .subnav { padding:2px 5% 7px 5%; background:#ce1212; font-size:90%;}
128
+ .subnav li { display:inline;}
129
+ .subnav li a { color:#fff; text-decoration:none; margin-right:10px; display:inline-block; background:#dd5b5b; padding:5px; -webkit-border-radius:3px; -moz-border-radius:3px;}
130
+ .subnav li.current a { background:#fff; font-weight:bold; color:#ce1212;}
131
+ .subnav li a:active { background:#b00909;}
132
+
133
+ #main { padding:10px 5%; background:#fff; overflow:hidden; }
134
+ #main .logo { float:right; margin:10px;}
135
+ #main span.hl { background:#efefef; padding:2px;}
136
+ #main h1 { margin:10px 0; font-size:190%; font-weight:bold; color:#ce1212;}
137
+ #main h2 { margin:10px 0; font-size:130%;}
138
+ #main table { width:100%; margin:10px 0;}
139
+ #main table tr td, #main table tr th { border:1px solid #ccc; padding:6px;}
140
+ #main table tr th { background:#efefef; color:#888; font-size:80%; font-weight:bold;}
141
+ #main table tr td.no-data { text-align:center; padding:40px 0; color:#999; font-style:italic; font-size:130%;}
142
+ #main a { color:#111;}
143
+ #main p { margin:5px 0;}
144
+ #main p.intro { margin-bottom:15px; font-size:85%; color:#999; margin-top:0; line-height:1.3;}
145
+ #main h1.wi { margin-bottom:5px;}
146
+ #main p.sub { font-size:95%; color:#999;}
147
+
148
+ #main table.queues { width:40%;}
149
+ #main table.queues td.queue { font-weight:bold; width:50%;}
150
+ #main table.queues tr.failed td { border-top:2px solid; font-size:90%; }
151
+ #main table.queues tr.failure td { background:#ffecec; border-top:2px solid #d37474; font-size:90%; color:#d37474;}
152
+ #main table.queues tr.failure td a{ color:#d37474;}
153
+
154
+ #main table.jobs td.class { font-family:Monaco, "Courier New", monospace; font-size:90%; width:50%;}
155
+ #main table.jobs td.args{ width:50%;}
156
+
157
+ #main table.workers td.icon {width:1%; background:#efefef;text-align:center;}
158
+ #main table.workers td.icon img { height: 16px; width: 16px; }
159
+ #main table.workers td.where { width:25%;}
160
+ #main table.workers td.queues { width:35%;}
161
+ #main .queue-tag { background:#b1d2e9; padding:2px; margin:0 3px; font-size:80%; text-decoration:none; text-transform:uppercase; font-weight:bold; color:#3274a2; -webkit-border-radius:4px; -moz-border-radius:4px;}
162
+ #main table.workers td.queues.queue { width:10%;}
163
+ #main table.workers td.process { width:35%;}
164
+ #main table.workers td.process span.waiting { color:#999; font-size:90%;}
165
+ #main table.workers td.process small { font-size:80%; margin-left:5px;}
166
+ #main table.workers td.process code { font-family:Monaco, "Courier New", monospace; font-size:90%;}
167
+ #main table.workers td.process small a { color:#999;}
168
+ #main.polling table.workers tr.working td { background:#f4ffe4; color:#7ac312;}
169
+ #main.polling table.workers tr.working td.where a { color:#7ac312;}
170
+ #main.polling table.workers tr.working td.process code { font-weight:bold;}
171
+
172
+
173
+ #main table.stats th { font-size:100%; width:40%; color:#000;}
174
+ #main hr { border:0; border-top:5px solid #efefef; margin:15px 0;}
175
+
176
+ #footer { padding:10px 5%; background:#efefef; color:#999; font-size:85%; line-height:1.5; border-top:5px solid #ccc; padding-top:10px;}
177
+ #footer p a { color:#999;}
178
+
179
+ #main p.poll { background:url(poll.png) no-repeat 0 2px; padding:3px 0; padding-left:23px; float:right; font-size:85%; }
180
+
181
+ #main ul.failed {}
182
+ #main ul.failed li {background:-webkit-gradient(linear, left top, left bottom, from(#efefef), to(#fff)) #efefef; margin-top:10px; padding:10px; overflow:hidden; -webkit-border-radius:5px; border:1px solid #ccc; }
183
+ #main ul.failed li dl dt {font-size:80%; color:#999; width:60px; float:left; padding-top:1px; text-align:right;}
184
+ #main ul.failed li dl dd {margin-bottom:10px; margin-left:70px;}
185
+ #main ul.failed li dl dd .retried { float:right; text-align: right; }
186
+ #main ul.failed li dl dd .retried .remove { display:none; margin-top: 8px; }
187
+ #main ul.failed li.hover dl dd .retried .remove { display:block; }
188
+ #main ul.failed li dl dd .controls { display:none; float:right; }
189
+ #main ul.failed li.hover dl dd .controls { display:block; }
190
+ #main ul.failed li dl dd code, #main ul.failed li dl dd pre { font-family:Monaco, "Courier New", monospace; font-size:90%; white-space: pre-wrap;}
191
+ #main ul.failed li dl dd.error a {font-family:Monaco, "Courier New", monospace; font-size:90%; }
192
+ #main ul.failed li dl dd.error pre { margin-top:3px; line-height:1.3;}
193
+
194
+ #main p.pagination { background:#efefef; padding:10px; overflow:hidden;}
195
+ #main p.pagination a.less { float:left;}
196
+ #main p.pagination a.more { float:right;}
197
+
198
+ #main form {float:right; margin-top:-10px;margin-left:10px;}
199
+
200
+ #main .time a.toggle_format {text-decoration:none;}
@@ -0,0 +1,94 @@
1
+ /* ==========================================================
2
+ * bootstrap-alert.js v2.0.2
3
+ * http://twitter.github.com/bootstrap/javascript.html#alerts
4
+ * ==========================================================
5
+ * Copyright 2012 Twitter, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ * ========================================================== */
19
+
20
+
21
+ !function( $ ){
22
+
23
+ "use strict"
24
+
25
+ /* ALERT CLASS DEFINITION
26
+ * ====================== */
27
+
28
+ var dismiss = '[data-dismiss="alert"]'
29
+ , Alert = function ( el ) {
30
+ $(el).on('click', dismiss, this.close)
31
+ }
32
+
33
+ Alert.prototype = {
34
+
35
+ constructor: Alert
36
+
37
+ , close: function ( e ) {
38
+ var $this = $(this)
39
+ , selector = $this.attr('data-target')
40
+ , $parent
41
+
42
+ if (!selector) {
43
+ selector = $this.attr('href')
44
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
45
+ }
46
+
47
+ $parent = $(selector)
48
+ $parent.trigger('close')
49
+
50
+ e && e.preventDefault()
51
+
52
+ $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
53
+
54
+ $parent
55
+ .trigger('close')
56
+ .removeClass('in')
57
+
58
+ function removeElement() {
59
+ $parent
60
+ .trigger('closed')
61
+ .remove()
62
+ }
63
+
64
+ $.support.transition && $parent.hasClass('fade') ?
65
+ $parent.on($.support.transition.end, removeElement) :
66
+ removeElement()
67
+ }
68
+
69
+ }
70
+
71
+
72
+ /* ALERT PLUGIN DEFINITION
73
+ * ======================= */
74
+
75
+ $.fn.alert = function ( option ) {
76
+ return this.each(function () {
77
+ var $this = $(this)
78
+ , data = $this.data('alert')
79
+ if (!data) $this.data('alert', (data = new Alert(this)))
80
+ if (typeof option == 'string') data[option].call($this)
81
+ })
82
+ }
83
+
84
+ $.fn.alert.Constructor = Alert
85
+
86
+
87
+ /* ALERT DATA-API
88
+ * ============== */
89
+
90
+ $(function () {
91
+ $('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
92
+ })
93
+
94
+ }( window.jQuery );
@@ -0,0 +1,125 @@
1
+ /* =============================================================
2
+ * bootstrap-scrollspy.js v2.0.2
3
+ * http://twitter.github.com/bootstrap/javascript.html#scrollspy
4
+ * =============================================================
5
+ * Copyright 2012 Twitter, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ * ============================================================== */
19
+
20
+ !function ( $ ) {
21
+
22
+ "use strict"
23
+
24
+ /* SCROLLSPY CLASS DEFINITION
25
+ * ========================== */
26
+
27
+ function ScrollSpy( element, options) {
28
+ var process = $.proxy(this.process, this)
29
+ , $element = $(element).is('body') ? $(window) : $(element)
30
+ , href
31
+ this.options = $.extend({}, $.fn.scrollspy.defaults, options)
32
+ this.$scrollElement = $element.on('scroll.scroll.data-api', process)
33
+ this.selector = (this.options.target
34
+ || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
35
+ || '') + ' .nav li > a'
36
+ this.$body = $('body').on('click.scroll.data-api', this.selector, process)
37
+ this.refresh()
38
+ this.process()
39
+ }
40
+
41
+ ScrollSpy.prototype = {
42
+
43
+ constructor: ScrollSpy
44
+
45
+ , refresh: function () {
46
+ this.targets = this.$body
47
+ .find(this.selector)
48
+ .map(function () {
49
+ var href = $(this).attr('href')
50
+ return /^#\w/.test(href) && $(href).length ? href : null
51
+ })
52
+
53
+ this.offsets = $.map(this.targets, function (id) {
54
+ return $(id).position().top
55
+ })
56
+ }
57
+
58
+ , process: function () {
59
+ var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
60
+ , offsets = this.offsets
61
+ , targets = this.targets
62
+ , activeTarget = this.activeTarget
63
+ , i
64
+
65
+ for (i = offsets.length; i--;) {
66
+ activeTarget != targets[i]
67
+ && scrollTop >= offsets[i]
68
+ && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
69
+ && this.activate( targets[i] )
70
+ }
71
+ }
72
+
73
+ , activate: function (target) {
74
+ var active
75
+
76
+ this.activeTarget = target
77
+
78
+ this.$body
79
+ .find(this.selector).parent('.active')
80
+ .removeClass('active')
81
+
82
+ active = this.$body
83
+ .find(this.selector + '[href="' + target + '"]')
84
+ .parent('li')
85
+ .addClass('active')
86
+
87
+ if ( active.parent('.dropdown-menu') ) {
88
+ active.closest('li.dropdown').addClass('active')
89
+ }
90
+ }
91
+
92
+ }
93
+
94
+
95
+ /* SCROLLSPY PLUGIN DEFINITION
96
+ * =========================== */
97
+
98
+ $.fn.scrollspy = function ( option ) {
99
+ return this.each(function () {
100
+ var $this = $(this)
101
+ , data = $this.data('scrollspy')
102
+ , options = typeof option == 'object' && option
103
+ if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
104
+ if (typeof option == 'string') data[option]()
105
+ })
106
+ }
107
+
108
+ $.fn.scrollspy.Constructor = ScrollSpy
109
+
110
+ $.fn.scrollspy.defaults = {
111
+ offset: 10
112
+ }
113
+
114
+
115
+ /* SCROLLSPY DATA-API
116
+ * ================== */
117
+
118
+ $(function () {
119
+ $('[data-spy="scroll"]').each(function () {
120
+ var $spy = $(this)
121
+ $spy.scrollspy($spy.data())
122
+ })
123
+ })
124
+
125
+ }( window.jQuery );