birds 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,64 @@
1
+ <div class="row">
2
+ <div class="col-md-9">
3
+ <form action="<%= url('/search') %>" method="GET" class="form-inline" role="form">
4
+ <div class="form-group">
5
+ <label class="control-label sr-only" for="q">Query</label>
6
+ <input type="search" class="form-control input-lg" name="q" id="q" size="40" value="<%=h @query %>" required="required" placeholder="Enter Query…" list="sample_queries" />
7
+ <datalist id="sample_queries">
8
+ <% for label, value in settings.sample_queries %>
9
+ <option label="<%=h label %>" value="<%=h value %>" />
10
+ <% end %>
11
+ </datalist>
12
+ </div>
13
+ <button type="submit" class="btn btn-default btn-lg" title="Search">
14
+ <%= glyphicon(:search) %> Search
15
+ </button>
16
+ </form>
17
+
18
+ <% if @filter %>
19
+ <ul class="list-inline" style="margin-top: 0.5em"><!-- XXX -->
20
+ <% for filter in @filter %>
21
+ <li style="line-height: 1.7em"><!-- XXX -->
22
+ <%= link_to_search('&times;', @query, *@filter - [filter], class: 'close', title: 'Remove filter') %>
23
+ <code><%=h filter %></code>
24
+ </li>
25
+ <% end %>
26
+ </ul>
27
+ <% end %>
28
+
29
+ <% if @result %>
30
+ <%= erb :_documents, locals: { documents: @result, explain: @explain, start: @offset + 1 } %>
31
+ <%= pagination_for(:search, query_params) %>
32
+ </div>
33
+ <div class="col-md-3">
34
+ <%= erb :_facets %>
35
+ <% else %>
36
+ <h2>Query syntax</h2>
37
+
38
+ <dl class="dl-horizontal">
39
+ <dt><code>term</code></dt>
40
+ <dd>Query term <em>should</em> occur.</dd>
41
+ <dt><code>+term</code></dt>
42
+ <dd>Query term <em>must</em> occur.</dd>
43
+ <dt><code>-term</code></dt>
44
+ <dd>Query term <em>must not</em> occur.</dd>
45
+ <dt><code>term*</code></dt>
46
+ <dd>Wildcard search for <em>zero or more</em> characters.</dd>
47
+ <dt><code>term?</code></dt>
48
+ <dd>Wildcard search for <em>one</em> character.</dd>
49
+ <dt><code>"..."</code></dt>
50
+ <dd>Phrase search.</dd>
51
+ <dt><code>term~<kbd>n</kbd></code></dt>
52
+ <dd>Fuzzy search.
53
+ <span class="text-muted">(The number <kbd>n</kbd> is optional)</span></dd>
54
+ <dt><code>term^<kbd>n</kbd></code></dt>
55
+ <dd>Boosting.
56
+ <span class="text-muted">(The number <kbd>n</kbd> is required)</span></dd>
57
+ <dt><code>field:term</code></dt>
58
+ <dd>Field-specific search.</dd>
59
+ </dl>
60
+
61
+ <p>For further details, see <a href="http://lucene.apache.org/core/<%=h settings.solr.solr_version.tr('.', '_') %>/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Overview">here</a> or <a href="http://yonik.com/solr/query-syntax/">here</a>.</p>
62
+ <% end %>
63
+ </div>
64
+ </div>
@@ -0,0 +1,83 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+
8
+ <title><%=h @page_title %><% if @page_title_extra %> (<%=h @page_title_extra %>)<% end %> · <%=h settings.site_title %></title>
9
+
10
+ <link rel="shortcut icon" href="<%= url('/favicon.ico') %>" />
11
+
12
+ <link rel="stylesheet" href="<%=h settings.bootstrap_url %>/css/bootstrap.min.css" />
13
+ <link rel="stylesheet" href="<%=h settings.bootstrap_url %>/css/bootstrap-theme.min.css" />
14
+ <link rel="stylesheet" href="<%= url('/css/birds.css') %>" />
15
+ </head>
16
+ <body>
17
+ <a class="sr-only" href="#content">Skip to main content</a>
18
+
19
+ <div id="wrap">
20
+ <header class="navbar navbar-default" id="top" role="banner">
21
+ <div class="container">
22
+ <div class="navbar-header">
23
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
24
+ <span class="sr-only">Toggle navigation</span>
25
+ <span class="icon-bar"></span>
26
+ <span class="icon-bar"></span>
27
+ <span class="icon-bar"></span>
28
+ </button>
29
+ <a class="navbar-brand" href="<%= url('/') %>" title="<%=h settings.site_title %>">
30
+ <% bird = { 'Search' => 2, 'Browse' => 1, 'Scroll' => 3 }[@page_title] || :s %>
31
+ <img src="<%= url("/images/bird#{bird}.png") %>" alt="Bird<%= bird %>" />
32
+ </a>
33
+ </div>
34
+
35
+ <nav class="collapse navbar-collapse" role="navigation">
36
+ <ul class="nav navbar-nav">
37
+ <%= nav_item('/search', 'Search', 'Search for documents') %>
38
+ <%= nav_item('/browse', 'Browse', 'Browse by category') unless settings.browse_fields.empty? %>
39
+ <%= nav_item('/scroll', 'Scroll', 'Scroll through indexes') unless settings.scroll_fields.empty? %>
40
+ </ul>
41
+ <ul class="nav navbar-nav navbar-right">
42
+ <li><a href="<%= url('/help') %>" title="View help pages">Help</a></li>
43
+ </ul>
44
+ <form action="<%= url('/search') %>" method="GET" class="navbar-form navbar-right" role="search">
45
+ <div class="form-group">
46
+ <input type="search" class="form-control" title="Quick search" name="qq" id="qq" required="required" placeholder="Search" />
47
+ </div>
48
+ <button type="submit" class="btn btn-default" title="Search"><%= glyphicon(:search) %></button>
49
+ </form>
50
+ </nav>
51
+ </div>
52
+ </header>
53
+
54
+ <main id="content" role="main">
55
+ <div class="container">
56
+ <% if @code && @error %>
57
+ <p><big>Oops... <%=h @code %> – <%=h @error %></big></p>
58
+ <% else %>
59
+ <h1><%=h @page_title %><% if @page_title_extra %> <small>(<%=h @page_title_extra %>)</small><% end %></h1>
60
+ <%= yield %>
61
+ <% end %>
62
+ </div>
63
+ </main>
64
+
65
+ <div id="push"></div>
66
+ </div>
67
+
68
+ <footer role="contentinfo">
69
+ <div class="container">
70
+ <p>
71
+ <em>powered by</em> <a href="//lucene.apache.org/solr/">Solr</a>
72
+ <em>and</em> <a href="http://sinatrarb.com">Sinatra</a>
73
+ — <a href="//blackwinter.github.com/birds">Birds</a>
74
+ <strong>v<%= Birds::VERSION %></strong>
75
+ </p>
76
+ </div>
77
+ </footer>
78
+
79
+ <script src="//code.jquery.com/jquery-2.1.0.min.js"></script>
80
+ <script src="<%=h settings.bootstrap_url %>/js/bootstrap.min.js"></script>
81
+ <script src="<%= url('/js/birds.js') %>"></script>
82
+ </body>
83
+ </html>
@@ -0,0 +1,23 @@
1
+ <% if @result %>
2
+ <ol start="<%= @start + 1 %>">
3
+ <% for document in @result %>
4
+ <li><%= link_to_document(document) %></li>
5
+ <% end %>
6
+ </ol>
7
+ <%= pagination_for(:scroll, @field, @letter) %>
8
+ <% elsif @fields %>
9
+ <ul>
10
+ <% for field, label in @fields %>
11
+ <li><%= link_to(h(label), :scroll, field) %></li>
12
+ <% end %>
13
+ </ul>
14
+ <% else %>
15
+ <ul>
16
+ <% for letter, count in @letters %>
17
+ <li>
18
+ <%= link_to(h(letter), :scroll, @field, letter) %>
19
+ <span class="badge"><%=h count %></span>
20
+ </li>
21
+ <% end %>
22
+ </ul>
23
+ <% end %>
data/lib/birds/app.rb ADDED
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ ###############################################################################
5
+ # #
6
+ # Birds -- Bibliographic information retrieval & document search #
7
+ # #
8
+ # Copyright (C) 2014-2015 Jens Wille #
9
+ # #
10
+ # Birds is free software: you can redistribute it and/or modify it under the #
11
+ # terms of the GNU Affero General Public License as published by the Free #
12
+ # Software Foundation, either version 3 of the License, or (at your option) #
13
+ # any later version. #
14
+ # #
15
+ # Birds is distributed in the hope that it will be useful, but WITHOUT ANY #
16
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
17
+ # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for #
18
+ # more details. #
19
+ # #
20
+ # You should have received a copy of the GNU Affero General Public License #
21
+ # along with Birds. If not, see <http://www.gnu.org/licenses/>. #
22
+ # #
23
+ ###############################################################################
24
+ #++
25
+
26
+ require 'sinatra/bells'
27
+
28
+ class Birds
29
+
30
+ class App < Sinatra::Bells
31
+
32
+ set_root __FILE__
33
+
34
+ set :default_render, { json: :render_json }
35
+
36
+ private
37
+
38
+ def to_render_hash
39
+ super(
40
+ d: @document || @result.to_a,
41
+ e: @error,
42
+ q: @query
43
+ )
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ require_relative 'app/helpers'
51
+ require_relative 'app/settings'
52
+ require_relative 'app/controllers'
@@ -0,0 +1,2 @@
1
+ require_relative 'app'
2
+ Rack_app = Birds::App
@@ -0,0 +1,27 @@
1
+ class Birds
2
+
3
+ module Version
4
+
5
+ MAJOR = 0
6
+ MINOR = 0
7
+ TINY = 0
8
+
9
+ class << self
10
+
11
+ # Returns array representation.
12
+ def to_a
13
+ [MAJOR, MINOR, TINY]
14
+ end
15
+
16
+ # Short-cut for version string.
17
+ def to_s
18
+ to_a.join('.')
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ VERSION = Version.to_s
26
+
27
+ end
data/lib/birds.rb ADDED
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+
3
+ #--
4
+ ###############################################################################
5
+ # #
6
+ # Birds -- Bibliographic information retrieval & document search #
7
+ # #
8
+ # Copyright (C) 2014-2015 Jens Wille #
9
+ # #
10
+ # Birds is free software: you can redistribute it and/or modify it under the #
11
+ # terms of the GNU Affero General Public License as published by the Free #
12
+ # Software Foundation, either version 3 of the License, or (at your option) #
13
+ # any later version. #
14
+ # #
15
+ # Birds is distributed in the hope that it will be useful, but WITHOUT ANY #
16
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
17
+ # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for #
18
+ # more details. #
19
+ # #
20
+ # You should have received a copy of the GNU Affero General Public License #
21
+ # along with Birds. If not, see <http://www.gnu.org/licenses/>. #
22
+ # #
23
+ ###############################################################################
24
+ #++
25
+
26
+ require 'rack'
27
+ require 'forwardable'
28
+
29
+ class Birds
30
+
31
+ extend Forwardable
32
+
33
+ DEFAULT_CONFIG = 'config.ru'
34
+
35
+ class << self
36
+
37
+ def app(path)
38
+ app_class(path).new!
39
+ end
40
+
41
+ def rack_app
42
+ new(__FILE__.sub(/\.rb\z/, '/rack_app'))
43
+ end
44
+
45
+ private
46
+
47
+ def app_class(path)
48
+ (@app_class ||= {})[path] ||= Rack::Builder.parse_file(path).first
49
+ end
50
+
51
+ end
52
+
53
+ def initialize(path = DEFAULT_CONFIG)
54
+ self.app = self.class.app(File.expand_path(path))
55
+ end
56
+
57
+ attr_accessor :app
58
+
59
+ def_delegators 'app.settings', :solr, :solr_opts
60
+
61
+ def count
62
+ solr.count.to_i
63
+ end
64
+
65
+ end
66
+
67
+ require_relative 'birds/version'
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: birds
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jens Wille
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra-bells
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.0.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: solr4r
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.0'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.0.4
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.0'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.0.4
53
+ - !ruby/object:Gem::Dependency
54
+ name: unicode
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.4'
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.4'
67
+ - !ruby/object:Gem::Dependency
68
+ name: hen
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.8'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.8.3.pre1
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0.8'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 0.8.3.pre1
87
+ - !ruby/object:Gem::Dependency
88
+ name: rake
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ description: Experimental information retrieval system for bibliographic data.
102
+ email: jens.wille@gmail.com
103
+ executables: []
104
+ extensions: []
105
+ extra_rdoc_files:
106
+ - README
107
+ - COPYING
108
+ - ChangeLog
109
+ files:
110
+ - COPYING
111
+ - ChangeLog
112
+ - README
113
+ - Rakefile
114
+ - config.ru.sample
115
+ - lib/birds.rb
116
+ - lib/birds/app.rb
117
+ - lib/birds/app/controllers.rb
118
+ - lib/birds/app/helpers.rb
119
+ - lib/birds/app/helpers/controller.rb
120
+ - lib/birds/app/helpers/view.rb
121
+ - lib/birds/app/public/favicon.ico
122
+ - lib/birds/app/settings.rb
123
+ - lib/birds/app/views/_documents.erb
124
+ - lib/birds/app/views/_facets.erb
125
+ - lib/birds/app/views/browse.erb
126
+ - lib/birds/app/views/document.erb
127
+ - lib/birds/app/views/index.erb
128
+ - lib/birds/app/views/layout.erb
129
+ - lib/birds/app/views/scroll.erb
130
+ - lib/birds/rack_app.rb
131
+ - lib/birds/version.rb
132
+ homepage: http://github.com/blackwinter/birds
133
+ licenses:
134
+ - AGPL-3.0
135
+ metadata: {}
136
+ post_install_message: |2+
137
+
138
+ birds-0.0.0 [2014-03-19]:
139
+
140
+ * Birthday :-)
141
+
142
+ rdoc_options:
143
+ - "--title"
144
+ - birds Application documentation (v0.0.0)
145
+ - "--charset"
146
+ - UTF-8
147
+ - "--line-numbers"
148
+ - "--all"
149
+ - "--main"
150
+ - README
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: 1.9.3
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.4.8
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: Bibliographic information retrieval & document search.
169
+ test_files: []