Move JavaScript source into app/assets/javascript

This commit is contained in:
Andreas Nedbal 2023-01-05 13:53:42 +01:00
parent 3157802be9
commit 37d3fc7a55
64 changed files with 137 additions and 23 deletions

View file

@ -1,10 +1,10 @@
import '@hotwired/turbo-rails';
import initialize from './initializers';
import bootstrap from './initializers/bootstrap';
export default function start(): void {
try {
initialize();
bootstrap();
} catch (e) {
// initialization errors
}
}
}

View file

@ -0,0 +1,134 @@
{
"en": {
"frontend": {
"destroy_comment": {
"confirm": {
"text": "You will not be able to recover this comment.",
"title": "Are you sure?"
}
},
"destroy_own": {
"confirm": {
"text": "The question will be removed.",
"title": "Are you sure?"
}
},
"destroy_question": {
"confirm": {
"text": "The question will be moved back to your inbox, but it won't delete any posts to social media.",
"title": "Are you sure?"
}
},
"destroy_report": {
"confirm": {
"text": "You will not be able to recover this report.",
"title": "Are you sure?"
}
},
"error": {
"message": "An error occurred, a developer should check the console for details",
"title": "Uh-oh…"
},
"inbox": {
"confirm": {
"text": "This question will be gone forever.",
"title": "Are you sure?"
},
"confirm_all": {
"text": "They will be gone forever.",
"title": "Are you sure you want to delete %{count} questions?"
},
"empty": "Nothing to see here."
},
"list": {
"confirm": {
"text": "You will not be able to recover this list.",
"title": "Are you sure?"
},
"item": {
"members": {
"one": "1 member",
"other": "%{count} members",
"zero": "No members"
}
}
},
"load": "Load more",
"mod_mute": {
"confirm": {
"text": "This will mute this user for everyone.",
"title": "Are you sure?"
}
},
"push_notifications": {
"inbox": {
"title": "New question from %{user}"
},
"setup_fail": "Failed to set up push notifications. Please try again later.",
"subscribe": {
"fail": {
"body": "Please try again later",
"title": "Failed to subscribe to push notifications"
},
"success": {
"body": "You will now receive push notifications for new questions on this device.",
"title": "Push notifications enabled!"
}
},
"unsubscribe": {
"fail": "Failed to disable push notifications.",
"success": "Push notifications disabled successfully."
}
},
"report": {
"confirm": {
"input": "Specify a reason…",
"text": "A moderator will review your report and decide what happens.\nYou can optionally specify a reason.",
"title": "Are you sure you want to report this %{type}?"
}
},
"subscription": {
"fail": {
"subscribe": "Failed to subscribe to answer.",
"unsubscribe": "Failed to unsubscribe from answer."
},
"subscribe": "Successfully subscribed.",
"unsubscribe": "Successfully unsubscribed."
},
"success": {
"title": "Success!"
}
},
"voc": {
"add": "Add",
"answer": "Answer",
"block": "Block",
"block_site_wide": "Block user site-wide",
"cancel": "Cancel",
"close": "Close",
"confirm": "Are you sure?",
"delete": "Delete",
"edit": "Edit",
"follow": "Follow",
"load": "Load more",
"login": "Sign in",
"logout": "Sign out",
"mute": "Mute",
"n": "No",
"register": "Sign up",
"remove": "Remove",
"report": "Report",
"save": "Save changes",
"show_anonymous_questions": "Show all questions from this user",
"subscribe": "Subscribe",
"terms": "Terms of Service",
"unblock": "Unblock",
"unfollow": "Unfollow",
"unmute": "Unmute",
"unsubscribe": "Unsubscribe",
"update": "Update",
"view_in_rails_admin": "View in Rails Admin",
"y": "Yes"
}
}
}

View file

@ -1,20 +0,0 @@
/**
* Using some JavaScript trickery with require.context
* and default exports, we're basically rebuilding the
* Rails concept of "initializers" in JavaScript.
*
* Every file in this folder exports a default function
* which this index script is loading and executing, so
* we don't have to specify several single import
* statements and can dynamically extend this with as
* many initializers as we see fit.
*/
export default function initialize(): void {
const files = require.context('.', false, /\.ts$/);
files.keys().forEach((key) => {
if (key === './index.ts') return;
if (key.startsWith('./_')) return;
files(key).default();
});
}