Skip to content

Commit

Permalink
添加自定义缩写文件
Browse files Browse the repository at this point in the history
  • Loading branch information
redleafnew committed Apr 27, 2023
1 parent fa15b8d commit 34bfa47
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "greenfrog",
"version": "0.9.1",
"version": "0.9.2",
"description": "Zotero plugin for update journal information from easyScholar",
"config": {
"addonName": "Green Frog",
Expand Down
29 changes: 29 additions & 0 deletions src/modules/abb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 得到自定义期刊缩写
export function getAbbEx(pubT: any) {
var fullAbb: any = [
{
'full': 'Proceedings of the National Academy of Sciences',
'abb_no_dot': 'Proc Natl Acad Sci',
'abb_with_dot': 'Proc. Natl. Acad. Sci.',
"record": 1
},
{
'full': 'test',
'abb_no_dot': 'tt',
'abb_with_dot': 'test.',
"record": 1
}
]

var record0 = {
"record": 0
}

// var pubT: any = item.getField('publicationTitle');
var jourAbbs = fullAbb.filter((x: any) => x.full === pubT);
if (jourAbbs['0']) {
return jourAbbs['0'];
} else {
return record0;
}
};
15 changes: 14 additions & 1 deletion src/modules/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ProgressWindowHelper } from "zotero-plugin-toolkit/dist/helpers/progres
import { config } from "../../package.json";
import { getString } from "./locale";
import { njauCore, njauJournal } from "./njau";
import { getAbbEx } from "./abb";

function example(
target: any,
Expand Down Expand Up @@ -2449,6 +2450,14 @@ export class HelperExampleFactory {
}
}

if (jourAbbs["record"] == 0) { // 自定义的期刊缩写
try {
var jourAbbs = getAbbEx(pubT as any); // 得到带点和不带点的缩写
} catch (e) {
Zotero.debug('获取自定义期刊缩写失败');
}
}

if (jourAbbs["record"] == 0) { // 得到带点和不带点的缩写, 尝试删除the空格
try {
var jourAbbs = await HelperExampleFactory.getJourAbb((pubT as any).replace(/the\s/i, '')); // 得到带点和不带点的缩写
Expand All @@ -2460,6 +2469,7 @@ export class HelperExampleFactory {
if (jourAbbs["record"] != 0) {
try {
var jourAbb = dotAbb ? jourAbbs["abb_with_dot"] : jourAbbs["abb_no_dot"];

var abb = HelperExampleFactory.titleCase(jourAbb) //改为词首字母大写
abb = abb.replace('Ieee', 'IEEE'). //替换IEEE
replace('Acs', 'ACS'). //替换ACS
Expand All @@ -2468,14 +2478,17 @@ export class HelperExampleFactory {
replace('Avs', 'AVS'). //替换AVS
replace('Bmc', 'BMC'). //替换AVS
replace('Iet', 'IET'). //替换IET
replace('Rsc', 'RSC') //替换RSC
replace('Rsc', 'RSC'). //替换RSC
replace('U S A', 'USA'). //删除空格
replace('U. S. A.', 'U.S.A.') //删除空格
item.setField('journalAbbreviation', abb);

} catch (e) {
return;
}
// 英文如果找不到缩写是否用全称代替
} else {

if (enAbb && lan == 'en-US') {
item.setField('journalAbbreviation', pubT);
// 中文如果找不到缩写是否用全称代替
Expand Down
4 changes: 2 additions & 2 deletions update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"greenfrog@redleafnew.me": {
"updates": [
{
"version": "0.9.1",
"version": "0.9.2",
"update_link": "https://github.com/redleafnew/zotero-updateifsE/releases/latest/download/greenfrog.xpi",
"applications": {
"gecko": {
Expand All @@ -12,7 +12,7 @@
}
},
{
"version": "0.9.1",
"version": "0.9.2",
"update_link": "https://github.com/redleafnew/zotero-updateifsE/releases/latest/download/greenfrog.xpi",
"applications": {
"zotero": {
Expand Down
2 changes: 1 addition & 1 deletion update.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<rdf:Seq>
<rdf:li>
<rdf:Description>
<em:version>0.9.1</em:version>
<em:version>0.9.2</em:version>
<em:targetApplication>
<rdf:Description>
<em:id>zotero@chnm.gmu.edu</em:id>
Expand Down

0 comments on commit 34bfa47

Please # to comment.