Skip to content

Commit

Permalink
Update dive-into-hydra docs for 7.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-dce committed May 6, 2014
1 parent aea2fca commit 58809d0
Show file tree
Hide file tree
Showing 15 changed files with 276 additions and 298 deletions.
4 changes: 2 additions & 2 deletions RELEASE-POLICY.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ repositories, so you can treat them like any other.
git pull
```

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

```
cp -a path/to/hydra.wiki/* path/to/hydra/doc/
Expand All @@ -60,4 +60,4 @@ repositories, so you can treat them like any other.
This commit should then be included as part of the pull request for the new
release. See ["Making Changes"](/CONTRIBUTING.md#making-changes) and
["Submitting Changes"](/CONTRIBUTING.md#submitting-changes) on the preferred
way to submit pull requests.
way to submit pull requests.
11 changes: 3 additions & 8 deletions doc/Dive-into-Hydra.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This tutorial is known to work with [hydra](http://rubygems.org/gems/hydra) release version 6.1.0.
This tutorial is tested to work with [hydra](http://rubygems.org/gems/hydra) release version 7.0.0.
_Please update this wiki to reflect any other versions that have been tested._

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

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

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

# Steps/Lessons
1. [[Lesson: Generate a Rails Application]]
1. [[Lesson: Create a git Repository]]
1. [[Lesson: Add the Hydra Dependencies]]
1. [[Lesson: Run the Hydra generator]]
1. [[Lesson: Install hydra-jetty]]
1. [[Lesson: Start Jetty]]
1. [[Lesson: Start the Application & Search for Results]]
1. [[Lesson: Build a Book Model]]
1. [[Lesson: Turn Off Access Controls]]
1. [[Lesson: Make Blacklight Return Search Results]]

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

# Next Steps
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.
Expand Down
16 changes: 10 additions & 6 deletions doc/Lesson:-Define-Relationships-Between-Objects.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
This lesson is known to work with hydra version 6.2.0.
_Please update this wiki to reflect any other versions that have been tested._

# Goals
* Set up Models to represent relationships between different types of objects
* Create and modify relationships between objects
Expand Down Expand Up @@ -28,6 +25,11 @@ class Datastreams::PageMetadata < ActiveFedora::OmDatastream
def self.xml_template
Nokogiri::XML.parse("<fields/>")
end

def prefix
'' # add a prefix for solr index terms if you need to namespace identical terms in multiple data streams
end

end

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

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

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

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

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

```
```text
<?xml version="1.0" encoding="UTF-8"?>
<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#">
<rdf:Description rdf:about="info:fedora/changeme:2">
Expand Down Expand Up @@ -123,5 +127,5 @@ $> git commit -m "Created a book page model with relationship to the book model"
```

# Next Step
Go on to [[Lesson: Adding Content Datastreams]] or
Go on to **BONUS** [[Lesson: Adding Content Datastreams]] or
explore other [Dive into Hydra](Dive into Hydra#Bonus) tutorial bonus lessons.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
This Tutorial is known to work with hydra version 6.1.0, 6.2.0.
_Please update this wiki to reflect any other versions that have been tested._

# Goals

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

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

If you see 'uninitialized constant Book::BookMetadata' you'll need to edit `app/models/datastreams/book_metadata.rb`

Replace the first line BookMetadata with Datastreams::BookMetadata:

```ruby
class Datastreams::BookMetadata < ActiveFedora::OmDatastream
```

You will also need to edit `app/models/book.rb`

Again, replace BookMetadata with Datastreams::BookMetadata:
Explore the pages for creating, editing and showing Books.

```ruby
has_metadata 'descMetadata', type: Datastreams::BookMetadata
```
Explore the pages for creating, editing and showing Books.
> ####Rails 3-troubleshooting:
> If you see 'uninitialized constant Book::BookMetadata' you'll need to edit two files.
> Open `app/models/datastreams/book_metadata.rb` and replace `BookMetadata` in the class definition with `Datastreams::BookMetadata` i.e.
>
> ```ruby
> class Datastreams::BookMetadata < ActiveFedora::OmDatastream
> ```
>
> You will also need to edit `app/models/book.rb` and replace `BookMetadata` with `Datastreams::BookMetadata`:
>
> ```ruby
> has_metadata 'descMetadata', type: Datastreams::BookMetadata
> ```
### Step 3: Commit your work
Expand Down Expand Up @@ -179,4 +175,4 @@ git commit -m "Handling multivalued author fields"
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.

# Next Step
Proceed to [[Lesson: Set up your Rails Application to use RSpec]] or explore other [Dive into Hydra](Dive into Hydra#Bonus) tutorial bonus lessons.
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.
60 changes: 51 additions & 9 deletions doc/Lesson:-add-the-Hydra-dependencies.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,70 @@
This lesson is known to work with hydra (gem) version 6.1.0, 6.2.0.
_Please update this wiki to reflect any other versions that have been tested._

# Goals
* Add the Hydra software to your application's list of dependencies
* Use bundler to install dependencies
* Add Hydra (Hydra, Blacklight, and Devise) functionality to your Rails Application

# Explanation

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.

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.

# Steps

Open up ```Gemfile``` in your editor. We're going to add the following lines:
### Step 1: Add the *hydra* gem to your Gemfile

Open up `Gemfile` in your editor. We're going to add the following lines after the `source` line:

```ruby
gem 'hydra'
```

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.
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.

Now save the change and install the dependencies by running bundler:
```text
bundle install
```

Check which files have been changed:
```text
git status
```

You should see changes to your `Gemfile` and `Gemfile.lock`. Now, go ahead and commit the modified files to your local git repo:
```text
git add .
git commit -m "Add hydra dependency to Gemfile"
```

### Step 2: Run the code generator provided by the *hydra* gem.

>
**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`.
>
Run the hydra generator

```text
rails generate hydra:install
```

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.

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.

### Step 3: Review and commit your changes

See what the hydra generator has done
```text
git status
```

After you've viewed which files have been modified, commit the changes:

Now we save the file and install the dependencies by running bundler:
```text
$ bundle install
git add .
git commit -m "Ran hydra generator"
```

# Next Step
Go on to [[Lesson: Run the Hydra generator]] or return to the [[Dive into Hydra]] page.
Go on to [[Lesson: Install hydra-jetty]] or return to the [[Dive into Hydra]] page.
5 changes: 1 addition & 4 deletions doc/Lesson:-adding-content-datastreams.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
This lesson is known to work with hydra version 6.1.0, 6.2.0.
_Please update this wiki to reflect any other versions that have been tested._

# Goals
* Add "file-bearing" Datastreams to models and objects
* See where files are stored in Fedora objects and how to retrieve them
Expand Down Expand Up @@ -57,4 +54,4 @@ $> git commit -m "Created a content datastream"
```

# Next Step
Proceed to [[Lesson: Generate Rails Scaffolding for Creating and Editing Books]] or explore other [Dive into Hydra](Dive into Hydra#bonus) tutorial bonus lessons.
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.
19 changes: 11 additions & 8 deletions doc/Lesson:-build-a-book-model.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
This lesson is known to work with hydra release version 6.1.0, 6.2.0.
_Please update this wiki to reflect any other versions that have been tested._

# Goals
* Define a simple OM (Opinionated Metadata) Terminology for Book Metadata that we will track as XML Datastreams
* Start the Rails console and run code interactively in the console
Expand Down Expand Up @@ -44,6 +41,12 @@ class BookMetadata < ActiveFedora::OmDatastream
def self.xml_template
Nokogiri::XML.parse("<fields/>")
end

def prefix
# set a datastream prefix if you need to namespace terms that might occur in multiple data streams
""
end

end
```

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

```text
b.descMetadata.to_solr
=> {"title_tesim"=>["Anna Karenina"], "author_tesim"=>["Tolstoy, Leo"]}
=> {"title_tesim"=>["Anna Karenina"], "author_tesim"=>["Tolstoy, Leo"]}
```
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]].

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

```xml
<arr name="title_tesim">
<str>Anna Karenina</str>
<str>Anna Karenina</str>
</arr>
<arr name="author_tesim">
<str>Tolstoy, Leo</str>
<str>Tolstoy, Leo</str>
</arr>
```

**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.
**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.

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

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

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

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.
32 changes: 0 additions & 32 deletions doc/Lesson:-create-a-git-repository.md

This file was deleted.

Loading

0 comments on commit 58809d0

Please sign in to comment.