capitate 0.1.7

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.
Files changed (101) hide show
  1. data/Capfile +24 -0
  2. data/History.txt +22 -0
  3. data/License.txt +20 -0
  4. data/Manifest.txt +100 -0
  5. data/README.txt +1 -0
  6. data/Rakefile +4 -0
  7. data/bin/capitate +46 -0
  8. data/config/hoe.rb +70 -0
  9. data/config/requirements.rb +17 -0
  10. data/lib/capitate/cap_ext/connections.rb +95 -0
  11. data/lib/capitate/cap_ext/extension_proxy.rb +15 -0
  12. data/lib/capitate/cap_ext/variables.rb +59 -0
  13. data/lib/capitate/config.rb +106 -0
  14. data/lib/capitate/plugins/base.rb +85 -0
  15. data/lib/capitate/plugins/gem.rb +25 -0
  16. data/lib/capitate/plugins/package.rb +30 -0
  17. data/lib/capitate/plugins/profiles.rb +33 -0
  18. data/lib/capitate/plugins/script.rb +118 -0
  19. data/lib/capitate/plugins/templates.rb +98 -0
  20. data/lib/capitate/plugins/wget.rb +23 -0
  21. data/lib/capitate/plugins/yum.rb +87 -0
  22. data/lib/capitate/recipes.rb +9 -0
  23. data/lib/capitate/version.rb +9 -0
  24. data/lib/capitate.rb +32 -0
  25. data/lib/doc/centos/memcached.yml +18 -0
  26. data/lib/doc/centos/mongrel_cluster.yml +11 -0
  27. data/lib/doc/centos/monit.yml +12 -0
  28. data/lib/doc/centos/mysql.yml +6 -0
  29. data/lib/doc/centos/nginx.yml +25 -0
  30. data/lib/doc/centos/sphinx.yml +14 -0
  31. data/lib/doc/gems.yml +7 -0
  32. data/lib/doc/install.yml +11 -0
  33. data/lib/doc/memcached.yml +13 -0
  34. data/lib/doc/mongrel_cluster.yml +12 -0
  35. data/lib/doc/mysql.yml +46 -0
  36. data/lib/doc/nginx.yml +23 -0
  37. data/lib/doc/packages.yml +17 -0
  38. data/lib/doc/rails.yml +15 -0
  39. data/lib/profiles/centos-sick.rb +114 -0
  40. data/lib/recipes/README +5 -0
  41. data/lib/recipes/centos/README +3 -0
  42. data/lib/recipes/centos/centos.rb +44 -0
  43. data/lib/recipes/centos/imagemagick.rb +19 -0
  44. data/lib/recipes/centos/memcached.rb +31 -0
  45. data/lib/recipes/centos/mongrel_cluster.rb +34 -0
  46. data/lib/recipes/centos/monit.rb +42 -0
  47. data/lib/recipes/centos/mysql.rb +25 -0
  48. data/lib/recipes/centos/nginx.rb +45 -0
  49. data/lib/recipes/centos/ruby.rb +37 -0
  50. data/lib/recipes/centos/sphinx.rb +49 -0
  51. data/lib/recipes/deploy.rb +18 -0
  52. data/lib/recipes/gems.rb +11 -0
  53. data/lib/recipes/install.rb +18 -0
  54. data/lib/recipes/memcached.rb +14 -0
  55. data/lib/recipes/mongrel_cluster.rb +33 -0
  56. data/lib/recipes/mysql.rb +33 -0
  57. data/lib/recipes/nginx.rb +40 -0
  58. data/lib/recipes/packages.rb +24 -0
  59. data/lib/recipes/rails.rb +20 -0
  60. data/lib/recipes/sphinx.rb +38 -0
  61. data/lib/templates/capistrano/Capfile +26 -0
  62. data/lib/templates/centos/setup_for_web.sh +17 -0
  63. data/lib/templates/centos/sudoers +95 -0
  64. data/lib/templates/memcached/memcached.initd.centos.erb +70 -0
  65. data/lib/templates/memcached/memcached.monitrc.erb +4 -0
  66. data/lib/templates/mongrel/mongrel_cluster.initd.erb +61 -0
  67. data/lib/templates/mongrel/mongrel_cluster.monitrc.erb +15 -0
  68. data/lib/templates/mongrel/mongrel_cluster.yml.erb +10 -0
  69. data/lib/templates/monit/cert.sh +14 -0
  70. data/lib/templates/monit/monit.cnf +34 -0
  71. data/lib/templates/monit/monit.initd.centos.erb +68 -0
  72. data/lib/templates/monit/monitrc.erb +28 -0
  73. data/lib/templates/monit/patch_inittab.sh +15 -0
  74. data/lib/templates/mysql/install_db.sql.erb +7 -0
  75. data/lib/templates/mysql/mysql.monitrc.erb +6 -0
  76. data/lib/templates/nginx/nginx.conf.erb +88 -0
  77. data/lib/templates/nginx/nginx.initd.erb +62 -0
  78. data/lib/templates/nginx/nginx.monitrc.erb +4 -0
  79. data/lib/templates/nginx/nginx_vhost.conf.erb +95 -0
  80. data/lib/templates/rails/database.yml.erb +42 -0
  81. data/lib/templates/ruby/fix_openssl.sh +12 -0
  82. data/lib/templates/sphinx/sphinx.conf.erb +498 -0
  83. data/lib/templates/sphinx/sphinx.monitrc.erb +4 -0
  84. data/lib/templates/sphinx/sphinx_app.initd.centos.erb +67 -0
  85. data/script/destroy +14 -0
  86. data/script/generate +14 -0
  87. data/script/txt2html +74 -0
  88. data/setup.rb +1585 -0
  89. data/tasks/capitate.rake +10 -0
  90. data/tasks/deployment.rake +34 -0
  91. data/tasks/environment.rake +7 -0
  92. data/tasks/website.rake +17 -0
  93. data/test/test_helper.rb +2 -0
  94. data/test/test_recipes.rb +11 -0
  95. data/test/test_templates.rb +29 -0
  96. data/website/index.html +161 -0
  97. data/website/index.txt +86 -0
  98. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  99. data/website/stylesheets/screen.css +138 -0
  100. data/website/template.rhtml +48 -0
  101. metadata +160 -0
@@ -0,0 +1,498 @@
1
+ #
2
+ # Sphinx configuration file sample
3
+ # TODO: This isn't currently used by any recipe. The current setup recipe uses sphinx conf on per application
4
+ # basis.
5
+ #
6
+
7
+ #############################################################################
8
+ ## data source definition
9
+ #############################################################################
10
+
11
+ source <%= application %>
12
+ {
13
+ # data source type
14
+ # for now, known types are 'mysql', 'pgsql' and 'xmlpipe'
15
+ # MUST be defined
16
+ type = mysql
17
+
18
+ # whether to strip HTML
19
+ # values can be 0 (don't strip) or 1 (do strip)
20
+ # WARNING, only works with mysql source for now
21
+ # WARNING, should work ok for PERFECTLY formed XHTML for now
22
+ # WARNING, POSSIBLE TO BUG on malformed everday HTML
23
+ # optional, default is 0
24
+ strip_html = 0
25
+
26
+ # what HTML attributes to index if stripping HTML
27
+ # format is as follows:
28
+ #
29
+ # index_html_attrs = img=alt,title; a=title;
30
+ #
31
+ # optional, default is to not index anything
32
+ index_html_attrs =
33
+
34
+ #####################################################################
35
+
36
+ # some straightforward parameters for 'mysql' source type
37
+ sql_host = 127.0.0.1
38
+ sql_user = <%= db_user %>
39
+ sql_pass = <%= db_pass %>
40
+ sql_db = <%= db_name %>
41
+ sql_port = 3306 # optional, default is 3306
42
+
43
+ # sql_sock = /tmp/mysql.sock
44
+ #
45
+ # optional
46
+ # usually '/var/lib/mysql/mysql.sock' on Linux
47
+ # usually '/tmp/mysql.sock' on FreeBSD
48
+
49
+ # pre-query, executed before the main fetch query
50
+ # useful eg. to setup encoding or mark records
51
+ # optional, default is empty
52
+ #
53
+ # sql_query_pre = SET CHARACTER_SET_RESULTS=cp1251
54
+ sql_query_pre = SET NAMES UTF8
55
+
56
+ # main document fetch query
57
+ #
58
+ # you can specify up to 32 (formally SPH_MAX_FIELDS in sphinx.h) fields;
59
+ # all of the fields which are not document_id or attributes (see below)
60
+ # will be full-text indexed
61
+ #
62
+ # document_id MUST be the very first field
63
+ # document_id MUST be positive (non-zero, non-negative)
64
+ # document_id MUST fit into 32 bits
65
+ # document_id MUST be unique
66
+ #
67
+ # mandatory
68
+ sql_query = \
69
+ SELECT id, UNIX_TIMESTAMP(created_at) AS created_at, body FROM todo
70
+
71
+ # query range setup
72
+ #
73
+ # useful to avoid MyISAM table locks and big result sets
74
+ # when indexing lots of data
75
+ #
76
+ # to use query ranges, you should
77
+ # 1) provide a query to fetch min/max id (ie. id range) from data set;
78
+ # 2) configure step size in which this range will be walked;
79
+ # 3) use $start and $end macros somewhere in the main fetch query.
80
+ #
81
+ # 'sql_query_range' must return exactly two integer fields
82
+ # in exactly min_id, max_id order
83
+ #
84
+ # 'sql_range_step' must be a positive integer
85
+ # optional, default is 1024
86
+ #
87
+ # 'sql_query' must contain both '$start' and '$end' macros
88
+ # if you are using query ranges (because it obviously would be an
89
+ # error to index the whole table many times)
90
+ #
91
+ # note that the intervals specified by $start/$end do not
92
+ # overlap, so you should NOT remove document ids which are exactly
93
+ # equal to $start or $end in your query
94
+ #
95
+ # here's an example which will index 'documents' table
96
+ # fetching (at most) one thousand entries at a time:
97
+ #
98
+ # sql_query_range = SELECT MIN(id),MAX(id) FROM documents
99
+ # sql_range_step = 1000
100
+ # sql_query = \
101
+ # SELECT doc.id, doc.id AS group, doc.title, doc.data \
102
+ # FROM documents doc \
103
+ # WHERE id>=$start AND id<=$end
104
+
105
+
106
+ # attribute columns
107
+ #
108
+ # attribute values MUST be positive (non-zero, non-negative) integers
109
+ # attribute values MUST fit into 32 bits
110
+ #
111
+ # attributes are additional values associated with each document which
112
+ # may be used to perform additional filtering and sorting during search.
113
+ # attributes are NOT full-text indexed; they are stored in the full text
114
+ # index as is.
115
+ #
116
+ # a good example would be a forum posts table. one might need to search
117
+ # through 'title' and 'content' fields but to limit search to specific
118
+ # values of 'author_id', or 'forum_id', or to sort by 'post_date', or to
119
+ # group matches by 'thread_id', or to group posts by month of the
120
+ # 'post_date' and provide statistics.
121
+ #
122
+ # this all can be achieved by specifying all the mentioned columns
123
+ # (excluding 'title' and 'content' which are full-text fields) as
124
+ # attributes and then using API calls to setup filtering, sorting,
125
+ # and grouping.
126
+ #
127
+ # sql_group_column is used to declare integer attributes.
128
+ #
129
+ # sql_date_column is used to declare UNIX timestamp attributes.
130
+ #
131
+ # sql_str2ordinal_column is used to declare integer attributes which
132
+ # values are computed as ordinal numbers of corresponding column value
133
+ # in sorted list of column values. WARNING, all such strings values
134
+ # are going to be stored in RAM while indexing, and "C" locale will
135
+ # be used when sorting!
136
+ #
137
+ # starting with 0.9.7, there may be multiple attribute columns specified.
138
+ # here's an example for that mentioned posts table:
139
+ #
140
+ # sql_group_column = author_id
141
+ # sql_group_column = forum_id
142
+ # sql_group_column = thread_id
143
+ # sql_date_column = post_unix_timestamp
144
+ # sql_date_column = last_edit_unix_timestamp
145
+ #
146
+ # optional, default is empty
147
+ ##sql_group_column = group_id
148
+ sql_date_column = created_at
149
+ # sql_str2ordinal_column = author_name
150
+
151
+ # post-query, executed on the end of main fetch query
152
+ #
153
+ # note that indexing is NOT completed at the point when post-query
154
+ # gets executed and might very well fail
155
+ #
156
+ # optional, default is empty
157
+ ##sql_query_post =
158
+
159
+ # post-index-query, executed on succsefully completed indexing
160
+ #
161
+ # $maxid macro is the max document ID which was actually
162
+ # fetched from the database
163
+ #
164
+ # optional, default is empty
165
+ #
166
+ # sql_query_post_index = REPLACE INTO counters ( id, val ) \
167
+ # VALUES ( 'max_indexed_id', $maxid )
168
+
169
+
170
+ # document info query
171
+ #
172
+ # ONLY used by search utility to display document information
173
+ # MUST be able to fetch document info by its id, therefore
174
+ # MUST contain '$id' macro
175
+ #
176
+ # optional, default is empty
177
+ ##sql_query_info = SELECT * FROM documents WHERE id=$id
178
+
179
+ #####################################################################
180
+
181
+ # demo config for 'xmlpipe' source type is a little below
182
+ #
183
+ # with xmlpipe, indexer opens a pipe to a given command,
184
+ # and then reads documents from stdin
185
+ #
186
+ # indexer expects one or more documents from xmlpipe stdin
187
+ # each document must be formatted exactly as follows:
188
+ #
189
+ # <document>
190
+ # <id>123</id>
191
+ # <group>45</group>
192
+ # <timestamp>1132223498</timestamp>
193
+ # <title>test title</title>
194
+ # <body>
195
+ # this is my document body
196
+ # </body>
197
+ # </document>
198
+ #
199
+ # timestamp element is optional, its default value is 1
200
+ # all the other elements are mandatory
201
+
202
+ # type = xmlpipe
203
+ # xmlpipe_command = cat /var/test.xml
204
+ }
205
+
206
+
207
+ # inherited source example
208
+ #
209
+ # all the parameters are copied from the parent source,
210
+ # and may then be overridden in this source definition
211
+ ##source src1stripped : src1
212
+ ##{
213
+ ## strip_html = 1
214
+ ##}
215
+
216
+ #############################################################################
217
+ ## index definition
218
+ #############################################################################
219
+
220
+ # local index example
221
+ #
222
+ # this is an index which is stored locally in the filesystem
223
+ #
224
+ # all indexing-time options (such as morphology and charsets)
225
+ # are configured per local index
226
+ index <%= application %>
227
+ {
228
+ # which document source to index
229
+ # at least one MUST be defined
230
+ #
231
+ # multiple sources MAY be specified; to do so, just add more
232
+ # "source = NAME" lines. in this case, ALL the document IDs
233
+ # in ALL the specified sources MUST be unique
234
+ source = <%= application %>
235
+
236
+ # this is path and index file name without extension
237
+ #
238
+ # indexer will append different extensions to this path to
239
+ # generate names for both permanent and temporary index files
240
+ #
241
+ # .tmp* files are temporary and can be safely removed
242
+ # if indexer fails to remove them automatically
243
+ #
244
+ # .sp* files are fulltext index data files. specifically,
245
+ # .spa contains attribute values attached to each document id
246
+ # .spd contains doclists and hitlists
247
+ # .sph contains index header (schema and other settings)
248
+ # .spi contains wordlists
249
+ #
250
+ # MUST be defined
251
+ path = /var/sphinx/<%= application %>
252
+
253
+ # docinfo (ie. per-document attribute values) storage strategy
254
+ # defines how docinfo will be stored
255
+ #
256
+ # available values are "none", "inline" and "extern"
257
+ #
258
+ # "none" means there'll be no docinfo at all (no groups/dates)
259
+ #
260
+ # "inline" means that the docinfo will be stored in the .spd
261
+ # file along with the document ID lists (doclists)
262
+ #
263
+ # "extern" means that the docinfo will be stored in the .spa
264
+ # file separately
265
+ #
266
+ # externally stored docinfo should (basically) be kept in RAM
267
+ # when querying; therefore, "inline" may be the only viable option
268
+ # for really huge (50-100+ million docs) datasets. however, for
269
+ # smaller datasets "extern" storage makes both indexing and
270
+ # searching MUCH more efficient.
271
+ #
272
+ # additional search-time memory requirements for extern storage are
273
+ #
274
+ # ( 1 + number_of_attrs )*number_of_docs*4 bytes
275
+ #
276
+ # so 10 million docs with 2 groups and 1 timestamp will take
277
+ # (1+2+1)*10M*4 = 160 MB of RAM. this is PER DAEMON, ie. searchd
278
+ # will alloc 160 MB on startup, read the data and keep it shared
279
+ # between queries; the children will NOT allocate additional
280
+ # copies of this data.
281
+ #
282
+ # default is "extern" (as most collections are smaller than 100M docs)
283
+ docinfo = extern
284
+
285
+ # morphology
286
+ #
287
+ # currently supported morphology preprocessors are Porter stemmers
288
+ # for English and Russian, and Soundex. more stemmers could be added
289
+ # at users request.
290
+ #
291
+ # available values are "none", "stem_en", "stem_ru", "stem_enru",
292
+ # and "soundex"
293
+ #
294
+ # optional, default is "none"
295
+ #
296
+ # morphology = none
297
+ # morphology = stem_en
298
+ # morphology = stem_ru
299
+ # morphology = stem_enru
300
+ # morphology = soundex
301
+ morphology = none
302
+
303
+ # stopwords file
304
+ #
305
+ # format is plain text in whatever encoding you use
306
+ # optional, default is empty
307
+ #
308
+ # stopwords = /var/data/stopwords.txt
309
+ #stopwords =
310
+
311
+ # minimum word length
312
+ #
313
+ # only the words that are of this length and above will be indexed;
314
+ # for example, if min_word_len is 4, "the" won't be indexed,
315
+ # but "they" will be.
316
+ #
317
+ # default is 1, which (obviously) means to index everything
318
+ min_word_len = 1
319
+
320
+ # charset encoding type
321
+ #
322
+ # known types are 'sbcs' (Single Byte CharSet) and 'utf-8'
323
+ #
324
+ # optional, default is sbcs
325
+ charset_type = utf-8
326
+
327
+ # charset definition and case folding rules "table"
328
+ #
329
+ # optional, default value depends on charset_type
330
+ #
331
+ # for now, defaults are configured to support English and Russian
332
+ # this behavior MAY change in future versions
333
+ #
334
+ # 'sbcs' default value is
335
+ # charset_table = 0..9, A..Z->a..z, _, a..z, U+A8->U+B8, U+B8, U+C0..U+DF->U+E0..U+FF, U+E0..U+FF
336
+ #
337
+ # 'utf-8' default value is
338
+ # charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F
339
+
340
+ # minimum prefix length
341
+ #
342
+ # if prefix length is positive, indexer will not only index all words,
343
+ # but all the possible prefixes (ie. word beginnings) as well
344
+ #
345
+ # for instance, "exam" query against such index will match documents
346
+ # which contain "example" word, even if they do not contain "exam"
347
+ #
348
+ # indexing prefixes will make the index grow significantly
349
+ # and could degrade search times
350
+ #
351
+ # currently there's no way to rank perfect word matches higher
352
+ # than prefix matches using only one index; you could setup two
353
+ # indexes for that
354
+ #
355
+ # default is 0, which means NOT to index prefixes
356
+ min_prefix_len = 0
357
+
358
+ # minimum infix length
359
+ #
360
+ # if infix length is positive, indexer will not only index all words,
361
+ # but all the possible infixes (ie. characters subsequences starting
362
+ # anywhere inside the word) as well
363
+ #
364
+ # for instance, "amp" query against such index will match documents
365
+ # which contain "example" word, even if they do not contain "amp"
366
+ #
367
+ # indexing prefixes will make the index grow significantly
368
+ # and could degrade search times
369
+ #
370
+ # currently there's no way to rank perfect word matches higher
371
+ # than infix matches using only one index; you could setup two
372
+ # indexes for that
373
+ #
374
+ # default is 0, which means NOT to index infixes
375
+ min_infix_len = 0
376
+
377
+ # n-grams length
378
+ #
379
+ # n-grams provide basic CJK support for unsegmented texts. if using
380
+ # n-grams, streams of CJK characters are indexed as n-grams. for example,
381
+ # if incoming stream is ABCDEF and n is 2, this text would be indexed
382
+ # as if it was AB BC CD DE EF.
383
+ #
384
+ # this feature is in alpha version state and only n=1 is currently
385
+ # supported; this is going to be improved.
386
+ #
387
+ # note that if search query is segmented (ie. words are separated with
388
+ # whitespace), words are in quotes and extended matching mode is used,
389
+ # then all matching documents will be returned even if their text was
390
+ # *not* segmented. in the example above, ABCDEF text will be indexed as
391
+ # A B C D E F, and "BCD" query will be transformed to "B C D" (where
392
+ # quotes is phrase matching operator), so the document will match.
393
+ #
394
+ # optional, default is 0, which means NOT to use n-grams
395
+ #
396
+ # ngram_len = 1
397
+
398
+ # n-gram characters table
399
+ #
400
+ # specifies what specific characters are subject to n-gram
401
+ # extraction. format is similar to charset_table.
402
+ #
403
+ # optional, default is empty
404
+ #
405
+ # ngrams_chars = U+3000..U+2FA1F
406
+ }
407
+
408
+
409
+ # inherited index example
410
+ #
411
+ # all the parameters are copied from the parent index,
412
+ # and may then be overridden in this index definition
413
+ ##index test1stemmed : test1
414
+ ##{
415
+ ## path = /var/data/test1stemmed
416
+ ## morphology = stem_en
417
+ ##}
418
+
419
+
420
+ #############################################################################
421
+ ## indexer settings
422
+ #############################################################################
423
+
424
+ indexer
425
+ {
426
+ # memory limit
427
+ #
428
+ # may be specified in bytes (no postfix), kilobytes (mem_limit=1000K)
429
+ # or megabytes (mem_limit=10M)
430
+ #
431
+ # will grow if set unacceptably low
432
+ # will warn if set too low and potentially hurting the performance
433
+ #
434
+ # optional, default is 32M
435
+ mem_limit = 32M
436
+ }
437
+
438
+ #############################################################################
439
+ ## searchd settings
440
+ #############################################################################
441
+
442
+ searchd
443
+ {
444
+ # IP address on which search daemon will bind and accept
445
+ # incoming network requests
446
+ #
447
+ # optional, default is to listen on all addresses,
448
+ # ie. address = 0.0.0.0
449
+ #
450
+ address = 127.0.0.1
451
+ # address = 192.168.0.1
452
+
453
+
454
+ # port on which search daemon will listen
455
+ port = 3312
456
+
457
+
458
+ # log file
459
+ # searchd run info is logged here
460
+ log = /var/sphinx/searchd.log
461
+
462
+
463
+ # query log file
464
+ # all the search queries are logged here
465
+ query_log = /var/sphinx/query.log
466
+
467
+
468
+ # client read timeout, seconds
469
+ read_timeout = 5
470
+
471
+
472
+ # maximum amount of children to fork
473
+ # useful to control server load
474
+ max_children = 30
475
+
476
+
477
+ # a file which will contain searchd process ID
478
+ # used for different external automation scripts
479
+ # MUST be present
480
+ pid_file = /var/sphinx/searchd.pid
481
+
482
+
483
+ # maximum amount of matches this daemon would ever retrieve
484
+ # from each index and serve to client
485
+ #
486
+ # this parameter affects per-client memory and CPU usage
487
+ # (16+ bytes per match) in match sorting phase; so blindly raising
488
+ # it to 1 million is definitely NOT recommended
489
+ #
490
+ # starting from 0.9.7, it can be decreased on the fly through
491
+ # the corresponding API call; increasing is prohibited to protect
492
+ # against malicious and/or malformed requests
493
+ #
494
+ # default is 1000 (just like with Google)
495
+ max_matches = 1000
496
+ }
497
+
498
+ # --eof--
@@ -0,0 +1,4 @@
1
+ check process sphinx_<%= application %> with pidfile <%= sphinx_pid_path %>
2
+ group search
3
+ start program = "/sbin/service sphinx_<%= application %> start"
4
+ stop program = "/sbin/service sphinx_<%= application %> stop"
@@ -0,0 +1,67 @@
1
+ #! /bin/sh
2
+ # sphinx: Sphinx search daemon for <%= application %>
3
+ #
4
+ # chkconfig: - 86 14
5
+ # description: sphinx search daemon
6
+ # processname: searchd
7
+ #
8
+ # Author: Gabriel Handford http://ducktyper.com
9
+
10
+ # Source function library
11
+ . /etc/rc.d/init.d/functions
12
+
13
+ RETVAL=0
14
+
15
+ DESC="sphinx daemon (<%= application %>)"
16
+ NAME=searchd
17
+ DAEMON=<%= sphinx_bin_path %>/searchd
18
+ CONFIGFILE=<%= sphinx_conf_path %>
19
+ PIDFILE=<%= sphinx_pid_path %>
20
+
21
+ start() {
22
+ daemon --user <%= user %> $DAEMON --config $CONFIGFILE
23
+ RETVAL=$?
24
+ echo
25
+ return $RETVAL;
26
+ }
27
+
28
+ stop() {
29
+ kill -QUIT `cat $PIDFILE` || echo -n " not running"
30
+ }
31
+
32
+ reload() {
33
+ kill -HUP `cat $PIDFILE` || echo -n " can't reload"
34
+ }
35
+
36
+ case "$1" in
37
+ start)
38
+ echo -n "Starting $DESC: $NAME"
39
+ start
40
+ RETVAL=$?;
41
+ ;;
42
+ stop)
43
+ echo -n "Stopping $DESC: $NAME"
44
+ stop
45
+ RETVAL=$?;
46
+ ;;
47
+ reload)
48
+ echo -n "Reloading $DESC configuration..."
49
+ reload
50
+ RETVAL=$?;
51
+ echo "reloaded."
52
+ ;;
53
+ restart)
54
+ echo -n "Restarting $DESC: $NAME"
55
+ stop
56
+ # Sleep after stop
57
+ sleep 1
58
+ start
59
+ RETVAL=$?;
60
+ ;;
61
+ *)
62
+ echo "Usage: $0 {start|stop|restart|force-reload}" >&2
63
+ RETVAL=3;
64
+ ;;
65
+ esac
66
+
67
+ exit $RETVAL;
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
data/script/txt2html ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'newgem'
6
+ rescue LoadError
7
+ puts "\n\nGenerating the website requires the newgem RubyGem"
8
+ puts "Install: gem install newgem\n\n"
9
+ exit(1)
10
+ end
11
+ require 'redcloth'
12
+ require 'syntax/convertors/html'
13
+ require 'erb'
14
+ require File.dirname(__FILE__) + '/../lib/capitate/version.rb'
15
+
16
+ version = Capitate::VERSION::STRING
17
+ download = 'http://rubyforge.org/projects/capitate'
18
+
19
+ class Fixnum
20
+ def ordinal
21
+ # teens
22
+ return 'th' if (10..19).include?(self % 100)
23
+ # others
24
+ case self % 10
25
+ when 1: return 'st'
26
+ when 2: return 'nd'
27
+ when 3: return 'rd'
28
+ else return 'th'
29
+ end
30
+ end
31
+ end
32
+
33
+ class Time
34
+ def pretty
35
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
36
+ end
37
+ end
38
+
39
+ def convert_syntax(syntax, source)
40
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
41
+ end
42
+
43
+ if ARGV.length >= 1
44
+ src, template = ARGV
45
+ template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
46
+
47
+ else
48
+ puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
49
+ exit!
50
+ end
51
+
52
+ template = ERB.new(File.open(template).read)
53
+
54
+ title = nil
55
+ body = nil
56
+ File.open(src) do |fsrc|
57
+ title_text = fsrc.readline
58
+ body_text = fsrc.read
59
+ syntax_items = []
60
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
61
+ ident = syntax_items.length
62
+ element, syntax, source = $1, $2, $3
63
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
64
+ "syntax-temp-#{ident}"
65
+ }
66
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
67
+ body = RedCloth.new(body_text).to_html
68
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
69
+ end
70
+ stat = File.stat(src)
71
+ created = stat.ctime
72
+ modified = stat.mtime
73
+
74
+ $stdout << template.result(binding)