Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
246 commits
Select commit Hold shift + click to select a range
673b186
fix MathJax default zoom menu option
papes1ns Mar 13, 2024
5624b2c
Merge branch 'main' of github.com:galahq/gala
papes1ns Mar 13, 2024
66597a2
Merge branch 'main' of github.com:galahq/gala
papes1ns Apr 17, 2024
9d22e90
Merge branch 'main' of github.com:galahq/gala
papes1ns May 1, 2024
53599f2
fix issues assoicated with backspacing to an empty CaseElement card
papes1ns May 8, 2024
d19533d
Merge branch 'main' of github.com:galahq/gala
papes1ns Sep 21, 2024
de1bed7
update case search index views for postgres 16 upgrade
papes1ns Oct 11, 2024
0f6114f
bump redis ~> 5
papes1ns Oct 17, 2024
6d8f880
work with new REDIS TLS requirements
papes1ns Oct 17, 2024
b11a354
follow rubocop rules
papes1ns Oct 17, 2024
8017a42
fix rubocop issues
papes1ns Oct 17, 2024
e7ffd3c
round 3, make rubocop codeclimate happy
papes1ns Oct 17, 2024
37ddcbb
make UpdateCaseSearchIndexForPostgres16 reversible
papes1ns Oct 17, 2024
fc1fc3d
clean migration and wrap the up and down operations in a transaction
papes1ns Oct 17, 2024
ff612dd
checkin structure.sql and reset indices refresh rake task
papes1ns Oct 17, 2024
d596e94
remove unknown configuration parameter: default_table_access_method
papes1ns Oct 17, 2024
6b979a5
fix actioncable errors
papes1ns Oct 18, 2024
b1dc498
bump redis version
papes1ns Oct 18, 2024
fc4f6f2
try Redis 4.1
papes1ns Oct 18, 2024
a60cd11
revert Gemfile back to the main branch
papes1ns Oct 18, 2024
18686fe
remove redis
papes1ns Nov 6, 2024
880e117
old,working gems
papes1ns Nov 6, 2024
f7748d7
ruby gems
papes1ns Nov 6, 2024
5ba6f66
use gem versions from main
papes1ns Nov 6, 2024
b104aec
change perform_now to perform_later to fix translation issues
papes1ns Nov 12, 2024
b1e7430
spike to query a researcher entity in wikidata
papes1ns Nov 14, 2024
e96cea8
Add initial wikidata ui
michaelkli1998 Nov 15, 2024
c85d4a7
dont require redis and sidekiq in Gemfile and routes.rb
papes1ns Nov 15, 2024
f7a9536
fix rubocop code style errors
papes1ns Nov 15, 2024
f199302
Merge branch 'no-redis' of https://github.com/galahq/gala into add-wi…
michaelkli1998 Nov 18, 2024
eefa736
more ui updates
michaelkli1998 Nov 18, 2024
79f8ca8
Hook up api
michaelkli1998 Nov 18, 2024
1ac4afa
update to handle multiple pre-defined schemas
papes1ns Nov 19, 2024
4f8e3de
clean up the sparqler component
papes1ns Nov 19, 2024
b265d68
handle 404 when query returns no results and add loading spinner
papes1ns Nov 19, 2024
10e70b6
add macbook pro example
papes1ns Nov 19, 2024
5510173
use case instead of if/else in wikidata service
papes1ns Nov 19, 2024
78c3d34
add more properties to software schema
papes1ns Nov 20, 2024
587f1df
fix researcher schema
papes1ns Nov 20, 2024
b04f140
More wikidata ui work
michaelkli1998 Nov 20, 2024
414babe
Hook up with new api changes and updated styling
michaelkli1998 Nov 20, 2024
b14b61b
add researchers
michaelkli1998 Nov 20, 2024
a7e11d8
add intent danger callout for 404 responses
papes1ns Nov 21, 2024
345bed7
inital hookup work for db schema and gala api
papes1ns Nov 21, 2024
0d36d57
tweak SortableWikidataList text styles
waisaed Nov 21, 2024
3e8f449
modify font-weight, lowercase, on wikidata list item
waisaed Nov 21, 2024
167ce9d
redux actions and reducers
papes1ns Nov 21, 2024
ca40e34
use updateCase to save wikidata links
papes1ns Nov 21, 2024
cca862a
get wikidataLinks in the redux store
papes1ns Nov 21, 2024
c441f29
Add initial info modal and styling fixes
michaelkli1998 Nov 22, 2024
e4e17eb
hooking up wikidata links to db
papes1ns Nov 22, 2024
b862c06
configure routes to handle wikidata_links like tags
papes1ns Nov 22, 2024
a9eab3c
add extra props to LinkWikidata from CaseKeywords component
papes1ns Nov 22, 2024
6de65fd
a11y for wikidata info button
waisaed Nov 22, 2024
ea8cb13
match wikidata card title link styles
waisaed Nov 22, 2024
4fa3b88
Implement database saves
michaelkli1998 Nov 25, 2024
141055f
implement WikidataLinks#destroy
papes1ns Nov 25, 2024
9054ff0
Merge branch 'add-wikidata-ui' of github.com:galahq/gala into add-wik…
papes1ns Nov 25, 2024
7e2785d
new readonly show view
michaelkli1998 Nov 25, 2024
87e5396
retain wikidata_links order
papes1ns Nov 25, 2024
99db6de
when not editing only show the schemas that have items
papes1ns Nov 25, 2024
aa6b2af
use redux store for WikidataLinks
papes1ns Nov 25, 2024
7df038a
only fire off one query per qid
papes1ns Nov 26, 2024
29938b0
better state transitions
papes1ns Nov 26, 2024
cc56a42
use better styles for wikidata cards
papes1ns Nov 26, 2024
af3408b
fix queried qids that errored
papes1ns Nov 26, 2024
e22e796
add wikidata logo, change font weights
waisaed Nov 26, 2024
2ce5ccd
change wikidata section heading
waisaed Nov 26, 2024
ad9605a
styling updates and fix bug with duplicate entries
michaelkli1998 Nov 26, 2024
18d4016
Add error message for duplicate entries
michaelkli1998 Nov 26, 2024
2d2cc47
use link to guide instead of wikidata info modal
waisaed Nov 26, 2024
baa5a56
Merge branch 'add-wikidata-ui-with-api-updateCase1' of https://github…
michaelkli1998 Nov 27, 2024
8204347
refactors and fixed bug with saving invalid results
michaelkli1998 Nov 27, 2024
caa5f30
styling updates
michaelkli1998 Nov 27, 2024
29c052d
cleanup code
papes1ns Nov 27, 2024
cece6df
Merge branch 'add-wikidata-ui' of github.com:galahq/gala into add-wik…
papes1ns Nov 27, 2024
39a2d03
Add more validation
michaelkli1998 Nov 27, 2024
7a78035
Fix bug with duplicate entry and saving invalid QID's
michaelkli1998 Nov 27, 2024
7d7fbc4
Don't render tag if no value
michaelkli1998 Nov 27, 2024
59b45df
add local and json-ld to sparql wikidata results
papes1ns Nov 30, 2024
8f17c20
add date modified, modify migration, add json ld
papes1ns Nov 30, 2024
2923f36
add json-ld to head
papes1ns Nov 30, 2024
9a4b81a
working gem versions
papes1ns Dec 1, 2024
f29e9d2
turn sentry off for AWS testing
papes1ns Dec 1, 2024
3befc9f
add infra
papes1ns Dec 2, 2024
2726ef1
more infra work for memcached
papes1ns Dec 2, 2024
66ecb7e
add build_and_deploy script
papes1ns Dec 2, 2024
ff55558
add secrets for s3 uploads
papes1ns Dec 2, 2024
ebf94a1
make sidekiq worker work and use jemalloc
papes1ns Dec 2, 2024
84c0a77
improve docker image
papes1ns Dec 2, 2024
048cf29
s3 active storage working
papes1ns Dec 2, 2024
53ee62e
slimmed down docker image and faster docker compose dev env
papes1ns Dec 3, 2024
539e141
show version in footer
papes1ns Dec 3, 2024
903c862
working image uploads with minimagik
papes1ns Dec 3, 2024
316209f
add waf
papes1ns Dec 3, 2024
accc7a8
destroy waf... cant get it working
papes1ns Dec 3, 2024
786ef7a
improve docker performance and image size
papes1ns Dec 3, 2024
974f69a
docker improvements
papes1ns Dec 4, 2024
7d9147b
improve docker stages
papes1ns Dec 4, 2024
8752612
optimized docker env
papes1ns Dec 5, 2024
0bd2502
add pgrestore command
papes1ns Dec 5, 2024
6dd849d
Refactors and bug fixes
michaelkli1998 Dec 4, 2024
5e8ecb0
Merge branch 'add-wikidata-ui' of github.com:galahq/gala into add-wik…
papes1ns Dec 5, 2024
0c415bf
rm package-lock.json
papes1ns Dec 5, 2024
e56a8b2
pin dalli version
papes1ns Dec 5, 2024
2eaa0e2
fixing dalli errors at heroku build time
papes1ns Dec 5, 2024
20880c7
memcache and redis tweaks
papes1ns Dec 5, 2024
fbd6d3c
redis fixes
papes1ns Dec 5, 2024
26cd5d0
fix deps
papes1ns Dec 5, 2024
d9bce26
fix action cable
papes1ns Dec 5, 2024
e89d792
add ssl verify none to action cable config
papes1ns Dec 5, 2024
1bee4b7
fix action cable
papes1ns Dec 5, 2024
ca5fd7d
Fix conditional styling for input field and error state
michaelkli1998 Dec 5, 2024
1d4a964
add sidekiq admin endpoint back
papes1ns Dec 5, 2024
8ee6471
update infra
papes1ns Dec 6, 2024
6ab9ccf
update infra
papes1ns Dec 6, 2024
029ed67
action cable fixes
papes1ns Dec 6, 2024
0a56fb8
Merge branch 'add-wikidata-ui' of github.com:galahq/gala into aws-inf…
papes1ns Dec 6, 2024
7adb6e8
add wikidata search prototype
papes1ns Dec 6, 2024
1809029
add healthcheck endpoint for ecs
papes1ns Dec 6, 2024
c919cef
add wikidata search
papes1ns Dec 6, 2024
da1ba8a
fix production merge error
papes1ns Dec 6, 2024
e4fc26a
fix migratiion issues
papes1ns Dec 6, 2024
ec99e41
show semver in release script
papes1ns Dec 6, 2024
2b7c84e
add SearchWikidata component
papes1ns Dec 7, 2024
aaa787d
get typeahead working
papes1ns Dec 7, 2024
cce1b98
fix issue that would lock up main js thread
papes1ns Dec 10, 2024
b71d514
make search wikidata more efficient
papes1ns Dec 12, 2024
16134be
remove console logs and fix typo in Dockerfile
papes1ns Dec 27, 2024
f1c66e1
validate react_router_location params
papes1ns Dec 27, 2024
e1d4815
upgrade to rails 7.0.8.7, ruby 3.1.6, debian 12
papes1ns Jan 5, 2025
139be5b
fix number comparision in entrypoint.sh
papes1ns Jan 5, 2025
9b2ff39
fix duplicate key error :ml
papes1ns Jan 5, 2025
183d22f
rails 7.0.x upgrade
papes1ns Jan 5, 2025
2927e58
update mobility gem
papes1ns Jan 6, 2025
fefc906
fix syntax errors
papes1ns Jan 6, 2025
b859ed9
fix cloners
papes1ns Jan 6, 2025
4468de4
rails 7 updater
papes1ns Jan 6, 2025
727ce6a
remove console.logs and empty file
papes1ns Jan 6, 2025
8956d45
fix pdf archive generation
papes1ns Jan 6, 2025
ea41d7f
fix deployments
papes1ns Jan 6, 2025
e310991
fix structure.sql and update semaphore
papes1ns Jan 6, 2025
5c0cfe1
fix semaphore machine type
papes1ns Jan 6, 2025
002b29a
change machine type to be compatible with ubunut2204\n\nhttps://docs.…
papes1ns Jan 6, 2025
2fa1e00
add rails 3.1.6 support to code climate
papes1ns Jan 6, 2025
23bf465
fix draper kwargs error
papes1ns Jan 7, 2025
7233488
fix rails tests, update rspec gems
papes1ns Jan 7, 2025
73a177e
add edgenote tests back
papes1ns Jan 7, 2025
659ea65
change semaphore os and heroku-22
papes1ns Jan 7, 2025
0675747
add libssl-dev to semaphore ci
papes1ns Jan 7, 2025
f859cde
add libssl1.1 to semaphore
papes1ns Jan 7, 2025
9f6189e
re-install native puma extensions ubuntu 22
papes1ns Jan 7, 2025
c17d9a2
fix ruby 3 kwargs
papes1ns Jan 7, 2025
62b2fd9
ci fix
papes1ns Jan 7, 2025
bc69126
semaphor ci updates
papes1ns Jan 7, 2025
29e9338
use bundle exec rake test:unit to run rails unit tests
papes1ns Jan 7, 2025
82a8d09
add missing rexml dep
papes1ns Jan 7, 2025
11b4f77
make heroku buildpack smaller
papes1ns Jan 7, 2025
2f50cd1
revert npm packages to make build smaller
papes1ns Jan 7, 2025
a207be7
fix heroku s3 error
papes1ns Jan 7, 2025
5a92f64
update active_storage_validations gem
papes1ns Jan 7, 2025
b139ef2
update production puma config
papes1ns Jan 7, 2025
0cead0b
fix ci tests
papes1ns Jan 7, 2025
1f99567
remove barnes gem
papes1ns Jan 7, 2025
aeddbae
no more barnes refs
papes1ns Jan 7, 2025
f306baa
upgrade aws s3 gem
papes1ns Jan 7, 2025
254b476
add .slugcleanup to get build slugs under 500mb
papes1ns Jan 8, 2025
cccffaa
ruby 3.2.6, update Aptfile for heroku
papes1ns Jan 8, 2025
3720ebe
fix heroku builds
papes1ns Jan 8, 2025
f81c8b9
truncate Aptfile
papes1ns Jan 8, 2025
0e73d28
deploy to staging heroku-22
papes1ns Jan 8, 2025
df574d0
change back to ruby 3.1.6
papes1ns Jan 8, 2025
7fdb4ab
make build size smaller
papes1ns Jan 8, 2025
14461d7
revert to under Gemfile
papes1ns Jan 8, 2025
5944c36
make buildpack smaller
papes1ns Jan 8, 2025
bf2d320
make build pack smaller
papes1ns Jan 8, 2025
9c8e805
comment out profile
papes1ns Jan 8, 2025
d82a714
slugignore update
papes1ns Jan 8, 2025
a752b76
revert puma.rb to default
papes1ns Jan 8, 2025
9eab789
keep :tmp_restart enabled
papes1ns Jan 8, 2025
a076802
rm slugclean files
papes1ns Jan 8, 2025
c30b25a
rm slugclean files
papes1ns Jan 8, 2025
7f6bf34
more gem updates
papes1ns Jan 8, 2025
66f27b7
Merge branch 'ruby3-1-6_rails7-0_deb12' of github.com:galahq/gala int…
papes1ns Jan 8, 2025
0ba3e92
fix kwarg errors in image decorator
papes1ns Jan 9, 2025
1e0caf0
enable yjit and jemalloc
papes1ns Jan 9, 2025
be06a94
upgrade to ruby 3.2.6 round2
papes1ns Jan 9, 2025
cf8e943
update ruby to 3.2.6
papes1ns Jan 9, 2025
6254697
fix kwargs syntax
papes1ns Jan 9, 2025
273d931
ability to run production mode in docker
papes1ns Jan 9, 2025
cb18d23
use jemalloc and yjit for memory and perf benefits
papes1ns Jan 9, 2025
acd8cc2
Merge branch 'main' of github.com:galahq/gala into ruby3-1-6_rails7-0…
papes1ns Jan 9, 2025
9a81f6e
update semaphore ruby version and gems
papes1ns Jan 9, 2025
c550738
fix paginator
papes1ns Jan 9, 2025
a9e5534
install wkhtmltopdf via apt
papes1ns Jan 9, 2025
ccaf216
rm -wkhtmltopdf from Aptfile in favor of a buildpack
papes1ns Jan 9, 2025
2ea012c
wkhtmltopdf issue
papes1ns Jan 9, 2025
66e5f3e
fix image optimizers for libvips
papes1ns Jan 9, 2025
5fd9294
change codeclimate rubocop
papes1ns Jan 9, 2025
a9b23ca
fix stale pdfs
papes1ns Jan 10, 2025
c32a577
fix libvips jpeg optomizations in edgenotes
papes1ns Jan 10, 2025
82a226e
clowne fixes
papes1ns Jan 11, 2025
67af78e
restore cloners
papes1ns Jan 11, 2025
4d86967
add flow annotations
papes1ns Jan 11, 2025
ed340d9
use semaphore.yml from main
papes1ns Jan 11, 2025
64b9035
fix administrate copy button
papes1ns Jan 11, 2025
6690c71
semaphore update
papes1ns Jan 12, 2025
97139c3
semaphore updates
papes1ns Jan 12, 2025
1e5d823
semaphore pipeline round 2
papes1ns Jan 12, 2025
f425181
semaphore round 3 debug lines
papes1ns Jan 12, 2025
de34e15
semphore upgrades
papes1ns Jan 12, 2025
4fd708e
fix .semaphore machine_type
papes1ns Jan 12, 2025
cde6db5
semaphore updates
papes1ns Jan 12, 2025
3f7c16a
less noise in semaphore
papes1ns Jan 12, 2025
fbe5607
fix code climate issue
papes1ns Jan 12, 2025
24ece18
use administrate 0.17.0 to work with sassc
papes1ns Jan 12, 2025
066fc32
update administrate gem and ensure clowners are working correctly
papes1ns Jan 12, 2025
d9ddb37
remove system call for rake test:unit task
papes1ns Jan 12, 2025
2f765c5
match rubocop version in codeclimate with Gemfile.lock
papes1ns Jan 12, 2025
4cb352f
Merge branch 'route_validation' of github.com:galahq/gala into ruby3-…
papes1ns Jan 12, 2025
1c06ef3
fix podcast cards when cloning
papes1ns Jan 12, 2025
00a4d97
initial wikidata merge
papes1ns Jan 13, 2025
ef5a23c
change development to use sidekiq
papes1ns Jan 13, 2025
f814d66
Merge branch 'main' of github.com:galahq/gala into wikidata_demo
papes1ns Feb 17, 2025
7b36e5c
experiment using github releases again
papes1ns Feb 17, 2025
313337e
fix Gemfile.lock
papes1ns Feb 17, 2025
d1e6350
add unconfirmed access env var to gala dev and staging to show/hide
papes1ns Feb 17, 2025
486a4a3
grey out google oauth buttons instead of hiding them out in staging and
papes1ns Feb 17, 2025
8179c62
Merge branch 'main' of github.com:galahq/gala into wikidata_demo
papes1ns Mar 14, 2025
ca30e28
clean up the frontend wikidata code to make it more performant and no…
papes1ns Mar 14, 2025
c4417b2
add schema js file for the support categories in the frontend
papes1ns Mar 14, 2025
5815813
improve search box feedback
waisaed Mar 13, 2025
e252328
show url for successful search
waisaed Mar 13, 2025
4e79805
Remove sparqler file
papes1ns Mar 19, 2025
c48af78
use tags for viewing wikidata links
waisaed Apr 14, 2025
7ce8260
scaffold add wikidata dialog
waisaed Apr 25, 2025
ac4a185
search by name or qid in SearchWikidata dialog
waisaed Apr 29, 2025
67a9633
don't crash when fetch fails and cached_json is nil
waisaed Apr 29, 2025
e5f8b1b
validate mismatched schemas in search
waisaed May 1, 2025
5ed9114
remove old 'add wikidata' logic
waisaed May 9, 2025
0e9e31c
add info boxes for wikidata links
Jun 3, 2025
751ec2b
add i18n to SearchWikidata
Jun 10, 2025
f19f9cc
avoid unrecognized prop error on Select
Jun 10, 2025
4f95b9e
fix select overflow
Jun 11, 2025
f84b957
tweak link preview
Jun 13, 2025
e852a65
validate suggested Qids
Jun 26, 2025
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ spec/examples.txt
.env.dev

# Ignore vscode settings
/.vscode
/.vscode
infrastructure
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ ENV BUNDLE_PATH="/usr/local/bundle" \
RUN apt-get update && apt-get install -y \
wget gnupg2 build-essential curl python3 wkhtmltopdf \
libvips git pkg-config libjemalloc-dev lsb-release zlib1g-dev \
libffi-dev libyaml-dev libreadline-dev libssl-dev postgresql-client libpq-dev gcc make \
libffi-dev libyaml-dev libreadline-dev libssl-dev gcc make \
&& sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt-get update \
&& apt-get install -y postgresql-client-16 libpq-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ gem 'barnes', require: false
gem 'email_reply_parser'
gem 'opengraph_parser'
gem 'ruby-oembed'
gem 'sparql-client'

# To seed the database for Heroku review apps, this is included in production
gem 'factory_bot_rails'
Expand Down
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ GEM
multi_json (~> 1)
statsd-ruby (~> 1.1)
base64 (0.2.0)
bcp47_spec (0.2.1)
bcrypt (3.1.20)
bigdecimal (3.1.8)
bindex (0.8.1)
Expand Down Expand Up @@ -300,6 +301,7 @@ GEM
addressable (~> 2.7)
letter_opener (1.7.0)
launchy (~> 2.2)
link_header (0.0.8)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand Down Expand Up @@ -337,6 +339,8 @@ GEM
multi_xml (0.6.0)
multipart-post (2.1.1)
nenv (0.3.0)
net-http-persistent (4.0.5)
connection_pool (~> 2.2)
net-imap (0.5.5)
date
net-protocol
Expand Down Expand Up @@ -450,6 +454,10 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rdf (3.3.2)
bcp47_spec (~> 0.2)
bigdecimal (~> 3.1, >= 3.1.5)
link_header (~> 0.0, >= 0.0.8)
redcarpet (3.6.0)
redis (5.3.0)
redis-client (>= 0.22.0)
Expand Down Expand Up @@ -539,6 +547,9 @@ GEM
logger
rack (>= 2.2.4)
redis-client (>= 0.22.2)
sparql-client (3.3.0)
net-http-persistent (~> 4.0, >= 4.0.2)
rdf (~> 3.3)
spring (4.2.1)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
Expand Down Expand Up @@ -691,6 +702,7 @@ DEPENDENCIES
sentry-raven (~> 3.1)
shoulda-matchers (~> 4.5)
sidekiq (~> 7.0)
sparql-client
spring
spring-commands-rspec
spring-watcher-listen
Expand Down
20 changes: 20 additions & 0 deletions app/controllers/sparql_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

# @see Wikidata
class SparqlController < ApplicationController
# @route [GET] `/sparql/:schema/:qid`
def show
wikidata = Wikidata.new I18n.locale
result = wikidata.canned_query params[:schema], params[:qid]
head :not_found and return if result.nil?
render json: result
end

# @route [GET] `/sparql?query&schema`
def index
wikidata = Wikidata.new I18n.locale
result = wikidata.search params[:query], params[:schema]
head :not_found and return if result.nil?
render json: result
end
end
50 changes: 50 additions & 0 deletions app/controllers/wikidata_links_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

# @see Wikidatalink
class WikidataLinksController < ApplicationController
include BroadcastEdits
include VerifyLock

before_action :authenticate_reader!
before_action :set_case
before_action -> { verify_lock_on @case }

broadcast_edits to: :@case, type: :update

# @route [POST] `/cases/case-slug/wikidata_links`
def create
authorize @case, :update?
link_params = wikidata_links_params
wikidata_link = @case.wikidata_links.find_or_initialize_by(
schema: link_params[:schema], qid: link_params[:qid])

wikidata_link.assign_attributes(link_params.merge(record_type: 'Case', record_id: @case.id))
wikidata_link.fetch_and_update_data!

if wikidata_link.save
render json: wikidata_link,
status: wikidata_link.new_record? ? :created : :ok
else
render json: { errors: wikidata_link.errors.full_messages },
status: :unprocessable_entity
end
end

# @route [DELETE] `/cases/case-slug/wikidata_links/id`
def destroy
authorize @case, :update?
wikidata_link = @case.wikidata_links.find_by id: params[:id]
wikidata_link&.destroy
head :no_content
end

private

def wikidata_links_params
params.require(:wikidata_link).permit(:qid, :position, :schema)
end

def set_case
@case = Case.friendly.find params[:case_slug]
end
end
5 changes: 5 additions & 0 deletions app/javascript/images/wikidata-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 17 additions & 2 deletions app/javascript/overview/Billboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import LearningObjectives from './LearningObjectives'
import CaseKeywords from './CaseKeywords'
import TranslationLinks from './TranslationLinks'
import TeachingGuide from './TeachingGuide'

import LinkWikidata from '../wikidata/LinkWikidata'
import asyncComponent from 'utility/asyncComponent'
import { updateCase } from 'redux/actions'

import type { State, Case, Tag, Viewport } from 'redux/state'
import type { State, Case, Tag, Viewport, WikidataLink } from 'redux/state'

const MapView = asyncComponent(() => import('map_view').then(m => m.default))

Expand All @@ -37,6 +37,7 @@ function mapStateToProps ({ caseData, edit }: State) {
tags,
links,
teachingGuideUrl,
wikidataLinks,
} = caseData

return {
Expand All @@ -50,8 +51,10 @@ function mapStateToProps ({ caseData, edit }: State) {
slug,
summary,
taggingsPath: links.taggings,
wikidataLinksPath: links.wikidataLinks,
tags,
teachingGuideUrl,
wikidataLinks,
}
}

Expand All @@ -66,8 +69,10 @@ type Props = {
slug: string,
summary: string,
taggingsPath: string,
wikidataLinksPath: string,
tags: Tag[],
teachingGuideUrl: string,
wikidataLinks: WikidataLink[],
updateCase: typeof updateCase,
}

Expand All @@ -82,8 +87,10 @@ const Billboard = ({
slug,
summary,
taggingsPath,
wikidataLinksPath,
tags,
teachingGuideUrl,
wikidataLinks,
updateCase,
}: Props) => (
<Container>
Expand Down Expand Up @@ -169,6 +176,14 @@ const Billboard = ({
onChange={(tags: Tag[]) => updateCase({ tags })}
/>

<LinkWikidata
editing={editing}
key={wikidataLinksPath}
wikidataLinksPath={wikidataLinksPath}
wikidataLinks={wikidataLinks}
onChange={(wikidataLinks: WikidataLink[]) => updateCase({ wikidataLinks }, false)}
/>

{readerSignedIn && (
<MinimalLink href={caseData.links.archive}>
<FormattedMessage id="archives.show.printableArchive" />
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/redux/actions/editing.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ async function saveModel (endpoint: string, state: State): Promise<Object> {
latitude,
longitude,
zoom,
wikidataLinks,
} = state.caseData
data = {
case: {
Expand All @@ -114,6 +115,7 @@ async function saveModel (endpoint: string, state: State): Promise<Object> {
latitude,
longitude,
zoom,
wikidataLinks,
coverUrl: baseCoverUrl,
},
}
Expand Down
1 change: 1 addition & 0 deletions app/javascript/redux/reducers/caseData.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Action =
| SetForumsAction
| ToggleEditingAction

// TODO this is how the inital caseData state is set
export default function caseData (
state: CaseDataState = ({ ...window.caseData }: CaseDataState),
action: Action
Expand Down
21 changes: 20 additions & 1 deletion app/javascript/redux/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ export type Byline = {
acknowledgements: string,
}

export type WikidataLink = {
id?: string,
schema: string,
qid: string,
position: number,
data?: SparqlResult,
}

export type SparqlResult = {
entity: string,
entityLabel: string,
schema: string,
properties: {
[string]: string,
}[],
}

export type Card = {
commentThreads: ?(CommentThread[]),
editorState: ?EditorState,
Expand Down Expand Up @@ -153,9 +170,10 @@ export type Case = {
self: string,
settings: string,
taggings: string,
wikidataLinks: string,
teach: string,
teachingGuide: string,
newCopy: string
newCopy: string,
},
longitude: ?number,
otherAvailableLocales: { [string]: { link: string, name: string } },
Expand All @@ -168,6 +186,7 @@ export type Case = {
teachingGuideUrl: ?string,
title: string,
zoom: ?number,
wikidataLinks: WikidataLink[],
} & Byline

export type CaseElement = {
Expand Down
93 changes: 93 additions & 0 deletions app/javascript/wikidata/AddWikidata.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* @providesModule AddWikidata
* @flow
*/

import * as React from 'react'
import { FormattedMessage } from 'react-intl'
import styled from 'styled-components'
import type { WikidataLink } from 'redux/state'
import SortableWikidataList, {
createSortableInput,
} from './SortableWikidataList'

type Props = {
editing: boolean,
schema: string,
editing: boolean,
onChange: (wikidataLinks: WikidataLink[]) => mixed,
wikidataLinks: WikidataLink[],
wikidataLinksPath: string,
}

const AddWikidata = ({
editing,
schema,
onChange,
wikidataLinks,
wikidataLinksPath,
}: Props): React.Node => {
const items = wikidataLinks.filter(link => link.schema === schema)

const handleChange = (updates: WikidataLink[]) => {
const updatedLinks = [
...wikidataLinks.filter(link => link.schema !== schema),
...updates,
]
onChange(updatedLinks)
}

if (!editing && items.length === 0) {
return null
}

return (
<Container>
<div className="pt-dark">
<div className="wikidata-item-title">
<FormattedMessage id={`catalog.wikidata.${schema}`} />
</div>
<SortableWikidataList
dark
editing={editing}
items={items}
newItem={{ id: '', qid: '', schema, position: items.length }}
render={(props, index) => (
<WikiDataInput {...props} schema={schema} index={index} />
)}
wikidataLinksPath={wikidataLinksPath}
schema={schema}
onChange={handleChange}
/>
</div>
</Container>
)
}

const Container = styled.div`
display: flex;
flex-direction: column;

.wikidata-item-title {
display: flex;
align-items: center;
gap: 6px;
color: #ebeae3;
font-size: 14px;
font-weight: 400;
margin-bottom: 2px;
}

.wikidata-instructions {
font-size: 13px;
color: #ebeae3;
opacity: 0.6;
margin-top: -8px;
}
`

const WikiDataInput = createSortableInput({
placeholderId: 'catalog.wikidata.wikidataPlaceholder',
})

export default AddWikidata
Loading