capitate 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/lib/capitate/plugins/templates.rb +2 -0
- data/lib/capitate/plugins/utils.rb +12 -0
- data/lib/capitate/version.rb +1 -1
- data/lib/recipes/sphinx.rb +20 -17
- data/lib/templates/sphinx/sphinx.conf.erb +39 -9
- data/website/index.html +1 -1
- metadata +2 -2
data/History.txt
CHANGED
@@ -32,10 +32,12 @@ module Capitate::Plugins::Templates
|
|
32
32
|
# Use first
|
33
33
|
template_path = template_dirs_found.first + "/#{path}"
|
34
34
|
|
35
|
+
logger.info "reading #{template_path}"
|
35
36
|
template_data = IO.read(template_path)
|
36
37
|
|
37
38
|
if File.extname(template_path) == ".erb"
|
38
39
|
template = ERB.new(template_data)
|
40
|
+
logger.info "evaluating #{template_path}"
|
39
41
|
template_data = template.result(override_binding || binding)
|
40
42
|
end
|
41
43
|
template_data
|
@@ -110,6 +110,18 @@ module Capitate::Plugins::Utils
|
|
110
110
|
found
|
111
111
|
end
|
112
112
|
|
113
|
+
# Get the hostname of the remote server
|
114
|
+
#
|
115
|
+
# ==== Example
|
116
|
+
# utils.hostname => "localhost.localdomain"
|
117
|
+
#
|
118
|
+
def hostname
|
119
|
+
run "hostname" do |channel, stream, data|
|
120
|
+
return data.chomp
|
121
|
+
end
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
|
113
125
|
# Append data to a file.
|
114
126
|
# Optionally check that it exists before adding.
|
115
127
|
#
|
data/lib/capitate/version.rb
CHANGED
data/lib/recipes/sphinx.rb
CHANGED
@@ -4,22 +4,24 @@ namespace :sphinx do
|
|
4
4
|
desc <<-DESC
|
5
5
|
Update sphinx for application.
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
<dl>
|
8
|
+
<dt>sphinx_conf_template</dt><dd>Path to sphinx.conf.erb.</dd><dd>_Defaults to "config/templates/sphinx.conf.erb"_</dd>
|
9
|
+
<dt>sphinx_conf_path</dt><dd>Path to sphinx.conf.</dd><dd>_Defaults to "[shared_path]/config/sphinx.conf"_</dd>
|
10
|
+
<dt>sphinx_port</dt><dd>Sphinx port.</dd><dd>_Defaults to 3312_</dd>
|
11
|
+
<dt>sphinx_conf_root</dt><dd>Directory for sphinx configuration, like stopwords.txt.</dd><dd>_Defaults to [current_path]/config_</dd>
|
12
|
+
<dt>sphinx_index_root</dt><dd>Directory for sphinx indexes.</dd><dd>_Defaults to "[shared_path]/var/index"_</dd>
|
13
|
+
<dt>sphinx_log_root</dt><dd>Directory for sphinx logs.</dd><dd>_Defaults to "[shared_path]/log"_</dd>
|
14
|
+
<dt>sphinx_pid_root</dt><dd>Directory for sphinx pids.</dd><dd>_Defaults to "[shared_path]/pids"_</dd>
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
<dt>sphinx_db_user</dt><dd>Sphinx DB user.</dd><dd>_Defaults to db_user_</dd>
|
17
|
+
<dt>sphinx_db_pass</dt><dd>Sphinx DB password.</dd><dd>_Defaults to db_pass_</dd>
|
18
|
+
<dt>sphinx_db_name</dt><dd>Sphinx DB name.</dd><dd>_Defaults to db_name_</dd>
|
19
|
+
<dt>sphinx_db_port</dt><dd>Sphinx DB port.</dd><dd>_Defaults to db_port_</dd>
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
<dt>sphinx_db_host</dt><dd>Sphinx DB host.</dd><dd>_Defaults to db_host_</dd>
|
22
|
+
<dt>sphinx_conf_host</dt><dd>Sphinx DB host to listen on.</dd><dd>_Defaults to 127.0.0.1_</dd>
|
22
23
|
|
24
|
+
</dl>
|
23
25
|
"Source":#{link_to_source(__FILE__)}
|
24
26
|
DESC
|
25
27
|
task :update_conf do
|
@@ -31,6 +33,7 @@ namespace :sphinx do
|
|
31
33
|
fetch_or_default(:sphinx_index_root, "#{shared_path}/var/index")
|
32
34
|
fetch_or_default(:sphinx_log_root, "#{shared_path}/log")
|
33
35
|
fetch_or_default(:sphinx_pid_path, "#{shared_path}/pids/searchd.pid")
|
36
|
+
fetch_or_default(:sphinx_hostname, Proc.new { utils.hostname }) # Runs if needed
|
34
37
|
|
35
38
|
fetch_or_set(:sphinx_db_user, :db_user)
|
36
39
|
fetch_or_set(:sphinx_db_pass, :db_pass)
|
@@ -50,8 +53,8 @@ namespace :sphinx do
|
|
50
53
|
desc <<-DESC
|
51
54
|
Rotate sphinx index for application.
|
52
55
|
|
53
|
-
*sphinx_prefix
|
54
|
-
*sphinx_conf
|
56
|
+
*sphinx_prefix*<dd>Location to sphinx install. _Defaults to nil_\n
|
57
|
+
*sphinx_conf*<dd>Location to sphinx conf. _Defaults to "[shared_path]/config/sphinx.conf"_\n
|
55
58
|
|
56
59
|
"Source":#{link_to_source(__FILE__)}
|
57
60
|
DESC
|
@@ -67,8 +70,8 @@ namespace :sphinx do
|
|
67
70
|
desc <<-DESC
|
68
71
|
Build sphinx indexes for application.
|
69
72
|
|
70
|
-
*sphinx_prefix
|
71
|
-
*sphinx_conf
|
73
|
+
*sphinx_prefix*<dd>Location to sphinx install. _Defaults to nil_\n
|
74
|
+
*sphinx_conf*<dd>Location to sphinx conf. _Defaults to "[shared_path]/config/sphinx.conf"_\n
|
72
75
|
|
73
76
|
"Source":#{link_to_source(__FILE__)}
|
74
77
|
DESC
|
@@ -20,18 +20,41 @@ source pages
|
|
20
20
|
sql_pass = <%= sphinx_db_pass %>
|
21
21
|
sql_db = <%= sphinx_db_name %>
|
22
22
|
sql_port = <%= sphinx_db_port %> # optional, default is 3306
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
|
24
|
+
sql_query_pre = SET NAMES UTF8
|
25
|
+
sql_query_pre = SET SESSION query_cache_type=OFF
|
26
|
+
sql_query_pre = INSERT INTO indexer_status (id, started_at, status, index_name, hostname) VALUES (10, NOW(), 'indexing', 'pages', '<%= sphinx_hostname %>') \
|
27
|
+
ON DUPLICATE KEY UPDATE started_at = NOW(), status = 'indexing'
|
28
|
+
|
29
|
+
sql_query = SELECT id, user_id, language, UNIX_TIMESTAMP(created_at) AS created_at, UNIX_TIMESTAMP(updated_at) AS updated_at, body, title FROM pages WHERE id>=$start AND id<=$end
|
30
|
+
sql_query_range = SELECT MIN(id),MAX(id) FROM pages where type='Article'
|
28
31
|
sql_range_step = 1000
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
|
33
|
+
sql_query_post = UPDATE indexer_status SET updated_at = NOW(), status = 'updated' WHERE index_name = 'pages' and hostname = '<%= sphinx_hostname %>'
|
34
|
+
|
35
|
+
sql_attr_uint = user_id
|
36
|
+
sql_attr_timestamp = created_at
|
37
|
+
sql_attr_timestamp = updated_at
|
33
38
|
}
|
34
39
|
|
40
|
+
source pages_delta : pages
|
41
|
+
{
|
42
|
+
# Clear and reset sql_query_pre
|
43
|
+
sql_query_pre =
|
44
|
+
sql_query_pre = SET NAMES UTF8
|
45
|
+
sql_query_pre = SET SESSION query_cache_type=OFF
|
46
|
+
sql_query_pre = INSERT INTO indexer_status (id, started_at, status, index_name, hostname) VALUES (11, NOW(), 'indexing', 'pages_delta', '<%= sphinx_hostname %>') \
|
47
|
+
ON DUPLICATE KEY UPDATE started_at = NOW(), status = 'indexing'
|
48
|
+
|
49
|
+
sql_query = SELECT id, user_id, language, UNIX_TIMESTAMP(created_at) AS created_at, UNIX_TIMESTAMP(updated_at) AS updated_at, body, title \
|
50
|
+
FROM pages \
|
51
|
+
WHERE updated_at >= (SELECT updated_at FROM indexer_status WHERE id = 11)
|
52
|
+
|
53
|
+
sql_query_post =
|
54
|
+
sql_query_post = UPDATE indexer_status SET updated_at = NOW(), status = 'updated' WHERE index_name = 'pages_delta' and hostname = '<%= sphinx_hostname %>'
|
55
|
+
sql_query_range =
|
56
|
+
sql_range_step =
|
57
|
+
}
|
35
58
|
|
36
59
|
index pages
|
37
60
|
{
|
@@ -46,6 +69,13 @@ index pages
|
|
46
69
|
min_infix_len = 0
|
47
70
|
}
|
48
71
|
|
72
|
+
index pages_delta : pages
|
73
|
+
{
|
74
|
+
source = pages_delta
|
75
|
+
path = <%= sphinx_index_root %>/pages_delta
|
76
|
+
|
77
|
+
}
|
78
|
+
|
49
79
|
#############################################################################
|
50
80
|
## indexer settings
|
51
81
|
#############################################################################
|
data/website/index.html
CHANGED
@@ -35,7 +35,7 @@
|
|
35
35
|
|
36
36
|
<div id="version" class="clickable box" onclick='document.location = "http://rubyforge.org/projects/capitate"; return false'>
|
37
37
|
<p>Get Version</p>
|
38
|
-
<a href="http://rubyforge.org/projects/capitate" class="numbers">0.3.
|
38
|
+
<a href="http://rubyforge.org/projects/capitate" class="numbers">0.3.2</a>
|
39
39
|
</div>
|
40
40
|
|
41
41
|
<div id="recipes">
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capitate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ""
|
6
6
|
authors:
|
7
7
|
- Gabriel Handford
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-04-
|
12
|
+
date: 2008-04-03 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|