Skip to content

Commit bc9523b

Browse files
committed
release: 更新至v0.1.1
fix: 添加文件名识别失败时的提示,更正作者全名模板{%a}->{%g}(参考zotfile)
1 parent c56956e commit bc9523b

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

chrome/content/scripts/jasminum.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,18 @@ Zotero.Jasminum = {
190190
var patentSepRegArr = patentSepArr.map(x => x.replace(/([\[\\\^\$\.\|\?\*\+\(\)])/g, '\\$&'));
191191
var patentMainArr = patent.match(/{%[^}]+}/g);
192192
//文件名中的作者姓名字段里不能包含下划线,请使用“&,,”等字符分隔多个作者,或仅使用第一个作者名(加不加“等”都行)。
193-
var patentMainRegArr = patentMainArr.map(x => x.replace(/.+/, /{%y}/.test(x) ? '(\\d+)' : (/{%a}/.test(x) ? '([^_]+)' : '(.+)')));
193+
var patentMainRegArr = patentMainArr.map(x => x.replace(/.+/, /{%y}/.test(x) ? '(\\d+)' : (/{%g}/.test(x) ? '([^_]+)' : '(.+)')));
194194
var regStrInterArr = patentSepRegArr.map((_, i) => [patentSepRegArr[i], patentMainRegArr[i]]);
195195
var patentReg = new RegExp([].concat.apply([], regStrInterArr).filter(Boolean).join(''), 'g');
196196
var prefix = filename.substr(0, filename.length - 4);
197197
var prefix = prefix.replace(/\.ashx$/g, ""); // 删除末尾.ashx字符
198198
var prefixMainArr = patentReg.exec(prefix);
199+
// 文件名识别结果为空,跳出警告弹窗
200+
if (prefixMainArr === null) {
201+
alert("文件名识别出错,请检查文件名识别模板与实际抓取文件名")
202+
}
199203
var titleIdx = patentMainArr.indexOf('{%t}');
200-
var authorIdx = patentMainArr.indexOf('{%a}');
204+
var authorIdx = patentMainArr.indexOf('{%g}');
201205
var titleRaw = (titleIdx != -1) ? prefixMainArr[titleIdx + 1] : '';
202206
var authors = (authorIdx != -1) ? prefixMainArr[authorIdx + 1] : '';
203207
var authorArr = authors.split(/[,&]/);

chrome/locale/en-US/overlay.dtd

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<!ENTITY jasminum.pdftk.info "Jasminum use PDFtk server to add bookmarks. Please install PDFtk server properly and choose folder contains PDFtk server execute file">
1616
<!ENTITY pdftk.path.check.ok "PDFtk server path is OK.">
1717
<!ENTITY pdftk.path.check.error "Can't find PDFtk execute file in this folder.">
18-
<!ENTITY jasminum.namepatent.desc "Filename format:{&#37;t}=title,{&#37;a}=author, {&#37;y}=year,{&#37;j}=other info(such as source), no limit on delimiters,ignore file extension">
18+
<!ENTITY jasminum.namepatent.desc "Filename format:{&#37;t}=title,{&#37;g}=author, {&#37;y}=year,{&#37;j}=other info(such as source), no limit on delimiters,ignore file extension">
1919
<!ENTITY jasminum.zhnamesplit.label "Split firstname and lastname when get metadata(Including CNKI web translators)">
2020
<!ENTITY jasminum.rename.label "Use Zotfile to rename attachment(Need Zotfile installed)">
2121
<!ENTITY jasminum.autobookmark.label "Add bookmark to thesis PDF when adding thesis item from CNKI">

chrome/locale/zh-CN/overlay.dtd

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<!ENTITY jasminum.pdftk.info "添加书签功能依赖于PDFtk server,正确安装并设置好安装目录才能实现书签添加功能,请选择PDFtk可执行文件所在目录">
1616
<!ENTITY pdftk.path.check.ok "PDFtk Server安装目录检查通过">
1717
<!ENTITY pdftk.path.check.error "未在该目录下发现pdftk执行程序">
18-
<!ENTITY jasminum.namepatent.desc "根据文件名抓取知网元数据,文件名格式设置:{&#37;t}=标题,{&#37;a}=作者,{&#37;y}=年份,{&#37;j}=其他(例如来源信息);分隔符依实情指定,可连续使用多个;不用考虑文件后缀名">
18+
<!ENTITY jasminum.namepatent.desc "根据文件名抓取知网元数据,文件名格式设置:{&#37;t}=标题,{&#37;g}=作者,{&#37;y}=年份,{&#37;j}=其他(例如来源信息);分隔符依实情指定,可连续使用多个;不用考虑文件后缀名">
1919
<!ENTITY jasminum.zhnamesplit.label "抓取题录信息时拆分中文姓,名(包括知网页面抓取)">
2020
<!ENTITY jasminum.rename.label "拉取知网元数据后调用Zotfile重命名附件(需安装Zotfile)">
2121
<!ENTITY jasminum.autobookmark.label "从知网添加学位论文时自动添加书签">

install.rdf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Description about="urn:mozilla:install-manifest">
66
<em:id>[email protected]</em:id>
77
<em:name>Jasminum</em:name>
8-
<em:version>0.1.0</em:version>
8+
<em:version>0.1.1</em:version>
99
<em:type>2</em:type>
1010
<em:iconURL>chrome://jasminum/skin/icon.png</em:iconURL>
1111
<em:multiprocessCompatible>true</em:multiprocessCompatible>

update.rdf

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<rdf:Seq>
77
<rdf:li>
88
<rdf:Description>
9-
<em:version>0.1.0</em:version>
9+
<em:version>0.1.1</em:version>
1010
<em:targetApplication>
1111
<rdf:Description>
1212
<em:id>[email protected]</em:id>
1313
<em:minVersion>5.0.0</em:minVersion>
1414
<em:maxVersion>5.*</em:maxVersion>
15-
<em:updateLink>https://github.com/l0o0/jasminum/releases/download/v0.1.0/jasminum-v0.1.0.xpi</em:updateLink>
15+
<em:updateLink>https://github.com/l0o0/jasminum/releases/download/v0.1.1/jasminum-v0.1.1.xpi</em:updateLink>
1616
</rdf:Description>
1717
</em:targetApplication>
1818

@@ -21,7 +21,7 @@
2121
<em:id>[email protected]</em:id>
2222
<em:minVersion>5.0</em:minVersion>
2323
<em:maxVersion>5.0.*</em:maxVersion>
24-
<em:updateLink>https://github.com/l0o0/jasminum/releases/download/v0.1.0/jasminum-v0.1.0.xpi</em:updateLink>
24+
<em:updateLink>https://github.com/l0o0/jasminum/releases/download/v0.1.1/jasminum-v0.1.1.xpi</em:updateLink>
2525
</rdf:Description>
2626
</em:targetApplication>
2727

0 commit comments

Comments
 (0)