A gem that generates meta tags for google scholar (or any other tags you might want)
Add this line to your application's Gemfile:
gem 'schoolie'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install schoolie
Install your schoolie configuration file in config/schoolie.yml
This file should contain contents similar to this:
---
static:
citation_institution: Your University
attributes:
citation_title: title
citation_author: creator
citation_date: publication_date
citation_keywords: keywords
citation_pdf_url: permanent_url
The 'static' section will be written directly into the meta tags as is, attributes will be sent as method calls to the current curation concern object, and the value thus returned will be written into the meta tag.
Missing methods will be ignored.
bundle exec rails schoolie:sitemap
The 'static' section maps a particular meta tag name to a static string
The attributes section maps meta tag names to methods that will be
called on whatever you pass into the schoolie_tags
helper.
If the method does not exist, the tag will not be generated (though no error will be thrown).
Call the helper like any other helper in your view:
<%= schoolie_tags my_object %>
That's all there is to it!
If you'd like to generate a sitemap for your Hyrax-based application, a simple rake task can be used (not included in schoolie):
task sitemap: :environment do
date_field = 'system_modified_dtsi'
result = ActiveFedora::SolrService.query("has_model_ssim:MyModel",
fq: "selectin_criteria:here",
fl: "id,#{date_field}",
sort: "sort_field,sortfield ASC",
rows: 20_000)
ids = result.map do |x|
["https://etd.example.com/concern/theses/#{x['id']}", x[date_field].to_s]
end
builder = Nokogiri::XML::Builder.new do |sitemap|
sitemap.urlset("xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9",
"xsi:schemaLocation": "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd") {
ids.each { |url, date|
sitemap.url {
sitemap.loc url
sitemap.lastmod date
}
}
}
end
File.open(Rails.root.join("public", "sitemap.xml"), "w") { |f| f.write(builder.to_xml) }
end
Don't forget to add your sitemap url to robots.txt too!
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/schoolie. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the Apache 2.0 License.