Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove methods to edit now that we are using baserow for data ingest #41

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.3
3.1.6
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.1.3'
ruby '3.1.6'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.1.7'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ DEPENDENCIES
web-console (>= 3.3.0)

RUBY VERSION
ruby 3.1.3p185
ruby 3.1.6p260

BUNDLED WITH
2.2.28
128 changes: 0 additions & 128 deletions app/controllers/monasteries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,132 +22,4 @@ def index
render_overridable "items", "search_preset", false, res: @res
end

def new
id = generate_id
@res = {
"title" => "",
"date_display" => "",
"spatial" => {
"name" => ""
},
"description" => "",
"relation" => "",
"rdf" => [
{
"subject" => "",
"object" => "",
"predicate" => "",
"source" => "",
"note" => ""
}
]
}
render "monasteries/new"
end

def create
json = JSON.parse(params[:monastery])
id = generate_id
json["identifier"] = id
json["collection"] = "tibetan_monasteries"
json["collection_desc"] = "tibetan_monasteries"
json["category"] = "Monasteries"
json["description"] = params[:description]
json["title"] = params[:title]
json["date_display"] = params[:date_display]
json["date_not_before"] = date_standardize(params[:date_display], false)
json["spatial"]["name"] = params[:spatial_name]
json["relation"] = params[:relation]
rdf = []
idx = 0
# loop through all the numbered keys
while params.has_key?("id_#{idx}") && params["id_#{idx}"].length > 0
figure = {"object" => params[:title]}
name = params["name_#{idx}"]
fig_id = params["id_#{idx}"]
figure["subject"] = "[#{name}](#{fig_id})"
figure["predicate"] = params["predicate_#{idx}"]
figure["source"] = params["source_#{idx}"]
figure["note"] = params["note_#{idx}"]
rdf << figure
idx += 1
end
json["rdf"] = rdf
# below should be refactored into more general helper methods
project_dir = File.join(File.dirname(__FILE__), "..", "..")
# path to the gem's config files
general_config_path = File.join(project_dir, "config")
# at some point I also need to factor into environments, private.yml for passwords
@options = read_config("#{general_config_path}/public.yml")
# auth_header = construct_auth_header(@options)
index_url = File.join(@options["es_path"], @options["es_index"])
RestClient.put("#{index_url}/_doc/#{id}", json.to_json, {:content_type => :json })
redirect_to monasteries_item_path(id)
end

def edit
id = params[:id]
@res = @items_api.get_item_by_id(id)
check_response
@res = @res.first
if @res
url = @res["uri_html"]
@html = Net::HTTP.get(URI.parse(url)) if url
@title = item_title
render "monasteries/edit"
else
@title = t "item.no_item", id: id,
default: "No item with identifier #{id} found!"
render_overridable("items", "show_not_found", false, status: 404)
end
end

def update
json = JSON.parse(params[:monastery])
id = params[:id]
json["description"] = params[:description]
json["title"] = params[:title]
json["date_display"] = params[:date_display]
json["date_not_before"] = date_standardize(params[:date_display], false)
json["spatial"]["name"] = params[:spatial_name]
json["relation"] = params[:relation]
rdf = []
idx = 0
# loop through all the numbered keys
while params.has_key?("id_#{idx}") && params["id_#{idx}"].length > 0
figure = {"object" => params[:title]}
name = params["name_#{idx}"]
fig_id = params["id_#{idx}"]
figure["subject"] = "[#{name}](#{fig_id})"
figure["predicate"] = params["predicate_#{idx}"]
figure["source"] = params["source_#{idx}"]
figure["note"] = params["note_#{idx}"]
rdf << figure
idx += 1
end
json["rdf"] = rdf
# below should be refactored into more general helper methods
project_dir = File.join(File.dirname(__FILE__), "..", "..")
# path to the gem's config files
general_config_path = File.join(project_dir, "config")
# at some point I also need to factor into environments, private.yml for passwords
@options = read_config("#{general_config_path}/public.yml")
#auth_header = construct_auth_header(@options)
index_url = File.join(@options["es_path"], @options["es_index"])
RestClient.put("#{index_url}/_doc/#{id}", json.to_json, {:content_type => :json } )
redirect_to monasteries_item_path(id)
end

private

def generate_id
#query api and determine nubmer of items
options = {
"f" => ["category|Monasteries"]
}
@res = @items_api.query(options)
count = @res.count
"mon_#{count + 1}"
end

end
130 changes: 0 additions & 130 deletions app/controllers/religious_figures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,134 +22,4 @@ def index
render_overridable("items", "search_preset", false)
end

def edit
id = params[:id]
@res = @items_api.get_item_by_id(id)
check_response
@res = @res.first
if @res
url = @res["uri_html"]
@html = Net::HTTP.get(URI.parse(url)) if url
@title = item_title
render "religious_figures/edit"
else
@title = t "item.no_item", id: id,
default: "No item with identifier #{id} found!"
render_overridable("items", "show_not_found", false, status: 404)
end
end

def update
json = JSON.parse(params[:figure])
id = params[:id]
json["description"] = params[:description]
json["title"] = params[:title]
json["date_display"] = params[:date_display]
json["date_not_before"] = date_standardize(params[:date_not_before], false)
json["date_not_after"] = date_standardize(params[:date_not_after], false)
json["spatial"]["name"] = params[:spatial_name]
json["relation"] = params[:relation]
rdf = []
idx = 0
# loop through all the numbered keys
while params.has_key?("name_#{idx}")
figure = {"subject" => params[:title]}
name = params["name_#{idx}"]
fig_id = params["id_#{idx}"]
figure["object"] = "[#{name}](#{fig_id})"
figure["predicate"] = params["predicate_#{idx}"]
figure["source"] = params["source_#{idx}"]
figure["note"] = params["note_#{idx}"]
rdf << figure
idx += 1
end
json["rdf"] = rdf
# below should be refactored into more general helper methods
project_dir = File.join(File.dirname(__FILE__), "..", "..")
# path to the gem's config files
general_config_path = File.join(project_dir, "config")
# at some point I also need to factor into environments, private.yml for passwords
@options = read_config("#{general_config_path}/public.yml")
auth_header = construct_auth_header(@options)
index_url = File.join(@options["es_path"], @options["es_index"])
RestClient.put("#{index_url}/_doc/#{id}", json.to_json, auth_header.merge({:content_type => :json }) )
redirect_to religious_figures_item_path(id)
end

def new
id = generate_id
@res = {
"title" => "",
"date_not_before" => "",
"date_not_after" => "",
"spatial" => {
"name" => ""
},
"description" => "",
"relation" => "",
"rdf" => [
{
"subject" => "",
"object" => "",
"predicate" => "",
"source" => "",
"note" => ""
}
]
}
render "religious_figures/new"
end

def create
json = JSON.parse(params[:figure])
id = generate_id
json["identifier"] = id
json["collection"] = "tibetan_monasteries"
json["collection_desc"] = "tibetan_monasteries"
json["category"] = "Religious Figures"
json["description"] = params[:description]
json["title"] = params[:title]
json["date_not_before"] = date_standardize(params[:date_not_before], false)
json["date_not_after"] = date_standardize(params[:date_not_afterr], false)
json["spatial"]["name"] = params[:spatial_name]
json["relation"] = params[:relation]
rdf = []
idx = 0
# loop through all the numbered keys
while params.has_key?("id_#{idx}") && params["id_#{idx}"].length > 0
figure = {"object" => params[:title]}
name = params["name_#{idx}"]
fig_id = params["id_#{idx}"]
figure["subject"] = "[#{name}](#{fig_id})"
figure["predicate"] = params["predicate_#{idx}"]
figure["source"] = params["source_#{idx}"]
figure["note"] = params["note_#{idx}"]
rdf << figure
idx += 1
end
json["rdf"] = rdf
# below should be refactored into more general helper methods
project_dir = File.join(File.dirname(__FILE__), "..", "..")
# path to the gem's config files
general_config_path = File.join(project_dir, "config")
# at some point I also need to factor into environments, private.yml for passwords
@options = read_config("#{general_config_path}/public.yml")
#auth_header = construct_auth_header(@options)
index_url = File.join(@options["es_path"], @options["es_index"])
RestClient.put("#{index_url}/_doc/#{id}", json.to_json, {:content_type => :json } )
redirect_to religious_figures_item_path(id)
end

private

def generate_id
#query api and determine nubmer of items
options = {
"f" => ["category|Religious Figures"]
}
@res = @items_api.query(options)
count = @res.count
"fig_#{count + 1}"
end

end
1 change: 0 additions & 1 deletion app/views/items/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<h1><%= sanitize @res["title"] %></h1>
<%= render_overridable("items", "edit_link") %>
<%= render_overridable("items", "show_metadata") %>
<%# render_overridable("items", "show_content") %>
43 changes: 0 additions & 43 deletions app/views/monasteries/_form.html.erb

This file was deleted.

3 changes: 1 addition & 2 deletions app/views/monasteries/_index_intro.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<p>Tibetan Buddhist monasteries and the figures that are associated with them.</p>
<%= link_to "new monastery", monasteries_new_path %>
<p>Tibetan Buddhist monasteries and the figures that are associated with them.</p>
1 change: 0 additions & 1 deletion app/views/monasteries/edit.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion app/views/monasteries/items/_edit_link.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion app/views/monasteries/new.html.erb

This file was deleted.

25 changes: 25 additions & 0 deletions config/database.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000

development:
<<: *default
database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3

production:
<<: *default
database: db/production.sqlite3
Loading