supplejack_api 1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +80 -0
- data/Rakefile +42 -0
- data/app/assets/javascripts/supplejack_api/application.js +26 -0
- data/app/assets/stylesheets/supplejack_api/application.css +30 -0
- data/app/controllers/supplejack_api/admin/base_controller.rb +24 -0
- data/app/controllers/supplejack_api/admin/sessions_controller.rb +25 -0
- data/app/controllers/supplejack_api/admin/site_activities_controller.rb +21 -0
- data/app/controllers/supplejack_api/admin/users_controller.rb +55 -0
- data/app/controllers/supplejack_api/application_controller.rb +70 -0
- data/app/controllers/supplejack_api/concepts_controller.rb +52 -0
- data/app/controllers/supplejack_api/concerns/ignore_metrics.rb +14 -0
- data/app/controllers/supplejack_api/concerns/records_controller_metrics.rb +26 -0
- data/app/controllers/supplejack_api/concerns/set_items_controller_metrics.rb +20 -0
- data/app/controllers/supplejack_api/concerns/user_sets_controller_metrics.rb +26 -0
- data/app/controllers/supplejack_api/harvester/concepts_controller.rb +41 -0
- data/app/controllers/supplejack_api/harvester/fragments_controller.rb +30 -0
- data/app/controllers/supplejack_api/harvester/records_controller.rb +68 -0
- data/app/controllers/supplejack_api/metrics_api_controller.rb +44 -0
- data/app/controllers/supplejack_api/partners_controller.rb +39 -0
- data/app/controllers/supplejack_api/records_controller.rb +71 -0
- data/app/controllers/supplejack_api/schema_controller.rb +19 -0
- data/app/controllers/supplejack_api/set_items_controller.rb +38 -0
- data/app/controllers/supplejack_api/sources_controller.rb +67 -0
- data/app/controllers/supplejack_api/status_controller.rb +67 -0
- data/app/controllers/supplejack_api/user_sets_controller.rb +97 -0
- data/app/controllers/supplejack_api/users_controller.rb +49 -0
- data/app/helpers/supplejack_api/application_helper.rb +39 -0
- data/app/helpers/supplejack_api/facets_helper.rb +30 -0
- data/app/mailers/supplejack_api/request_limit_mailer.rb +43 -0
- data/app/models/supplejack_api/api_concept/concept_fragment.rb +31 -0
- data/app/models/supplejack_api/api_record/record_fragment.rb +15 -0
- data/app/models/supplejack_api/concept.rb +46 -0
- data/app/models/supplejack_api/concept_search.rb +86 -0
- data/app/models/supplejack_api/concerns/queryable_by_date.rb +31 -0
- data/app/models/supplejack_api/concerns/record.rb +108 -0
- data/app/models/supplejack_api/concerns/record_fragmentable.rb +24 -0
- data/app/models/supplejack_api/concerns/searchable.rb +430 -0
- data/app/models/supplejack_api/concerns/user_set.rb +219 -0
- data/app/models/supplejack_api/daily_metrics.rb +20 -0
- data/app/models/supplejack_api/faceted_metrics.rb +55 -0
- data/app/models/supplejack_api/fragment.rb +82 -0
- data/app/models/supplejack_api/interaction_models/record.rb +60 -0
- data/app/models/supplejack_api/interaction_models/set.rb +13 -0
- data/app/models/supplejack_api/interaction_updaters/all_usage_metric.rb +41 -0
- data/app/models/supplejack_api/interaction_updaters/set_metrics.rb +32 -0
- data/app/models/supplejack_api/interaction_updaters/usage_metrics.rb +73 -0
- data/app/models/supplejack_api/partner.rb +24 -0
- data/app/models/supplejack_api/preview_record.rb +30 -0
- data/app/models/supplejack_api/record.rb +18 -0
- data/app/models/supplejack_api/record_search.rb +12 -0
- data/app/models/supplejack_api/schema_definition.rb +147 -0
- data/app/models/supplejack_api/search.rb +14 -0
- data/app/models/supplejack_api/set_item.rb +57 -0
- data/app/models/supplejack_api/site_activity.rb +59 -0
- data/app/models/supplejack_api/source.rb +28 -0
- data/app/models/supplejack_api/source_activity.rb +36 -0
- data/app/models/supplejack_api/source_authority.rb +42 -0
- data/app/models/supplejack_api/supplejack_schema.rb +37 -0
- data/app/models/supplejack_api/support/concept/searchable.rb +79 -0
- data/app/models/supplejack_api/support/concept/storable.rb +59 -0
- data/app/models/supplejack_api/support/fragment_helpers.rb +96 -0
- data/app/models/supplejack_api/support/harvestable.rb +105 -0
- data/app/models/supplejack_api/support/searchable.rb +115 -0
- data/app/models/supplejack_api/support/status_logger.rb +23 -0
- data/app/models/supplejack_api/support/storable.rb +49 -0
- data/app/models/supplejack_api/support/validation_logger.rb +23 -0
- data/app/models/supplejack_api/usage_metrics.rb +25 -0
- data/app/models/supplejack_api/user.rb +211 -0
- data/app/models/supplejack_api/user_activity.rb +65 -0
- data/app/models/supplejack_api/user_set.rb +17 -0
- data/app/serializers/supplejack_api/application_serializer.rb +12 -0
- data/app/serializers/supplejack_api/concept_record_serializer.rb +23 -0
- data/app/serializers/supplejack_api/concept_search_serializer.rb +12 -0
- data/app/serializers/supplejack_api/concept_serializer.rb +100 -0
- data/app/serializers/supplejack_api/concerns/record_serializable.rb +119 -0
- data/app/serializers/supplejack_api/concerns/search_serializable.rb +24 -0
- data/app/serializers/supplejack_api/record_search_serializer.rb +64 -0
- data/app/serializers/supplejack_api/record_serializer.rb +13 -0
- data/app/serializers/supplejack_api/search_serializer.rb +13 -0
- data/app/serializers/supplejack_api/source_authority_serializer.rb +23 -0
- data/app/serializers/supplejack_api/user_serializer.rb +13 -0
- data/app/serializers/supplejack_api/user_set_record_serializer.rb +14 -0
- data/app/serializers/supplejack_api/user_set_serializer.rb +77 -0
- data/app/services/metrics_api/v3/api.rb +30 -0
- data/app/services/metrics_api/v3/endpoints/facets.rb +23 -0
- data/app/services/metrics_api/v3/endpoints/global.rb +26 -0
- data/app/services/metrics_api/v3/endpoints/helpers.rb +14 -0
- data/app/services/metrics_api/v3/endpoints/root.rb +97 -0
- data/app/services/metrics_api/v3/presenters/daily_metric.rb +23 -0
- data/app/services/metrics_api/v3/presenters/extended_metadata.rb +41 -0
- data/app/services/metrics_api/v3/presenters/record.rb +26 -0
- data/app/services/metrics_api/v3/presenters/view.rb +28 -0
- data/app/views/layouts/supplejack_api/_head.html.erb +17 -0
- data/app/views/layouts/supplejack_api/_top_nav.html.erb +33 -0
- data/app/views/layouts/supplejack_api/application.html.erb +33 -0
- data/app/views/supplejack_api/admin/sessions/new.html.erb +25 -0
- data/app/views/supplejack_api/admin/shared/_links.erb +34 -0
- data/app/views/supplejack_api/admin/site_activities/index.csv.erb +22 -0
- data/app/views/supplejack_api/admin/site_activities/index.html.erb +54 -0
- data/app/views/supplejack_api/admin/users/edit.html.erb +16 -0
- data/app/views/supplejack_api/admin/users/index.csv.erb +22 -0
- data/app/views/supplejack_api/admin/users/index.html.erb +57 -0
- data/app/views/supplejack_api/admin/users/show.html.erb +33 -0
- data/app/views/supplejack_api/request_limit_mailer/at100percent.text.erb +13 -0
- data/app/views/supplejack_api/request_limit_mailer/at100percent_admin.text.erb +1 -0
- data/app/views/supplejack_api/request_limit_mailer/at90percent.text.erb +13 -0
- data/app/views/supplejack_api/request_limit_mailer/at90percent_admin.text.erb +1 -0
- data/app/workers/supplejack_api/daily_metrics_worker.rb +112 -0
- data/app/workers/supplejack_api/interaction_metrics_worker.rb +45 -0
- data/config/cucumber.yml +16 -0
- data/config/initializers/force_eagerload.rb +11 -0
- data/config/initializers/interaction_updaters.rb +7 -0
- data/config/routes.rb +81 -0
- data/db/binding_records.development.json +7 -0
- data/db/binding_records.staging.json +7 -0
- data/db/concepts.json +33 -0
- data/db/concepts_data.json +569745 -0
- data/db/source_authorities.json +119 -0
- data/lib/generators/supplejack_api/install_generator.rb +124 -0
- data/lib/mongoid/paperclip.rb +53 -0
- data/lib/mongoid/string.rb +20 -0
- data/lib/sunspot/mongoid.rb +51 -0
- data/lib/sunspot/resque_session_proxy.rb +72 -0
- data/lib/sunspot/sunspot_spellcheck.rb +98 -0
- data/lib/supplejack_api.rb +13 -0
- data/lib/supplejack_api/admin/sortable.rb +40 -0
- data/lib/supplejack_api/engine.rb +46 -0
- data/lib/supplejack_api/harvester_constraint.rb +28 -0
- data/lib/supplejack_api/stylesheets.rb +36 -0
- data/lib/supplejack_api/utils.rb +75 -0
- data/lib/supplejack_api/version.rb +11 -0
- data/lib/tasks/resque.rake +22 -0
- data/lib/url_validator.rb +38 -0
- data/spec/controllers/supplejack_api/admin/base_controller_spec.rb +55 -0
- data/spec/controllers/supplejack_api/admin/site_activities_controller_spec.rb +43 -0
- data/spec/controllers/supplejack_api/admin/users_controller_spec.rb +79 -0
- data/spec/controllers/supplejack_api/application_controller_spec.rb +133 -0
- data/spec/controllers/supplejack_api/concepts_controller_spec.rb +83 -0
- data/spec/controllers/supplejack_api/concerns/records_controller_metrics_spec.rb +60 -0
- data/spec/controllers/supplejack_api/harvester/concepts_controller_spec.rb +57 -0
- data/spec/controllers/supplejack_api/harvester/records_controller_spec.rb +138 -0
- data/spec/controllers/supplejack_api/metrics_api_controller_spec.rb +71 -0
- data/spec/controllers/supplejack_api/partners_controller_spec.rb +77 -0
- data/spec/controllers/supplejack_api/records_controller_spec.rb +143 -0
- data/spec/controllers/supplejack_api/set_items_controller_spec.rb +78 -0
- data/spec/controllers/supplejack_api/sources_controller_spec.rb +161 -0
- data/spec/controllers/supplejack_api/status_controller_spec.rb +120 -0
- data/spec/controllers/supplejack_api/user_sets_controller_spec.rb +233 -0
- data/spec/controllers/supplejack_api/users_controller_spec.rb +61 -0
- data/spec/dummy/README.rdoc +268 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +23 -0
- data/spec/dummy/app/assets/stylesheets/application.css +22 -0
- data/spec/dummy/app/controllers/application_controller.rb +10 -0
- data/spec/dummy/app/helpers/application_helper.rb +9 -0
- data/spec/dummy/app/supplejack_api/concept_schema.rb +83 -0
- data/spec/dummy/app/supplejack_api/record_schema.rb +64 -0
- data/spec/dummy/app/supplejack_api/record_schema.txt +66 -0
- data/spec/dummy/app/views/layouts/application.html.erb +23 -0
- data/spec/dummy/app/workers/supplejack_api/clear_index_buffer.rb +32 -0
- data/spec/dummy/app/workers/supplejack_api/flush_old_records_worker.rb +17 -0
- data/spec/dummy/app/workers/supplejack_api/index_buffer.rb +49 -0
- data/spec/dummy/app/workers/supplejack_api/index_source_worker.rb +39 -0
- data/spec/dummy/app/workers/supplejack_api/index_worker.rb +82 -0
- data/spec/dummy/app/workers/supplejack_api/store_user_activity_worker.rb +24 -0
- data/spec/dummy/config.ru +11 -0
- data/spec/dummy/config/application.rb +76 -0
- data/spec/dummy/config/application.yml +31 -0
- data/spec/dummy/config/application.yml.example +36 -0
- data/spec/dummy/config/boot.rb +17 -0
- data/spec/dummy/config/environment.rb +12 -0
- data/spec/dummy/config/environments/development.rb +42 -0
- data/spec/dummy/config/environments/production.rb +76 -0
- data/spec/dummy/config/environments/test.rb +46 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +14 -0
- data/spec/dummy/config/initializers/devise.rb +214 -0
- data/spec/dummy/config/initializers/inflections.rb +22 -0
- data/spec/dummy/config/initializers/kaminari_config.rb +17 -0
- data/spec/dummy/config/initializers/mime_types.rb +12 -0
- data/spec/dummy/config/initializers/mongoid.rb +9 -0
- data/spec/dummy/config/initializers/quiet_logger.rb +23 -0
- data/spec/dummy/config/initializers/resque.rb +18 -0
- data/spec/dummy/config/initializers/secret_token.rb +14 -0
- data/spec/dummy/config/initializers/session_store.rb +15 -0
- data/spec/dummy/config/initializers/simple_form.rb +149 -0
- data/spec/dummy/config/initializers/simple_form_foundation.rb +33 -0
- data/spec/dummy/config/initializers/state_machine.rb +8 -0
- data/spec/dummy/config/initializers/sunspot.rb +32 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +17 -0
- data/spec/dummy/config/locales/devise.en.yml +63 -0
- data/spec/dummy/config/locales/en.yml +66 -0
- data/spec/dummy/config/locales/simple_form.en.yml +33 -0
- data/spec/dummy/config/mongoid.travis.yml +34 -0
- data/spec/dummy/config/mongoid.yml +36 -0
- data/spec/dummy/config/resque-pool.yml +18 -0
- data/spec/dummy/config/resque_schedule.yml +12 -0
- data/spec/dummy/config/routes.rb +11 -0
- data/spec/dummy/config/secrets.yml +8 -0
- data/spec/dummy/config/sunspot.yml +38 -0
- data/spec/dummy/db/concepts.json +37 -0
- data/spec/dummy/db/source_authorities.json +116 -0
- data/spec/dummy/public/404.html +35 -0
- data/spec/dummy/public/422.html +35 -0
- data/spec/dummy/public/500.html +34 -0
- data/spec/dummy/public/favicon.ico +8 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/solr/collection1/conf/elevate.xml +36 -0
- data/spec/dummy/solr/collection1/conf/mapping-FoldToASCII.txt +3813 -0
- data/spec/dummy/solr/collection1/conf/schema.xml +292 -0
- data/spec/dummy/solr/collection1/conf/solrconfig.xml +1780 -0
- data/spec/dummy/solr/collection1/conf/spellings.txt +2 -0
- data/spec/dummy/solr/collection1/conf/stopwords.txt +58 -0
- data/spec/dummy/solr/collection1/conf/synonyms.txt +31 -0
- data/spec/factories/concepts.rb +16 -0
- data/spec/factories/daily_metrics.rb +10 -0
- data/spec/factories/faceted_metrics.rb +25 -0
- data/spec/factories/fragment.rb +14 -0
- data/spec/factories/partners.rb +14 -0
- data/spec/factories/record_interaction.rb +17 -0
- data/spec/factories/records.rb +47 -0
- data/spec/factories/set_interaction.rb +15 -0
- data/spec/factories/source_authorities.rb +19 -0
- data/spec/factories/sources.rb +16 -0
- data/spec/factories/usage_metrics.rb +20 -0
- data/spec/factories/user_activities.rb +14 -0
- data/spec/factories/user_sets.rb +27 -0
- data/spec/factories/users.rb +23 -0
- data/spec/helpers/application_helper_spec.rb +35 -0
- data/spec/models/concept_spec.rb +163 -0
- data/spec/models/fragment_spec.rb +15 -0
- data/spec/models/site_activity_spec.rb +103 -0
- data/spec/models/source_activity_spec.rb +56 -0
- data/spec/models/source_authority_spec.rb +42 -0
- data/spec/models/supplejack_api/api_concept/concept_fragment_spec.rb +189 -0
- data/spec/models/supplejack_api/api_record/record_fragment_spec.rb +189 -0
- data/spec/models/supplejack_api/concept_spec.rb +0 -0
- data/spec/models/supplejack_api/interaction_updaters/all_usage_metric_spec.rb +41 -0
- data/spec/models/supplejack_api/interaction_updaters/set_metrics_spec.rb +32 -0
- data/spec/models/supplejack_api/interaction_updaters/usage_metrics_spec.rb +44 -0
- data/spec/models/supplejack_api/partner_spec.rb +20 -0
- data/spec/models/supplejack_api/record_search_spec.rb +429 -0
- data/spec/models/supplejack_api/record_spec.rb +280 -0
- data/spec/models/supplejack_api/schema_definition_spec.rb +272 -0
- data/spec/models/supplejack_api/search_spec.rb +243 -0
- data/spec/models/supplejack_api/set_item_spec.rb +123 -0
- data/spec/models/supplejack_api/source_spec.rb +22 -0
- data/spec/models/supplejack_api/support/fragment_helpers_spec.rb +216 -0
- data/spec/models/supplejack_api/support/harvestable_spec.rb +177 -0
- data/spec/models/supplejack_api/support/searchable_spec.rb +85 -0
- data/spec/models/supplejack_api/support/storable_spec.rb +18 -0
- data/spec/models/supplejack_api/user_activity_spec.rb +88 -0
- data/spec/models/supplejack_api/user_set_spec.rb +559 -0
- data/spec/models/supplejack_api/user_spec.rb +348 -0
- data/spec/routing/concepts_routing_spec.rb +22 -0
- data/spec/routing/harvester_constraint_spec.rb +66 -0
- data/spec/routing/harvester_routing_spec.rb +51 -0
- data/spec/routing/partner_routing_spec.rb +34 -0
- data/spec/routing/records_routing_spec.rb +26 -0
- data/spec/routing/sets_routing_spec.rb +44 -0
- data/spec/routing/source_routing_spec.rb +38 -0
- data/spec/routing/users_routing_spec.rb +18 -0
- data/spec/serializers/concept_record_serializer_spec.rb +30 -0
- data/spec/serializers/supplejack_api/application_serializer_spec.rb +14 -0
- data/spec/serializers/supplejack_api/concept_search_serializer_spec.rb +34 -0
- data/spec/serializers/supplejack_api/concept_serializer_spec.rb +92 -0
- data/spec/serializers/supplejack_api/record_search_serializer_spec.rb +34 -0
- data/spec/serializers/supplejack_api/record_serializer_spec.rb +271 -0
- data/spec/serializers/supplejack_api/search_serializer_spec.rb +90 -0
- data/spec/serializers/supplejack_api/user_serializer_spec.rb +22 -0
- data/spec/serializers/supplejack_api/user_set_serializer_spec.rb +96 -0
- data/spec/services/metrics_api/v3/api_spec.rb +23 -0
- data/spec/services/metrics_api/v3/endpoints/facets_spec.rb +25 -0
- data/spec/services/metrics_api/v3/endpoints/global_spec.rb +22 -0
- data/spec/services/metrics_api/v3/endpoints/root_spec.rb +49 -0
- data/spec/services/metrics_api/v3/presenters/extended_metadata_spec.rb +49 -0
- data/spec/spec_helper.rb +70 -0
- data/spec/support/api/schemas/metrics/daily_metrics_metadata.json +24 -0
- data/spec/support/api/schemas/metrics/extended_metrics.json +26 -0
- data/spec/support/api/schemas/metrics/extended_response.json +6 -0
- data/spec/support/api/schemas/metrics/facets_response.json +6 -0
- data/spec/support/api/schemas/metrics/record_metadata.json +33 -0
- data/spec/support/api/schemas/metrics/top_level_response.json +6 -0
- data/spec/support/api/schemas/metrics/view_metadata.json +33 -0
- data/spec/support/api_schema_matcher.rb +14 -0
- data/spec/support/devise.rb +10 -0
- data/spec/workers/supplejack_api/daily_metrics_worker_spec.rb +140 -0
- data/spec/workers/supplejack_api/flush_old_records_worker_spec.rb +20 -0
- data/spec/workers/supplejack_api/index_worker_spec.rb +52 -0
- data/spec/workers/supplejack_api/source_index_worker_spec.rb +61 -0
- metadata +1231 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fac6e00165771116324b1cd5df5cb74e8d66d0bf
|
4
|
+
data.tar.gz: 5c2a0ff79bfa7d4b23805c1f2926f90aaa7690cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ad4a665dbe19895b3f832c1b8a28e45e9e63ded92a07a7bcc554af8451179b110c8eb366d1bc32fdeef1bc27638573417fe8c69e5f20e6305f4fe8c585589f4c
|
7
|
+
data.tar.gz: dcf93cfdf99e4b4e22827956eb592977daadf56eef9a6c4b6e7ec4bbac78f995070e8aea12ad3cbf684449f486a8ec4f089c2a7c08534f7fdb39f95d80a2fb7f
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Supplejack API
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/DigitalNZ/supplejack_api.svg?branch=master)](https://travis-ci.org/DigitalNZ/supplejack_api)
|
4
|
+
|
5
|
+
The Supplejack API is a [mountable engine](http://guides.rubyonrails.org/engines.html) which provides functionality to store, index and retrieve metadata via an API.
|
6
|
+
|
7
|
+
For more information on how to configure and use this application refer to the [documentation](http://digitalnz.github.io/supplejack).
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
[Install & Setup instructions](http://digitalnz.github.io/supplejack/start/development-setup.html)
|
12
|
+
|
13
|
+
|
14
|
+
## Engine Development
|
15
|
+
|
16
|
+
### Rails console
|
17
|
+
|
18
|
+
```
|
19
|
+
cd spec/dummy/
|
20
|
+
bundle exec rails console
|
21
|
+
```
|
22
|
+
|
23
|
+
### Rails server
|
24
|
+
|
25
|
+
```
|
26
|
+
cd spec/dummy/
|
27
|
+
bundle exec rails server
|
28
|
+
```
|
29
|
+
|
30
|
+
### Solr
|
31
|
+
|
32
|
+
```
|
33
|
+
cd spec/dummy/
|
34
|
+
bundle exec rake app:sunspot:solr:start
|
35
|
+
```
|
36
|
+
|
37
|
+
This will start the server based on the configuration in `config/sunspot.yml`
|
38
|
+
|
39
|
+
```
|
40
|
+
cd spec/dummy/
|
41
|
+
bundle exec rake app:sunspot:solr:stop
|
42
|
+
```
|
43
|
+
|
44
|
+
## Engine Testing
|
45
|
+
|
46
|
+
### Rspec Specs
|
47
|
+
|
48
|
+
From the root of the engine, run
|
49
|
+
|
50
|
+
```
|
51
|
+
bundle exec rspec spec/
|
52
|
+
```
|
53
|
+
|
54
|
+
This uses `spec/dummy` to mount the engine into and then runs the specs.
|
55
|
+
|
56
|
+
### Cucumber Features
|
57
|
+
|
58
|
+
From the root of the engine, run
|
59
|
+
|
60
|
+
```
|
61
|
+
bundle exec cucumber features/
|
62
|
+
```
|
63
|
+
|
64
|
+
This uses a test Solr instance from `spec/dummy/solr` in order to test searching.
|
65
|
+
|
66
|
+
## COPYRIGHT AND LICENSING
|
67
|
+
|
68
|
+
### MAJORITY OF SUPPLEJACK CODE - GNU GENERAL PUBLIC LICENCE, VERSION 3
|
69
|
+
|
70
|
+
Supplejack is a tool for aggregating, searching and sharing metadata records. Supplejack API is a component of Supplejack. Except as indicated below, the Supplejack API code is Crown copyright (C) 2014, New Zealand Government. Supplejack was created by DigitalNZ at the National Library of NZ and the Department of Internal Affairs. http://digitalnz.org/supplejack
|
71
|
+
|
72
|
+
Except as indicated below, this program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
73
|
+
|
74
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
75
|
+
|
76
|
+
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses / http://www.gnu.org/licenses/gpl-3.0.txt
|
77
|
+
|
78
|
+
### SUPPLEJACK API SUNSPOTSESSIONPROXY
|
79
|
+
|
80
|
+
The Supplejack API SunspotSessionProxy was authored by HeyZap (http://www.heyzap.com/) and is available at http://stdout.heyzap.com/2011/08/17/sunspot-resque-session-proxy/.
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
3
|
+
# and is licensed under the GNU General Public License, version 3.
|
4
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
5
|
+
#
|
6
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
7
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
8
|
+
|
9
|
+
#!/usr/bin/env rake
|
10
|
+
begin
|
11
|
+
require 'bundler/setup'
|
12
|
+
rescue LoadError
|
13
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
14
|
+
end
|
15
|
+
begin
|
16
|
+
require 'rdoc/task'
|
17
|
+
rescue LoadError
|
18
|
+
require 'rdoc/rdoc'
|
19
|
+
require 'rake/rdoctask'
|
20
|
+
RDoc::Task = Rake::RDocTask
|
21
|
+
end
|
22
|
+
|
23
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
24
|
+
rdoc.rdoc_dir = 'rdoc'
|
25
|
+
rdoc.title = 'SupplejackApi'
|
26
|
+
rdoc.options << '--line-numbers'
|
27
|
+
rdoc.rdoc_files.include('README.rdoc')
|
28
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
|
+
end
|
30
|
+
|
31
|
+
Bundler::GemHelper.install_tasks
|
32
|
+
|
33
|
+
require 'rake/testtask'
|
34
|
+
|
35
|
+
Rake::TestTask.new(:test) do |t|
|
36
|
+
t.libs << 'lib'
|
37
|
+
t.libs << 'test'
|
38
|
+
t.pattern = 'test/**/*_test.rb'
|
39
|
+
t.verbose = false
|
40
|
+
end
|
41
|
+
|
42
|
+
task default: :test
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/*
|
2
|
+
*The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
3
|
+
* and is licensed under the GNU General Public License, version 3.
|
4
|
+
* One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
5
|
+
* Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
* the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
*/
|
8
|
+
|
9
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
10
|
+
// listed below.
|
11
|
+
//
|
12
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
13
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
14
|
+
//
|
15
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
16
|
+
// the compiled file.
|
17
|
+
//
|
18
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
19
|
+
// GO AFTER THE REQUIRES BELOW.
|
20
|
+
//
|
21
|
+
//= require jquery
|
22
|
+
//= require jquery_ujs
|
23
|
+
//= require highcharts/highcharts
|
24
|
+
//= require highcharts/highcharts-more
|
25
|
+
//= require highcharts/highstock
|
26
|
+
//= require_tree .
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/*
|
2
|
+
*The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
3
|
+
* and is licensed under the GNU General Public License, version 3.
|
4
|
+
* One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
5
|
+
* Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
* the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
*/
|
8
|
+
|
9
|
+
/*
|
10
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
11
|
+
* listed below.
|
12
|
+
*
|
13
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
14
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
15
|
+
*
|
16
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
17
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
18
|
+
*
|
19
|
+
*= require_self
|
20
|
+
*= require_tree .
|
21
|
+
*= require foundation
|
22
|
+
*/
|
23
|
+
|
24
|
+
.table {
|
25
|
+
width: 100%;
|
26
|
+
}
|
27
|
+
|
28
|
+
.site-activities, .users {
|
29
|
+
overflow: scroll;
|
30
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
3
|
+
# and is licensed under the GNU General Public License, version 3.
|
4
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
5
|
+
#
|
6
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
7
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
8
|
+
|
9
|
+
module SupplejackApi
|
10
|
+
module Admin
|
11
|
+
class BaseController < ApplicationController
|
12
|
+
skip_before_filter :authenticate_user!
|
13
|
+
before_filter :authenticate_admin_user!
|
14
|
+
before_filter :restrict_to_admin_users!
|
15
|
+
|
16
|
+
def restrict_to_admin_users!
|
17
|
+
return if current_admin_user.admin?
|
18
|
+
|
19
|
+
sign_out
|
20
|
+
redirect_to new_admin_user_session_path, alert: t('admin.not_a_admin')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
3
|
+
# and is licensed under the GNU General Public License, version 3.
|
4
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
5
|
+
#
|
6
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
7
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
8
|
+
|
9
|
+
module SupplejackApi
|
10
|
+
module Admin
|
11
|
+
class SessionsController < Devise::SessionsController
|
12
|
+
layout 'supplejack_api/application'
|
13
|
+
|
14
|
+
skip_before_filter :authenticate_user!
|
15
|
+
|
16
|
+
def after_sign_in_path_for(resource)
|
17
|
+
stored_location_for(resource) || admin_users_path
|
18
|
+
end
|
19
|
+
|
20
|
+
def after_sign_out_path_for(_resource_or_scope)
|
21
|
+
new_admin_user_session_path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
3
|
+
# and is licensed under the GNU General Public License, version 3.
|
4
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
5
|
+
#
|
6
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
7
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
8
|
+
|
9
|
+
module SupplejackApi
|
10
|
+
module Admin
|
11
|
+
class SiteActivitiesController < BaseController
|
12
|
+
respond_to :html
|
13
|
+
respond_to :csv, only: :index
|
14
|
+
|
15
|
+
def index
|
16
|
+
@site_activities = SupplejackApi::SiteActivity.sortable(order: params[:order], page: params[:page])
|
17
|
+
.order_by(date: :desc)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
3
|
+
# and is licensed under the GNU General Public License, version 3.
|
4
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
5
|
+
#
|
6
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
7
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
8
|
+
|
9
|
+
module SupplejackApi
|
10
|
+
module Admin
|
11
|
+
class UsersController < BaseController
|
12
|
+
layout 'supplejack_api/application'
|
13
|
+
|
14
|
+
respond_to :html
|
15
|
+
respond_to :csv, only: :index
|
16
|
+
|
17
|
+
def index
|
18
|
+
@users = User.sortable(order: params[:order] || :daily_requests_desc, page: params[:page])
|
19
|
+
end
|
20
|
+
|
21
|
+
def show
|
22
|
+
@user = User.find(params[:id])
|
23
|
+
@api_requests = LazyHighCharts::HighChart.new('graph') do |f|
|
24
|
+
f.title(text: 'API requests/day for the last 90 days')
|
25
|
+
f.series(name: 'API Requests',
|
26
|
+
data: @user.requests_per_day(90),
|
27
|
+
pointStart: 89.days.ago,
|
28
|
+
pointInterval: 1.day)
|
29
|
+
f.xAxis(type: :datetime)
|
30
|
+
f.yAxis(title: { text: 'Number of Requests' }, min: 0)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def edit
|
35
|
+
@user = User.find(params[:id])
|
36
|
+
end
|
37
|
+
|
38
|
+
def update
|
39
|
+
@user = User.find(params[:id])
|
40
|
+
|
41
|
+
if @user.update_attributes(user_params)
|
42
|
+
redirect_to admin_users_path
|
43
|
+
else
|
44
|
+
render :edit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def user_params
|
51
|
+
params.require(:user).permit(:max_requests)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
3
|
+
# and is licensed under the GNU General Public License, version 3.
|
4
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
5
|
+
#
|
6
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
7
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
8
|
+
|
9
|
+
module SupplejackApi
|
10
|
+
class ApplicationController < ActionController::Base
|
11
|
+
protect_from_forgery
|
12
|
+
|
13
|
+
before_filter :authenticate_user!
|
14
|
+
|
15
|
+
def authenticate_user!
|
16
|
+
error_message = nil
|
17
|
+
|
18
|
+
if params[:api_key].blank?
|
19
|
+
error_message = I18n.t('users.blank_token')
|
20
|
+
elsif current_user
|
21
|
+
if current_user.over_limit?
|
22
|
+
error_message = I18n.t('users.reached_limit')
|
23
|
+
else
|
24
|
+
current_user.update_tracked_fields(request)
|
25
|
+
current_user.update_daily_activity(request)
|
26
|
+
current_user.check_daily_requests
|
27
|
+
current_user.save(validate: false)
|
28
|
+
end
|
29
|
+
else
|
30
|
+
error_message = I18n.t('users.invalid_token')
|
31
|
+
end
|
32
|
+
|
33
|
+
format = :json
|
34
|
+
format = request.format.to_sym if [:xml, :json, :rss].include?(request.format.try(:to_sym))
|
35
|
+
|
36
|
+
if error_message
|
37
|
+
render format => { errors: error_message }, status: :forbidden
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def current_user
|
42
|
+
@current_user ||= User.find_by_api_key(params[:api_key])
|
43
|
+
end
|
44
|
+
|
45
|
+
def authenticate_admin!
|
46
|
+
if RecordSchema.roles[current_user.role.to_sym].try(:admin)
|
47
|
+
return true
|
48
|
+
else
|
49
|
+
render request.format.to_sym => {
|
50
|
+
errors: 'You need Administrator privileges to perform this request'
|
51
|
+
}, status: :forbidden
|
52
|
+
return false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def find_user_set
|
57
|
+
user_set_id = params[:user_set_id] || params[:id]
|
58
|
+
|
59
|
+
@user_set = if RecordSchema.roles[current_user.role.to_sym].try(:admin)
|
60
|
+
UserSet.custom_find(user_set_id)
|
61
|
+
else
|
62
|
+
current_user.user_sets.custom_find(user_set_id)
|
63
|
+
end
|
64
|
+
|
65
|
+
unless @user_set
|
66
|
+
render json: { errors: "Set with id: #{params[:id]} was not found." }, status: :not_found
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
3
|
+
# and is licensed under the GNU General Public License, version 3.
|
4
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
5
|
+
#
|
6
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
7
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
8
|
+
|
9
|
+
module SupplejackApi
|
10
|
+
class ConceptsController < ApplicationController
|
11
|
+
skip_before_filter :authenticate_user!, only: [:source]
|
12
|
+
skip_before_filter :verify_limits!, only: [:source]
|
13
|
+
|
14
|
+
respond_to :json, :xml, :rss
|
15
|
+
|
16
|
+
def index
|
17
|
+
@search = ConceptSearch.new(params)
|
18
|
+
@search.request_url = request.original_url
|
19
|
+
@search.scope = current_user
|
20
|
+
|
21
|
+
begin
|
22
|
+
if @search.valid?
|
23
|
+
respond_with @search, serializer: ConceptSearchSerializer
|
24
|
+
else
|
25
|
+
render request.format.to_sym => { errors: @search.errors }, status: :bad_request
|
26
|
+
end
|
27
|
+
rescue RSolr::Error::Http => e
|
28
|
+
render request.format.to_sym => { errors: solr_error_message(e) }, status: :bad_request
|
29
|
+
rescue Sunspot::UnrecognizedFieldError => e
|
30
|
+
render request.format.to_sym => { errors: e.to_s }, status: :bad_request
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def show
|
35
|
+
@concept = SupplejackApi::Concept.custom_find(params[:id], current_user, params[:search])
|
36
|
+
respond_with @concept, root: false, serializer: ConceptSerializer
|
37
|
+
rescue Mongoid::Errors::DocumentNotFound
|
38
|
+
render request.format.to_sym => { errors: "Concept with ID #{params[:id]} was not found" }, status: :not_found
|
39
|
+
end
|
40
|
+
|
41
|
+
def default_serializer_options
|
42
|
+
default_options = {}
|
43
|
+
@search ||= SupplejackApi::ConceptSearch.new(params)
|
44
|
+
default_options[:fields] = @search.field_list if @search.field_list.present?
|
45
|
+
default_options[:groups] = @search.group_list if @search.group_list.present?
|
46
|
+
if params[:inline_context].try(:downcase) == 'true'
|
47
|
+
default_options[:inline_context] = params[:inline_context]
|
48
|
+
end
|
49
|
+
default_options
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|