ontopia-tldr 0.0.3-java → 0.0.4-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f25716bfe89707993d1498989312a968e04b38cd
4
+ data.tar.gz: c74e1bc02d3e370aa88394258e9ccf43c420a4a8
5
+ SHA512:
6
+ metadata.gz: 16d540e6f6a34e3fc57085507ad11ff3cf664502b35f3b1e85032427dd0b5cc91abad9099142c26826441d8f344ff51abbdf07300d89414105cf5ccf5a10eed5
7
+ data.tar.gz: 5cf994d53a391e326c034805b620af60a474c0b048c11254859650f95977b97b23138873931d5f1b69b6cf8401afaf8d6b33cc02179cdcc736992817743c4b91
data/ChangeLog CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  = Revision history for ontopia-tldr
4
4
 
5
+ == 0.0.4 [2014-04-15]
6
+
7
+ * Internal refactoring.
8
+
5
9
  == 0.0.3 [2013-10-24]
6
10
 
7
11
  * Fixed sample link display.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to ontopia-tldr version 0.0.3
5
+ This documentation refers to ontopia-tldr version 0.0.4
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -45,7 +45,7 @@ Assuming the following directory layout:
45
45
  |
46
46
  +-- tldr.xtm
47
47
  |
48
- +-- tmp/
48
+ `-- tmp/
49
49
 
50
50
  Place your database and topic map files there and adjust their paths in the
51
51
  <tt>config.ru</tt> file. The <tt>tmp/</tt> directory is used by Passenger
@@ -58,7 +58,7 @@ the paths according to your environment):
58
58
 
59
59
  /var/www
60
60
  |
61
- +-- tldr -> /usr/local/jruby/lib/ruby/gems/shared/current/ontopia-tldr/lib/ontopia/tldr/public
61
+ `-- tldr -> /usr/local/jruby/lib/ruby/gems/shared/current/ontopia-tldr/lib/ontopia/tldr/public
62
62
 
63
63
  Then put the following snippet in Apache's VirtualHost configuration:
64
64
 
@@ -82,10 +82,9 @@ Ontopia::TLDR requires JRuby[http://jruby.org]. It has been tested with jruby
82
82
 
83
83
  == LINKS
84
84
 
85
- <b></b>
86
- Documentation:: http://blackwinter.github.com/ontopia-tldr
87
- Source code:: http://github.com/blackwinter/ontopia-tldr
88
- RubyGem:: http://rubygems.org/gems/ontopia-tldr
85
+ Documentation:: https://blackwinter.github.io/ontopia-tldr/
86
+ Source code:: https://github.com/blackwinter/ontopia-tldr
87
+ RubyGem:: https://rubygems.org/gems/ontopia-tldr
89
88
  Ontopia:: http://ontopia.net/
90
89
  Demo:: http://ixtrieve.fh-koeln.de/ghn
91
90
 
@@ -97,7 +96,7 @@ Demo:: http://ixtrieve.fh-koeln.de/ghn
97
96
 
98
97
  == LICENSE AND COPYRIGHT
99
98
 
100
- Copyright (C) 2013 Jens Wille
99
+ Copyright (C) 2013-2014 Jens Wille
101
100
 
102
101
  ontopia-tldr is free software: you can redistribute it and/or modify it
103
102
  under the terms of the GNU Affero General Public License as published by
data/Rakefile CHANGED
@@ -10,10 +10,10 @@ begin
10
10
  :summary => %q{Tolog Document Retrieval with Ontopia.},
11
11
  :author => %q{Jens Wille},
12
12
  :email => %q{jens.wille@gmail.com},
13
- :license => %q{AGPL},
13
+ :license => %q{AGPL-3.0},
14
14
  :homepage => :blackwinter,
15
15
  :platform => 'java',
16
- :dependencies => %w[json ontopia-topicmaps ruby-nuggets sinatra],
16
+ :dependencies => %w[midos ontopia-topicmaps sinatra-bells],
17
17
  :extra_files => FileList['*.sample', 'lib/ontopia/tldr/{public,views}/*'].to_a
18
18
  }
19
19
  }}
data/lib/ontopia/tldr.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  # #
6
6
  # ontopia-tldr -- Tolog Document Retrieval with Ontopia. #
7
7
  # #
8
- # Copyright (C) 2013 Jens Wille #
8
+ # Copyright (C) 2013-2014 Jens Wille #
9
9
  # #
10
10
  # ontopia-tldr is free software: you can redistribute it and/or modify it #
11
11
  # under the terms of the GNU Affero General Public License as published by #
@@ -24,66 +24,46 @@
24
24
  #++
25
25
 
26
26
  require 'json'
27
- require 'sinatra/base'
28
- require 'nuggets/midos'
27
+ require 'midos'
28
+ require 'sinatra/bells'
29
29
  require 'ontopia/topicmaps'
30
30
 
31
31
  module Ontopia
32
- class TLDR < Sinatra::Base
33
32
 
34
- class << self
33
+ class TLDR < Sinatra::Bells
35
34
 
36
- private
35
+ set_root __FILE__
37
36
 
38
- def jget(*a, &b)
39
- jroute(:get, *a, &b)
40
- end
41
-
42
- def jpost(*a, &b)
43
- jroute(:post, *a, &b)
44
- end
45
-
46
- def jroute(m, r, t, &b)
47
- e = 'json'; e.prepend('.') unless r.end_with?('/')
48
- send(m, "#{r}#{e}") { instance_eval(&b); do_json }
49
- send(m, r, provides: :html) { instance_eval(&b); erb(t) }
50
- send(m, r, provides: :json) { instance_eval(&b); do_json }
51
- end
52
-
53
- end
54
-
55
- set :root, __FILE__.chomp('.rb')
37
+ set :default_render, { json: :render_json }
56
38
 
57
39
  set :otm do
58
- @__otm__ ||= Ontopia::Topicmaps::Topicmap.new(settings.xtm_file).tap {
40
+ Ontopia::Topicmaps::Topicmap.new(settings.xtm_file).tap {
59
41
  Ontopia::Topicmaps.default_stringifier = :id
60
42
  }
61
43
  end
62
44
 
63
45
  set :dbm do
64
- @__dbm__ ||= begin
65
- dbm, topic_keys = {}, settings.topic_keys
46
+ {}.tap { |dbm|
47
+ topic_keys = settings.topic_keys
66
48
 
67
49
  topic_index = Hash.new { |h, k| h[k] = {} }
68
50
  dbm.define_singleton_method(:topic_index) { topic_index }
69
51
 
70
- Nuggets::Midos::Parser.parse_file(settings.dbm_file, settings.dbm_opts) { |id, doc|
52
+ Midos::Reader.parse_file(settings.dbm_file, settings.dbm_opts) { |id, doc|
71
53
  unless (topics = doc.values_at(*topic_keys).compact).empty?
72
54
  dbm[id] = doc
73
55
  topics.flatten.each { |topic| topic_index[topic][id] = doc }
74
56
  end
75
57
  }
76
-
77
- dbm
78
- end
58
+ }
79
59
  end
80
60
 
81
61
  set :topics do
82
- @__topics__ ||= settings.otm.topics(:name)
62
+ settings.otm.topics(:name)
83
63
  end
84
64
 
85
65
  set :topic_index do
86
- @__topic_index__ ||= settings.dbm.topic_index
66
+ settings.dbm.topic_index
87
67
  end
88
68
 
89
69
  set :document_keys, %w[]
@@ -93,7 +73,7 @@ module Ontopia
93
73
 
94
74
  set :xtm_file, File.expand_path('../tldr.xtm', __FILE__)
95
75
  set :dbm_file, File.expand_path('../tldr.dbm', __FILE__)
96
- set :dbm_opts, { encoding: 'utf-8', vs: '|' }
76
+ set :dbm_opts, { encoding: 'utf-8' }
97
77
 
98
78
  set :tolog, <<-EOT
99
79
  import "http://psi.ontopia.net/tolog/string/" as s
@@ -184,8 +164,6 @@ select $TYPE, $TOPIC from
184
164
  EOT
185
165
  }
186
166
 
187
- helpers ERB::Util
188
-
189
167
  not_found do
190
168
  @error = 'Not found!'
191
169
  erb ''
@@ -195,7 +173,7 @@ select $TYPE, $TOPIC from
195
173
  erb :index
196
174
  end
197
175
 
198
- jpost '/', :index do
176
+ post '/', render: :index do
199
177
  @query = params[:q]
200
178
  @rules = params[:r] || ''
201
179
  @param = params[:p] || TITLE_TOPIC
@@ -214,15 +192,15 @@ select $TYPE, $TOPIC from
214
192
  end
215
193
 
216
194
  get '/xtm' do
217
- do_file(settings.xtm_file, 'xml')
195
+ send_file(settings.xtm_file, 'xml')
218
196
  end
219
197
 
220
- jget '/topics', :topics do
198
+ get '/topics', render: :topics do
221
199
  @title = "Topics (#{settings.topics.size})"
222
200
  @topics, @filter = settings.topics.keys, :topics
223
201
  end
224
202
 
225
- jget '/topic/:i', :topic do
203
+ get '/topic/:i', render: :topic do
226
204
  @title = topic_to_s(@topic = params[:i])
227
205
  not_found unless settings.topics.include?(@topic)
228
206
 
@@ -235,25 +213,23 @@ select $TYPE, $TOPIC from
235
213
  end
236
214
 
237
215
  get '/dbm' do
238
- do_file(settings.dbm_file, 'txt')
216
+ send_file(settings.dbm_file, 'txt')
239
217
  end
240
218
 
241
- jget '/documents', :documents do
219
+ get '/documents', render: :documents do
242
220
  @title = "Documents (#{settings.dbm.size})"
243
221
  @documents, @filter = settings.dbm, :documents
244
222
  end
245
223
 
246
- jget '/document/:i', :document do
224
+ get '/document/:i', render: :document do
247
225
  @title = "##{@id = params[:i].to_i}"
248
226
  not_found unless @document = settings.dbm[@id]
249
227
  end
250
228
 
251
229
  private
252
230
 
253
- def do_json
254
- content_type :json
255
-
256
- JSON.fast_generate({
231
+ def to_render_hash
232
+ super(
257
233
  d: @document || @documents,
258
234
  e: @error,
259
235
  i: @id,
@@ -264,11 +240,7 @@ select $TYPE, $TOPIC from
264
240
  r: @rules,
265
241
  t: @topic || @topics,
266
242
  y: @types
267
- }.delete_if { |_, v| !v })
268
- end
269
-
270
- def do_file(file, type)
271
- File.readable?(file) ? send_file(file, type: type) : not_found
243
+ )
272
244
  end
273
245
 
274
246
  def get_topics(query = @query, param = @param, rules = @rules)
@@ -344,11 +316,11 @@ select $TYPE, $TOPIC from
344
316
  end
345
317
 
346
318
  def link_to_topic(topic, text = topic_to_s(topic))
347
- _a(text, href: url("/topic/#{h(topic)}"))
319
+ link_to(text, :topic, topic)
348
320
  end
349
321
 
350
322
  def link_to_document(id, doc)
351
- _a(doc_to_s(id, doc), href: url("/document/#{h(id)}"))
323
+ link_to(doc_to_s(id, doc), :document, id)
352
324
  end
353
325
 
354
326
  def sample_link(name)
@@ -357,31 +329,8 @@ select $TYPE, $TOPIC from
357
329
  end
358
330
  end
359
331
 
360
- def _a(*args)
361
- _tag(:a, *args)
362
- end
363
-
364
- def _ul(list, *args)
365
- _tag(:ul, *args) { |t| list.each { |*i| t << yield(*i) } }
366
- end
367
-
368
- def _li(*args)
369
- _tag(:li, *args)
370
- end
371
-
372
- def _tag(name, *args)
373
- a = args.pop.map { |k, v| %Q{#{h(k)}="#{h(v)}"} } if args.last.is_a?(Hash)
374
-
375
- t = ["<#{name}#{a.unshift(nil).join(' ') if a}>"]
376
-
377
- args.each { |s| t << s }
378
- yield t if block_given?
379
-
380
- t << "</#{name}>"
381
- t.join
382
- end
383
-
384
332
  end
333
+
385
334
  end
386
335
 
387
336
  require_relative 'tldr/version'
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # ontopia-tldr -- Tolog Document Retrieval with Ontopia. #
5
5
  # #
6
- # Copyright (C) 2013 Jens Wille #
6
+ # Copyright (C) 2013-2014 Jens Wille #
7
7
  # #
8
8
  # ontopia-tldr is free software: you can redistribute it and/or modify it #
9
9
  # under the terms of the GNU Affero General Public License as published by #
@@ -28,7 +28,7 @@ module Ontopia
28
28
 
29
29
  MAJOR = 0
30
30
  MINOR = 0
31
- TINY = 3
31
+ TINY = 4
32
32
 
33
33
  class << self
34
34
 
metadata CHANGED
@@ -1,80 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ontopia-tldr
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.3
4
+ version: 0.0.4
6
5
  platform: java
7
6
  authors:
8
7
  - Jens Wille
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-24 00:00:00.000000000 Z
11
+ date: 2014-04-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: json
14
+ name: midos
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
16
22
  version_requirements: !ruby/object:Gem::Requirement
17
23
  requirements:
18
- - - '>='
24
+ - - ">="
19
25
  - !ruby/object:Gem::Version
20
26
  version: '0'
21
- none: false
27
+ - !ruby/object:Gem::Dependency
28
+ name: ontopia-topicmaps
22
29
  requirement: !ruby/object:Gem::Requirement
23
30
  requirements:
24
- - - '>='
31
+ - - ">="
25
32
  - !ruby/object:Gem::Version
26
33
  version: '0'
27
- none: false
28
- prerelease: false
29
34
  type: :runtime
30
- - !ruby/object:Gem::Dependency
31
- name: ontopia-topicmaps
35
+ prerelease: false
32
36
  version_requirements: !ruby/object:Gem::Requirement
33
37
  requirements:
34
- - - '>='
38
+ - - ">="
35
39
  - !ruby/object:Gem::Version
36
40
  version: '0'
37
- none: false
41
+ - !ruby/object:Gem::Dependency
42
+ name: sinatra-bells
38
43
  requirement: !ruby/object:Gem::Requirement
39
44
  requirements:
40
- - - '>='
45
+ - - ">="
41
46
  - !ruby/object:Gem::Version
42
47
  version: '0'
43
- none: false
44
- prerelease: false
45
48
  type: :runtime
46
- - !ruby/object:Gem::Dependency
47
- name: ruby-nuggets
49
+ prerelease: false
48
50
  version_requirements: !ruby/object:Gem::Requirement
49
51
  requirements:
50
- - - '>='
52
+ - - ">="
51
53
  - !ruby/object:Gem::Version
52
54
  version: '0'
53
- none: false
55
+ - !ruby/object:Gem::Dependency
56
+ name: hen
54
57
  requirement: !ruby/object:Gem::Requirement
55
58
  requirements:
56
- - - '>='
59
+ - - ">="
57
60
  - !ruby/object:Gem::Version
58
61
  version: '0'
59
- none: false
62
+ type: :development
60
63
  prerelease: false
61
- type: :runtime
62
- - !ruby/object:Gem::Dependency
63
- name: sinatra
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- none: false
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
70
71
  requirement: !ruby/object:Gem::Requirement
71
72
  requirements:
72
- - - '>='
73
+ - - ">="
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
- none: false
76
+ type: :development
76
77
  prerelease: false
77
- type: :runtime
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
78
83
  description: Tolog Document Retrieval with Ontopia.
79
84
  email: jens.wille@gmail.com
80
85
  executables: []
@@ -84,58 +89,57 @@ extra_rdoc_files:
84
89
  - COPYING
85
90
  - ChangeLog
86
91
  files:
92
+ - COPYING
93
+ - ChangeLog
94
+ - README
95
+ - Rakefile
96
+ - config.ru.sample
87
97
  - lib/ontopia-tldr.rb
88
98
  - lib/ontopia/tldr.rb
89
- - lib/ontopia/tldr/version.rb
90
- - config.ru.sample
91
99
  - lib/ontopia/tldr/public/site.css
92
100
  - lib/ontopia/tldr/public/site.js
101
+ - lib/ontopia/tldr/version.rb
93
102
  - lib/ontopia/tldr/views/document.erb
94
103
  - lib/ontopia/tldr/views/documents.erb
95
104
  - lib/ontopia/tldr/views/index.erb
96
105
  - lib/ontopia/tldr/views/layout.erb
97
106
  - lib/ontopia/tldr/views/topic.erb
98
107
  - lib/ontopia/tldr/views/topics.erb
99
- - COPYING
100
- - ChangeLog
101
- - README
102
- - Rakefile
103
108
  homepage: http://github.com/blackwinter/ontopia-tldr
104
109
  licenses:
105
- - AGPL
110
+ - AGPL-3.0
111
+ metadata: {}
106
112
  post_install_message: |2+
107
113
 
108
- ontopia-tldr-0.0.3 [2013-10-24]:
114
+ ontopia-tldr-0.0.4 [2014-04-15]:
109
115
 
110
- * Fixed sample link display.
116
+ * Internal refactoring.
111
117
 
112
118
  rdoc_options:
113
- - --charset
119
+ - "--title"
120
+ - ontopia-tldr Application documentation (v0.0.4)
121
+ - "--charset"
114
122
  - UTF-8
115
- - --line-numbers
116
- - --all
117
- - --title
118
- - ontopia-tldr Application documentation (v0.0.3)
119
- - --main
123
+ - "--line-numbers"
124
+ - "--all"
125
+ - "--main"
120
126
  - README
121
127
  require_paths:
122
128
  - lib
123
129
  required_ruby_version: !ruby/object:Gem::Requirement
124
130
  requirements:
125
- - - '>='
131
+ - - ">="
126
132
  - !ruby/object:Gem::Version
127
133
  version: '0'
128
- none: false
129
134
  required_rubygems_version: !ruby/object:Gem::Requirement
130
135
  requirements:
131
- - - '>='
136
+ - - ">="
132
137
  - !ruby/object:Gem::Version
133
138
  version: '0'
134
- none: false
135
139
  requirements: []
136
- rubyforge_project:
137
- rubygems_version: 1.8.24
138
- signing_key:
139
- specification_version: 3
140
+ rubyforge_project:
141
+ rubygems_version: 2.2.2
142
+ signing_key:
143
+ specification_version: 4
140
144
  summary: Tolog Document Retrieval with Ontopia.
141
145
  test_files: []