Skip to content

Instantly share code, notes, and snippets.

@mankind
mankind / gist:b686f12691d0ed9649fa25141c6934d0
Created July 26, 2021 16:32
Setting up Hyku Addons Account

Setting up Hyku Addons from scratch

Deleting existing system

If already exists and you want to start fresh DANGER: This will kill it all including data

docker-compose down
docker-compose system prune
@mankind
mankind / chunk_file_doc.md
Created August 9, 2019 14:25 — forked from ashikajith/chunk_file_doc.md
Chunk File Upload Doc

File Chunk Upload

To support large file upload we need to segregate the file to different chunks and we will be sending each chunk in a single request to the server. Once they recieve the complete chunk, we will combine the chunk to get the actual file.

Following are the steps we followed to implement the feature.

@mankind
mankind / mailer_report_doc.md
Created August 9, 2019 14:25 — forked from ashikajith/mailer_report_doc.md
Mailer Report Doc

Mailer Report

For the mailer report we have WorkReportMailer which acts as the controller of the Application Mailer. The mailer is called in the ExportController file.

  def send_mail_report
    emails = process_email
    emails.each do |email|
      WorkReportMailer.send_report(email.strip, current_account.cname, params[:email_type]).deliver_later
    end
 redirect_to hyrax.admin_stats_path(anchor: 'email_reports')
@mankind
mankind / mask_s3_url.md
Created August 9, 2019 14:24 — forked from ashikajith/mask_s3_url.md
Masking S3 URL

S3 Masking URL

For masking the url we created a seperate routes, controller to fetch the record and generate the url for the download file.

  app/controllers/ubiquity/fail_uploads_controller.rb
  
  def download_file
    params[:fileset_id]
    uuid = params[:uuid]
 s3_file_set_url = Ubiquity::ImporterClient.get_s3_url uuid

RIF Doc

For Rif template all the fileds have unique codes and we represent eah codes to the corresponding value. Following are the steps we follow to generate the report

  • Fetch the corresponding work from the controller CitationExportsController (app/controllers/ubiquity/citation_exports_controller.rb) and process the fetched record to render in RIF fromat.
  • A Controller Concern is added to handle the processing of data in Rif format (app/controllers/concerns/ubiquity/citations_export_concern.rb)

Basically we have a hash which consist of code and the fields that needs to map. Please find the hash below

@mankind
mankind / oai_export_doc.md
Created August 9, 2019 14:24 — forked from ashikajith/oai_export_doc.md
OAI Export Feature

OAI Export

For OAI we are using the BlackLightOaiProvider gem (https://github.com/projectblacklight/blacklight_oai_provider) which harvest the data automatically once it is configured in the catalog controller. We have divided into two phases.

We do have an ENV variable which acts as a switch to enable this feature .

ENABLE_OAI_METADATA: 'true'
Loading development environment (Rails 4.0.0)
2.0.0-p247 :001 > Date.today
=> Thu, 26 Sep 2013
2.0.0-p247 :002 > Date.tomorrow
=> Thu, 26 Sep 2013
@mankind
mankind / soft_delete.rb
Created October 5, 2013 08:46 — forked from brianjlandau/soft_delete.rb
This is a soft delete mixin for ActiveRecord 3.x. All you need to do is add a `deleted_at` column to the ActiveRecord models you mix this into.
module SoftDelete
extend ActiveSupport::Concern
included do
define_model_callbacks :soft_delete
define_model_callbacks :recover
default_scope where(:deleted_at => nil)
class_eval do
class << self
alias_method :with_deleted, :unscoped
@mankind
mankind / ImageUploader
Created August 17, 2011 12:07 — forked from ahamid/ImageUploader
CarrierWave mixed content upload processing
require 'carrierwave/processing/mini_magick'
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
IMAGE_EXTENSIONS = %w(jpg jpeg gif png)
DOCUMENT_EXTENSIONS = %w(exe pdf doc docm xls)
def store_dir
"files/#{model.id}"
@mankind
mankind / mongo_replication.rb
Created June 6, 2011 18:52
Sets up replication based on node[:mongodb][:repl_set]
# Install the MongoDB gem
%w{ mongo bson_ext }.each do |mongo_gem|
gem_install = gem_package mongo_gem do
action :nothing
end
gem_install.run_action(:install)
end
Gem.clear_paths
require 'mongo'