forked from samvera/hyku
-
Notifications
You must be signed in to change notification settings - Fork 1
Developer Cheatsheet
Tiffany Chan edited this page Jul 7, 2020
·
36 revisions
- Restart the server (i.e. Apache)
- Change the permissions or ownership of a file or folder (recursively)
- Search recursively for a string (of text) in a directory or file
- Start the rails console for vault.library.uvic.ca
- Clear the rails console
- Search for a string within a list of an object's methods
- Find the corresponding solr document, given a collection, work, or file set
- Find all works in a collection, given that collection's ID
- collection presenter with admin privileges
- work show presenter with admin privileges
- file set presenter with admin privileges
- List IIIF metadata fields (which appear in the IIIF manifest)
- List controlled vocabulary fields (also called authority fields)
- List required fields
- List primary terms (fields above the fold)
- List secondary terms ("additional fields" below the fold)
- List all terms
- Finding a document by ID
- Common query parameters
- Limiting results by model (collection, work, file set)
- Updating or posting information
- Return all index entries where a field is blank
- Return all index entries where a field is NOT blank
- Change the visibility of a work, collection, or file set
- Link_to tag with route helpers
- Reindex an item
- Return the current host/tenant
- login and cd into
home/sufia/vault
rails c -e production
AccountElevator.switch! "vault.library.uvic.ca"sudo systemctl restart httpd- pushes changes into production
- remember to also exit and restart the rails console!
- if a job is running, remember to restart sidekiq too
- Change ownership:
sudo chown [username] [file name or path] -R - Change group writing permissions (when logged in as the eponymous user of a group):
sudo chmod g+w [file name or path] -R - See who a group's members are:
groups [group name]or justgroupsto see members of current user's group
- Press
cntrl + l
- recursive = search that directory and all the directories and files it contains
- searches file names as well as the text within those files
grep -rnw path/to/dir -e "search text"- For when you think there's already a method that returns what you want, but you don't remember what it's called
GenericWork.methods.grep(/string/)
- where object is the Collection, GenericWork, or FileSet object:
SolrDocument.find(object.id)
GenericWork.where(member_of_collection_ids_ssim: collection_id)
GenericWork.member_of_collection_ids
Every collection/work/file set presenter needs two parameters:
- a
solr_document, which you can find like this - a current_ability (we'll set this to admin)
Hyrax::CollectionPresenter.new(solr_document, "admin")
Hyrax::WorkShowPresenter.new(solr_document, "admin")
Hyrax::FileSetPresenter.new(solr_document, "admin")
Hyrax.config.iiif_metadata_fields
- This is defined in
lib/hyrax/configuration.rb
fs = FileSet.last # Pick a specific file set or generic work
FileSet.controlled_properties
=> [:creator, :contributor, etc.]- For a generic work:
Hyrax::GenericWorkForm.required_fields - For a file set:
Hyrax::FileSetForm.required_fields - See hyrax list of notable methods
- For a generic work:
Hyrax::GenericWorkForm.primary_terms - For a file set:
Hyrax::FileSetForm.primary_terms - See hyrax list of notable methods
- For a generic work:
Hyrax::GenericWorkForm.secondary_terms - For a file set:
Hyrax::FileSetForm.secondary_terms - See hyrax list of notable methods
- For a generic work:
Hyrax::GenericWorkForm.terms - For a file set:
Hyrax::FileSetForm.terms - See hyrax list of notable methods
- Navigate to a show page for a work or file set
- Copy its ID from the URL
- Go to the Query page in the Solr dashboard
- In
fq, typeid:and then paste in the item ID - Click Query
- Go to the Query page in the Solr dashboard
- In
fq, typehas_model_ssim:and then the model name (e.g.GenericWork,FileSet) - Click Query
- Example: a field called
year_tesim - In the
fqbox:-year_tesim:["" TO *]
- Example: a field called
year_tesim - In the
fqbox:-year_tesim:[* TO *]
- See instructions on how to do this through the interface
- For a generic work, for example:
gw = GenericWork.last
gw.visibility = "open"
gw.save- To make a work private, you would do
gw.visibility = "restricted"andgw.save
- If you are using a helper path that is outside the hyrax namespace (e.g.
toggle_downloads_path), you will have to format thelink_totag like this:
<%= link_to "link text", main_app.toggle_downloads_path(local_variable: value...), remote: true, method: post, class: "some-class" %>- See
views/hyrax/dashboard/collections/_form_discovery.html.erbas an example
-
gw.update_index(same for collections and file sets)
-
request.base_url(for views) orAccount.find_by(tenant: Apartment::Tenant.current).&cname(whererequest.base_urldoesn't work) - As a true/false statement to check which tenant:
-
request.base_url.include? "vault"orAccount.find_by(tenant: Apartment::Tenant.current).&cname.include? "vault"
-