Skip to content

Commit 58809d0

Browse files
committed
Update dive-into-hydra docs for 7.0.0 release
1 parent aea2fca commit 58809d0

15 files changed

+276
-298
lines changed

RELEASE-POLICY.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ repositories, so you can treat them like any other.
4343
git pull
4444
```
4545

46-
1. Copy the wiki pages to `docs/` directory of `hydra` project.
46+
1. Copy the wiki pages to `doc/` directory of `hydra` repository.
4747

4848
```
4949
cp -a path/to/hydra.wiki/* path/to/hydra/doc/
@@ -60,4 +60,4 @@ repositories, so you can treat them like any other.
6060
This commit should then be included as part of the pull request for the new
6161
release. See ["Making Changes"](/CONTRIBUTING.md#making-changes) and
6262
["Submitting Changes"](/CONTRIBUTING.md#submitting-changes) on the preferred
63-
way to submit pull requests.
63+
way to submit pull requests.

doc/Dive-into-Hydra.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This tutorial is known to work with [hydra](http://rubygems.org/gems/hydra) release version 6.1.0.
1+
This tutorial is tested to work with [hydra](http://rubygems.org/gems/hydra) release version 7.0.0.
22
_Please update this wiki to reflect any other versions that have been tested._
33

44
# Prerequisites
@@ -11,8 +11,8 @@ The tutorial also mentions using [Ruby Version Manager](http://rvm.io), a.k.a RV
1111

1212
# System Requirements
1313
Your system should have the following installed before beginning the walkthrough
14-
+ [ruby](http://www.ruby-lang.org/en/) 1.9.3 or 2.0.0
15-
+ [rails](http://rubyonrails.org/) ~>3.2.15 or ~>4.0.0
14+
+ [ruby](http://www.ruby-lang.org/en/) 2.1.1 (also works with 2.0.0)
15+
+ [rails](http://rubyonrails.org/) ~>4.1.0 (also works with 3.2.x & 4.0.x)
1616
+ [git](http://git-scm.com/)
1717
+ [java](http://www.java.com/en/) runtime >= 6.0
1818

@@ -29,14 +29,10 @@ Your system should have the following installed before beginning the walkthrough
2929

3030
# Steps/Lessons
3131
1. [[Lesson: Generate a Rails Application]]
32-
1. [[Lesson: Create a git Repository]]
3332
1. [[Lesson: Add the Hydra Dependencies]]
34-
1. [[Lesson: Run the Hydra generator]]
3533
1. [[Lesson: Install hydra-jetty]]
36-
1. [[Lesson: Start Jetty]]
3734
1. [[Lesson: Start the Application & Search for Results]]
3835
1. [[Lesson: Build a Book Model]]
39-
1. [[Lesson: Turn Off Access Controls]]
4036
1. [[Lesson: Make Blacklight Return Search Results]]
4137

4238
## Bonus
@@ -45,7 +41,6 @@ You've completed the main tutorial, the following lessons can be completed in an
4541
1. [[Lesson: Define Relationships Between Objects]]
4642
1. [[Lesson: Adding Content Datastreams]]
4743
1. [[Lesson: Generate Rails Scaffolding for Creating and Editing Books]]
48-
1. [[Lesson: Set up your Rails Application to use RSpec]]
4944

5045
# Next Steps
5146
You've finished the initial Hydra tutorial and learned about setting up the basic hydra framework, building basic data models, establishing relationships between models, and modifying the basic user interface provided in a default hydra install. There is still lots more to learn. At this point, you can explore the ideas in this tutorial further by spending some time building out your models to support more complex metadata, further customizing your application views, and/or adding tests to make your applications more robust and easy to maintain.

doc/Lesson:-Define-Relationships-Between-Objects.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
This lesson is known to work with hydra version 6.2.0.
2-
_Please update this wiki to reflect any other versions that have been tested._
3-
41
# Goals
52
* Set up Models to represent relationships between different types of objects
63
* Create and modify relationships between objects
@@ -28,6 +25,11 @@ class Datastreams::PageMetadata < ActiveFedora::OmDatastream
2825
def self.xml_template
2926
Nokogiri::XML.parse("<fields/>")
3027
end
28+
29+
def prefix
30+
'' # add a prefix for solr index terms if you need to namespace identical terms in multiple data streams
31+
end
32+
3133
end
3234

3335
```
@@ -52,7 +54,7 @@ This is very similar to how our Book class looks, with the exception of the line
5254

5355
### Step 3: Make Books aware of their Pages
5456

55-
Let's edit the Book class and add the other half of the relationship:
57+
Let's edit the Book class in ```app/models/book.rb``` and add the other half of the relationship:
5658

5759
```ruby
5860
# within app/models/book.rb
@@ -72,6 +74,8 @@ p.book = b
7274
=> #<Book pid:"changeme:1", title:"Anna Karenina", author:"Tolstoy, Leo">
7375
p.save
7476
=> true
77+
b.reload
78+
=> #<Book pid:"changeme:1", title:"Anna Karenina", author:"Tolstoy, Leo">
7579
b.pages
7680
=> [#<Page pid:"changeme:2", number:1, text:"Happy families are all alike; every unhappy family is unhappy in its own way.">]
7781
```
@@ -89,7 +93,7 @@ Alternatively, look at the datastream in your browser at [http://localhost:8983/
8993

9094
Either way, you should see RDF that looks like this:
9195

92-
```
96+
```text
9397
<?xml version="1.0" encoding="UTF-8"?>
9498
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ns0="info:fedora/fedora-system:def/model#" xmlns:ns1="info:fedora/fedora-system:def/relations-external#">
9599
<rdf:Description rdf:about="info:fedora/changeme:2">
@@ -123,5 +127,5 @@ $> git commit -m "Created a book page model with relationship to the book model"
123127
```
124128

125129
# Next Step
126-
Go on to [[Lesson: Adding Content Datastreams]] or
130+
Go on to **BONUS** [[Lesson: Adding Content Datastreams]] or
127131
explore other [Dive into Hydra](Dive into Hydra#Bonus) tutorial bonus lessons.

doc/Lesson:-Generate-Rails-Scaffolding-for-Creating-and-Editing-Books.md

+15-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
This Tutorial is known to work with hydra version 6.1.0, 6.2.0.
2-
_Please update this wiki to reflect any other versions that have been tested._
3-
41
# Goals
52

63
- Understand the difference between unique (single-value) and multi-valued metadata fields
@@ -44,22 +41,21 @@ Removing test/unit/helpers/
4441

4542
Run the `rails server` and visit [[http://localhost:3000/books]]
4643

47-
If you see 'uninitialized constant Book::BookMetadata' you'll need to edit `app/models/datastreams/book_metadata.rb`
48-
49-
Replace the first line BookMetadata with Datastreams::BookMetadata:
50-
51-
```ruby
52-
class Datastreams::BookMetadata < ActiveFedora::OmDatastream
53-
```
54-
55-
You will also need to edit `app/models/book.rb`
56-
57-
Again, replace BookMetadata with Datastreams::BookMetadata:
44+
Explore the pages for creating, editing and showing Books.
5845

59-
```ruby
60-
has_metadata 'descMetadata', type: Datastreams::BookMetadata
61-
```
62-
Explore the pages for creating, editing and showing Books.
46+
> ####Rails 3-troubleshooting:
47+
> If you see 'uninitialized constant Book::BookMetadata' you'll need to edit two files.
48+
> Open `app/models/datastreams/book_metadata.rb` and replace `BookMetadata` in the class definition with `Datastreams::BookMetadata` i.e.
49+
>
50+
> ```ruby
51+
> class Datastreams::BookMetadata < ActiveFedora::OmDatastream
52+
> ```
53+
>
54+
> You will also need to edit `app/models/book.rb` and replace `BookMetadata` with `Datastreams::BookMetadata`:
55+
>
56+
> ```ruby
57+
> has_metadata 'descMetadata', type: Datastreams::BookMetadata
58+
> ```
6359
6460
### Step 3: Commit your work
6561
@@ -179,4 +175,4 @@ git commit -m "Handling multivalued author fields"
179175
Based on the concepts in steps 1-7, determine whether you want 'Title' to display as a single or multi-valued field and make appropriate edits to the 'show' view and '_form' partial on your own.
180176

181177
# Next Step
182-
Proceed to [[Lesson: Set up your Rails Application to use RSpec]] or explore other [Dive into Hydra](Dive into Hydra#Bonus) tutorial bonus lessons.
178+
Proceed to additional hydra tutorials including [Tame Your XML With OM](https://github.com/projecthydra/om/wiki/Tame-your-XML-with-OM) and [Access Controls with Hydra](https://github.com/projecthydra/hydra-head/wiki/Access-Controls-with-Hydra) or go back to explore other [Dive into Hydra](Dive into Hydra#Bonus) tutorial bonus lessons.
+51-9
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,70 @@
1-
This lesson is known to work with hydra (gem) version 6.1.0, 6.2.0.
2-
_Please update this wiki to reflect any other versions that have been tested._
3-
41
# Goals
52
* Add the Hydra software to your application's list of dependencies
6-
* Use bundler to install dependencies
3+
* Add Hydra (Hydra, Blacklight, and Devise) functionality to your Rails Application
74

85
# Explanation
96

107
In order to take advantage of the Hydra code and features in your application, you need to tell the application where to find that code and which versions of that code to use. Rails uses a tool called [bundler](http://bundler.io/) to track dependencies. Bundler looks in the file called `Gemfile` to know what you want installed.
118

9+
Hydra builds on and extends the features provided by Blacklight, the hydra generator integrates core hydra and blacklight functionality into your application. To do this, we run the custom [Rails generator](http://guides.rubyonrails.org/generators.html) provided by the hydra gem. The generator creates a number of files in your application that will allow you to build a Hydra application and use and modify Blacklight's features in your application. The default generator also installs [devise](https://github.com/plataformatec/devise) to provide simple user authentication and management.
10+
1211
# Steps
1312

14-
Open up ```Gemfile``` in your editor. We're going to add the following lines:
13+
### Step 1: Add the *hydra* gem to your Gemfile
14+
15+
Open up `Gemfile` in your editor. We're going to add the following lines after the `source` line:
1516

1617
```ruby
1718
gem 'hydra'
1819
```
1920

20-
This declares our application to have a dependency on the hydra6 release version of the hydra-gem and ensures that the hydra-head gem gets included (required) correctly. This includes a dependency for the jettywrapper gem (installed automatically). The jettywrapper gem is used to install and configure a preconfigured instance of jetty that loads and runs local development instances of Fedora and Solr for you to run and test your application against.
21+
This includes the hydra-gem in our application. Bundler will then ensure that the hydra-head, blacklight, active-fedora and other gems required by hydra get included (required) correctly. This includes a dependency for the jettywrapper gem (installed automatically). The jettywrapper gem is used to install and configure a preconfigured instance of jetty that loads and runs local development instances of Fedora and Solr for you to run and test your application against.
22+
23+
Now save the change and install the dependencies by running bundler:
24+
```text
25+
bundle install
26+
```
27+
28+
Check which files have been changed:
29+
```text
30+
git status
31+
```
32+
33+
You should see changes to your `Gemfile` and `Gemfile.lock`. Now, go ahead and commit the modified files to your local git repo:
34+
```text
35+
git add .
36+
git commit -m "Add hydra dependency to Gemfile"
37+
```
38+
39+
### Step 2: Run the code generator provided by the *hydra* gem.
40+
41+
>
42+
**Tip:** If you want to see clearly what changes that the generator makes, make sure that all of your current changes have been checked into git before running the generator. I.E. make sure that `git status` reports that there are no changes ("nothing to commit"). Then, after you run the generator, you can list all of the newly created and modified field by running `git status`.
43+
>
44+
45+
Run the hydra generator
46+
47+
```text
48+
rails generate hydra:install
49+
```
50+
51+
The hydra generator invokes both the blacklight generator and the hydra-head generator. Additionally, the blacklight generator installed the devise gem and the bootstrap gem. It's created an important file in our application `app/controllers/catalog_controller.rb`. This is the primary place where you configure the blacklight search.
52+
53+
When they are done, the generators have created a few database migrations that support saving user data, searches and bookmarks. Normally you would have to run `rake db:migrate` to update your database tables, but the hydra installer does this for you as one of its last steps.
54+
55+
### Step 3: Review and commit your changes
56+
57+
See what the hydra generator has done
58+
```text
59+
git status
60+
```
61+
62+
After you've viewed which files have been modified, commit the changes:
2163

22-
Now we save the file and install the dependencies by running bundler:
2364
```text
24-
$ bundle install
65+
git add .
66+
git commit -m "Ran hydra generator"
2567
```
2668

2769
# Next Step
28-
Go on to [[Lesson: Run the Hydra generator]] or return to the [[Dive into Hydra]] page.
70+
Go on to [[Lesson: Install hydra-jetty]] or return to the [[Dive into Hydra]] page.

doc/Lesson:-adding-content-datastreams.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
This lesson is known to work with hydra version 6.1.0, 6.2.0.
2-
_Please update this wiki to reflect any other versions that have been tested._
3-
41
# Goals
52
* Add "file-bearing" Datastreams to models and objects
63
* See where files are stored in Fedora objects and how to retrieve them
@@ -57,4 +54,4 @@ $> git commit -m "Created a content datastream"
5754
```
5855

5956
# Next Step
60-
Proceed to [[Lesson: Generate Rails Scaffolding for Creating and Editing Books]] or explore other [Dive into Hydra](Dive into Hydra#bonus) tutorial bonus lessons.
57+
Proceed to **BONUS** [[Lesson: Generate Rails Scaffolding for Creating and Editing Books]] or explore other [Dive into Hydra](Dive into Hydra#bonus) tutorial bonus lessons.

doc/Lesson:-build-a-book-model.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
This lesson is known to work with hydra release version 6.1.0, 6.2.0.
2-
_Please update this wiki to reflect any other versions that have been tested._
3-
41
# Goals
52
* Define a simple OM (Opinionated Metadata) Terminology for Book Metadata that we will track as XML Datastreams
63
* Start the Rails console and run code interactively in the console
@@ -44,6 +41,12 @@ class BookMetadata < ActiveFedora::OmDatastream
4441
def self.xml_template
4542
Nokogiri::XML.parse("<fields/>")
4643
end
44+
45+
def prefix
46+
# set a datastream prefix if you need to namespace terms that might occur in multiple data streams
47+
""
48+
end
49+
4750
end
4851
```
4952

@@ -216,7 +219,7 @@ Check and see that to_solr includes the title and author fields.
216219

217220
```text
218221
b.descMetadata.to_solr
219-
=> {"title_tesim"=>["Anna Karenina"], "author_tesim"=>["Tolstoy, Leo"]}
222+
=> {"title_tesim"=>["Anna Karenina"], "author_tesim"=>["Tolstoy, Leo"]}
220223
```
221224
Now when you call `.to_solr` on a BookMetadata datastream it returns a solr document with fields named `title_tesim` and `author_tesim` that contain your title and author values. Those are the field names that we will add to Blacklight's queries in [[Lesson: Make Blacklight Return Search Results]].
222225

@@ -234,14 +237,14 @@ If you refresh the document result from solr ([[http://localhost:8983/solr/selec
234237

235238
```xml
236239
<arr name="title_tesim">
237-
<str>Anna Karenina</str>
240+
<str>Anna Karenina</str>
238241
</arr>
239242
<arr name="author_tesim">
240-
<str>Tolstoy, Leo</str>
243+
<str>Tolstoy, Leo</str>
241244
</arr>
242245
```
243246

244-
**Aside:** The strange suffixes on the field names are provided by [solrizer](http://github.com/projecthydra/solrizer). You can read about them in the solrizer documentaton. In short, the **_tesim** suffix tells Solr to treat the values as _**t**ext_ in the _**e**nglish_ language that should be _**s**tored_, _**i**ndexed_ and allowed to be _**m**ultivalued_. This _tesim suffix is a useful catch-all that gets your searches working predictably with minimal fuss. As you encounter cases where you need to index your content in more nuanced ways, there are ways to change these suffixes in order to achieve different results in Solr.
247+
**Aside:** The strange suffixes on the field names are provided by [solrizer](http://github.com/projecthydra/solrizer). You can read about them in the [solrizer documentaton](https://github.com/projecthydra/hydra-head/wiki/Solr-Schema). In short, the **_tesim** suffix tells Solr to treat the values as _**t**ext_ in the _**e**nglish_ language that should be _**s**tored_, _**i**ndexed_ and allowed to be _**m**ultivalued_. This _tesim suffix is a useful catch-all that gets your searches working predictably with minimal fuss. As you encounter cases where you need to index your content in more nuanced ways, there are ways to change these suffixes in order to achieve different results in Solr.
245248

246249
#### Why doesn't the Book show up in Blacklight?
247250

@@ -257,6 +260,6 @@ $> git commit -m "Created a book model and a datastream"
257260
```
258261

259262
# Next Step
260-
Go on to [[Lesson: Turn Off Access Controls]] or return to the [[Dive into Hydra]] page.
263+
Go on to [[Lesson: Make Blacklight Return Search Results]] or return to the [[Dive into Hydra]] page.
261264

262265
If you want to learn about OM Terminologies and how they work, visit the [Tame your XML with OM](https://github.com/projecthydra/om/wiki/Tame-your-XML-with-OM) Tutorial.

doc/Lesson:-create-a-git-repository.md

-32
This file was deleted.

0 commit comments

Comments
 (0)