-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #216 from CDRH/dev
v3.1.1
- Loading branch information
Showing
28 changed files
with
301 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
orchid (3.0.3) | ||
orchid (3.1.1) | ||
rails (~> 5.2.0) | ||
|
||
GEM | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1><%= t "browse.browse_type", default: "Browse by" %> <%= @browse_facet_info["label"] %></h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1><%= t "browse.title", default: "Browse" %></h1> | ||
|
||
<p> | ||
<%= link_to t("browse.all_link", default: "All Items in the Collection"), prefix_path(route_path), | ||
class: "btn btn-lg btn-default", rel: "search" %> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<% if params["q"].blank? && params["f"].blank? %> | ||
<h1><%= t "search.all_items", default: "All Items" %></h1> | ||
<% else %> | ||
<h1><%= t "search.search_results", default: "Search Results" %></h1> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1><%= @content_label || @title %></h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
<% if APP_OPTS["languages"].present? && APP_OPTS["languages"][/\|/] %> | ||
<% langs = APP_OPTS["languages"] %> | ||
|
||
<% if langs.present? && langs[/\|/] %> | ||
<div class="language_link btn-group" role="group" aria-label="language choice"> | ||
<% APP_OPTS["languages"].split("|").each do |lang_code| %> | ||
<%# create link to switch languages that keeps current parameters %> | ||
<%# TODO a11y / ARIA markup for full language names? %> | ||
<% if lang_code == I18n.locale.to_s %> | ||
<%= link_to lang_code.upcase, "#", class: "btn btn-primary disabled", | ||
hreflang: lang_code, rel: "alternate", tabindex: -1 %> | ||
<% else %> | ||
<%# a11y / ARIA markup for full language name? %> | ||
<%= link_to lang_code.upcase, locale_link(lang_code), | ||
class: "btn btn-default", hreflang: lang_code, rel: "alternate" %> | ||
<% end %> | ||
<% langs.split("|").each do |lang_code| %> | ||
<%= language_toggle_link(lang_code) %> | ||
<% end %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%# override this file to add your own analytics code %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<%# links for alternate language pages %> | ||
<% if APP_OPTS["languages"].present? && APP_OPTS["languages"][/\|/] %> | ||
<% APP_OPTS["languages"].split("|").each do |lang_code| %> | ||
<%# if this is the currently selected language | ||
then no alternative link is needed for it %> | ||
<% next if lang_code == I18n.locale.to_s %> | ||
<link rel="alternate" hreflang="<%= lang_code %>" | ||
href="<%= locale_link(lang_code) %>" /> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Below is a list of languages currently supported by Orchid | ||
# | ||
# If you want to add an additional language, you will need | ||
# to add it to your app's languages.yml file below in the | ||
# langs key, then include the langs in your language's key. | ||
|
||
|
||
langs: &langs | ||
en: English | ||
es: Español | ||
|
||
en: | ||
languages: | ||
<<: *langs | ||
|
||
es: | ||
languages: | ||
<<: *langs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# API Requests | ||
|
||
When you are [overridding default controllers](/docs/overrides.md) or adding | ||
new [sections](/docs/sections.md) and [search presets](/docs/search_preset.md), | ||
you may find yourself needing to create custom API requests. | ||
|
||
- [Accessing the Connection](#accessing-the-connection) | ||
- [Querying](#querying) | ||
- [The Response](#the-response) | ||
- [Querying by ID](#querying-by-id) | ||
|
||
## Accessing the Connection | ||
|
||
When you first start an Orchid app, it connects to the API endpoint specified | ||
in your `config/private.yml` file with default settings from `config/public.yml`. | ||
|
||
That Query object is stored with a global variable: | ||
|
||
```ruby | ||
$api | ||
``` | ||
|
||
Typically, you will not need to work directly with `$api`. In the | ||
ItemsController, you are provided with an instance variable: | ||
|
||
```ruby | ||
@items_api | ||
``` | ||
|
||
`@items_api` will return either `$api` or a section appropriate connection, if | ||
you are working with sections. | ||
|
||
The section API connection information is stored in `$api_sections`, although | ||
you should rarely need to use it directly. | ||
|
||
## Querying | ||
|
||
Orchid uses the CDRH API's syntax for requests. You should familiarize yourself | ||
with the [API documentation](https://github.com/CDRH/api) before writing custom | ||
requests. | ||
|
||
When you initialize your application, Orchid sets up default query parameters | ||
using your config file settings. | ||
|
||
This means that you do not need to specify things such as the number of items | ||
per page, starting sort, facets, and any default filters for new queries, since | ||
they are already built in as a convenience. | ||
|
||
However, you may override those defaults as desired when creating a new query. | ||
|
||
A typical query will look something like this: | ||
|
||
```ruby | ||
@items_api.query({ hash of options }) | ||
``` | ||
|
||
For example, the following would bring back results of Willa Cather's writing with the text "birthday": | ||
|
||
```ruby | ||
|
||
options = { | ||
"f" => [ "category|Writings", "creator.name|Cather, Willa" ], | ||
"q" => "birthday" | ||
} | ||
@items_api.query(options) | ||
``` | ||
|
||
### The Response | ||
|
||
`.query` returns a Response object which has the following methods: | ||
|
||
- count : the number of items found | ||
- facets : a hash with facets + facet counts you requested | ||
- items : an array of the documents you requested | ||
- first : the first item | ||
- pages: the page count needed to display all the items | ||
|
||
### Querying by ID | ||
|
||
Although you could send a `.query({ identifier: "some.id" })` request and | ||
select the first item, orchid provides a helpful method to get a single item: | ||
|
||
```ruby | ||
@items_api.get_item_by_id("some.id").first | ||
``` |
Oops, something went wrong.