mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-09 00:24:08 +00:00
Remove APA as cite format
This removes APA as cite format, because it depends on an copyleft
dependency (https://github.com/Juris-M/citeproc-js).
(cherry picked from commit 7dc0b2bab6
)
This commit is contained in:
parent
7c434c4e27
commit
e45c409c20
21
package-lock.json
generated
21
package-lock.json
generated
|
@ -7,7 +7,6 @@
|
|||
"dependencies": {
|
||||
"@citation-js/core": "0.7.9",
|
||||
"@citation-js/plugin-bibtex": "0.7.9",
|
||||
"@citation-js/plugin-csl": "0.7.9",
|
||||
"@citation-js/plugin-software-formats": "0.6.1",
|
||||
"@claviska/jquery-minicolors": "2.3.6",
|
||||
"@github/markdown-toolbar-element": "2.2.3",
|
||||
|
@ -317,21 +316,6 @@
|
|||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@citation-js/plugin-csl": {
|
||||
"version": "0.7.9",
|
||||
"resolved": "https://registry.npmjs.org/@citation-js/plugin-csl/-/plugin-csl-0.7.9.tgz",
|
||||
"integrity": "sha512-mbD7CnUiPOuVnjeJwo+d0RGUcY0PE8n01gHyjq0qpTeS42EGmQ9+LzqfsTUVWWBndTwc6zLRuIF1qFAUHKE4oA==",
|
||||
"dependencies": {
|
||||
"@citation-js/date": "^0.5.0",
|
||||
"citeproc": "^2.4.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@citation-js/core": "^0.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@citation-js/plugin-github": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@citation-js/plugin-github/-/plugin-github-0.6.1.tgz",
|
||||
|
@ -3673,11 +3657,6 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/citeproc": {
|
||||
"version": "2.4.63",
|
||||
"resolved": "https://registry.npmjs.org/citeproc/-/citeproc-2.4.63.tgz",
|
||||
"integrity": "sha512-68F95Bp4UbgZU/DBUGQn0qV3HDZLCdI9+Bb2ByrTaNJDL5VEm9LqaiNaxljsvoaExSLEXe1/r6n2Z06SCzW3/Q=="
|
||||
},
|
||||
"node_modules/clean-regexp": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz",
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
"dependencies": {
|
||||
"@citation-js/core": "0.7.9",
|
||||
"@citation-js/plugin-bibtex": "0.7.9",
|
||||
"@citation-js/plugin-csl": "0.7.9",
|
||||
"@citation-js/plugin-software-formats": "0.6.1",
|
||||
"@claviska/jquery-minicolors": "2.3.6",
|
||||
"@github/markdown-toolbar-element": "2.2.3",
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
<button class="ui citation button" id="citation-copy-apa" data-text="">
|
||||
APA
|
||||
</button>
|
||||
<button class="ui citation button" id="citation-copy-bibtex" data-text="">
|
||||
<span class="ui citation label primary" id="citation-copy-bibtex" data-text="">
|
||||
BibTeX
|
||||
</button>
|
||||
</span>
|
||||
<!-- the value will be updated by initCitationFileCopyContent, the code below is used to avoid UI flicking -->
|
||||
<input id="citation-copy-content" value="" size="1" readonly>
|
||||
<button class="ui icon button" id="citation-clipboard-btn" data-tooltip-content="{{ctx.Locale.Tr "copy"}}" data-clipboard-target="#citation-copy-content">
|
||||
|
|
|
@ -2084,11 +2084,6 @@ td .commit-summary {
|
|||
line-height: 1.4;
|
||||
}
|
||||
|
||||
#cite-repo-modal #citation-panel .citation.button {
|
||||
font-size: 13px;
|
||||
padding: 7.5px 5px;
|
||||
}
|
||||
|
||||
#cite-repo-modal #citation-panel #citation-copy-content {
|
||||
border-radius: 0;
|
||||
padding: 5px 10px;
|
||||
|
@ -2097,8 +2092,9 @@ td .commit-summary {
|
|||
flex: 1;
|
||||
}
|
||||
|
||||
#cite-repo-modal #citation-panel #citation-copy-apa,
|
||||
#cite-repo-modal #citation-panel #citation-copy-bibtex {
|
||||
font-size: 13px;
|
||||
padding: 7.5px 5px;
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,11 @@ import {getCurrentLocale} from '../utils.js';
|
|||
|
||||
const {pageData} = window.config;
|
||||
|
||||
async function initInputCitationValue(citationCopyApa, citationCopyBibtex) {
|
||||
async function initInputCitationValue(inputContent) {
|
||||
const [{Cite, plugins}] = await Promise.all([
|
||||
import(/* webpackChunkName: "citation-js-core" */'@citation-js/core'),
|
||||
import(/* webpackChunkName: "citation-js-formats" */'@citation-js/plugin-software-formats'),
|
||||
import(/* webpackChunkName: "citation-js-bibtex" */'@citation-js/plugin-bibtex'),
|
||||
import(/* webpackChunkName: "citation-js-csl" */'@citation-js/plugin-csl'),
|
||||
]);
|
||||
const {citationFileContent} = pageData;
|
||||
const config = plugins.config.get('@bibtex');
|
||||
|
@ -16,30 +15,16 @@ async function initInputCitationValue(citationCopyApa, citationCopyBibtex) {
|
|||
config.constants.fieldTypes.version = ['field', 'literal'];
|
||||
const citationFormatter = new Cite(citationFileContent);
|
||||
const lang = getCurrentLocale() || 'en-US';
|
||||
const apaOutput = citationFormatter.format('bibliography', {template: 'apa', lang});
|
||||
const bibtexOutput = citationFormatter.format('bibtex', {lang});
|
||||
citationCopyBibtex.setAttribute('data-text', bibtexOutput);
|
||||
citationCopyApa.setAttribute('data-text', apaOutput);
|
||||
inputContent.value = bibtexOutput;
|
||||
}
|
||||
|
||||
export async function initCitationFileCopyContent() {
|
||||
const defaultCitationFormat = 'apa'; // apa or bibtex
|
||||
|
||||
if (!pageData.citationFileContent) return;
|
||||
|
||||
const citationCopyApa = document.getElementById('citation-copy-apa');
|
||||
const citationCopyBibtex = document.getElementById('citation-copy-bibtex');
|
||||
const inputContent = document.getElementById('citation-copy-content');
|
||||
|
||||
if ((!citationCopyApa && !citationCopyBibtex) || !inputContent) return;
|
||||
|
||||
const updateUi = () => {
|
||||
const isBibtex = (localStorage.getItem('citation-copy-format') || defaultCitationFormat) === 'bibtex';
|
||||
const copyContent = (isBibtex ? citationCopyBibtex : citationCopyApa).getAttribute('data-text');
|
||||
inputContent.value = copyContent;
|
||||
citationCopyBibtex.classList.toggle('primary', isBibtex);
|
||||
citationCopyApa.classList.toggle('primary', !isBibtex);
|
||||
};
|
||||
if (!inputContent) return;
|
||||
|
||||
document.getElementById('cite-repo-button')?.addEventListener('click', async (e) => {
|
||||
const dropdownBtn = e.target.closest('.ui.dropdown.button');
|
||||
|
@ -47,22 +32,11 @@ export async function initCitationFileCopyContent() {
|
|||
|
||||
try {
|
||||
try {
|
||||
await initInputCitationValue(citationCopyApa, citationCopyBibtex);
|
||||
await initInputCitationValue(inputContent);
|
||||
} catch (e) {
|
||||
console.error(`initCitationFileCopyContent error: ${e}`, e);
|
||||
return;
|
||||
}
|
||||
updateUi();
|
||||
|
||||
citationCopyApa.addEventListener('click', () => {
|
||||
localStorage.setItem('citation-copy-format', 'apa');
|
||||
updateUi();
|
||||
});
|
||||
|
||||
citationCopyBibtex.addEventListener('click', () => {
|
||||
localStorage.setItem('citation-copy-format', 'bibtex');
|
||||
updateUi();
|
||||
});
|
||||
|
||||
inputContent.addEventListener('click', () => {
|
||||
inputContent.select();
|
||||
|
|
Loading…
Reference in a new issue