Skip to content

Commit

Permalink
Separating the orcid.js from application.js and ensuring that `de…
Browse files Browse the repository at this point in the history
…scribe/` is prefixed to the Webpack manifest paths
  • Loading branch information
jrgriffiniii committed Jul 8, 2022
1 parent 9f33222 commit 43c2e2a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 1 addition & 3 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import Rails from "@rails/ujs"
import Turbolinks from "turbolinks"
import * as ActiveStorage from "@rails/activestorage"
import "channels"
import { isOrcid } from './orcid'
window.isOrcid = isOrcid;

Rails.start()
Turbolinks.start()
ActiveStorage.start()
ActiveStorage.start()
6 changes: 5 additions & 1 deletion app/javascript/packs/orcid.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export function isOrcid(value) {
function isOrcid(value) {
// Notice that we allow for an "X" as the last digit.
// Source https://gist.github.com/asencis/644f174855899b873131c2cabcebeb87
return /^(\d{4}-){3}\d{3}(\d|X)$/.test(value)
};

window.isOrcid = isOrcid;

export { isOrcid };
3 changes: 2 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.1/font/bootstrap-icons.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
Expand All @@ -31,4 +30,6 @@
</div>
<%= render partial: 'shared/footer' %>
</body>
<%= javascript_pack_tag 'orcid', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
<% end %>
2 changes: 1 addition & 1 deletion config/webpacker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default: &default
source_path: app/javascript
source_entry_path: packs
public_root_path: public
public_output_path: packs
public_output_path: describe/packs
cache_path: tmp/cache/webpacker
webpack_compile_output: true

Expand Down

0 comments on commit 43c2e2a

Please sign in to comment.