Skip to content

Commit

Permalink
Merge branch 'osfans:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ongyo authored Jan 13, 2025
2 parents 543e509 + 2951a88 commit 1f7297b
Show file tree
Hide file tree
Showing 1,255 changed files with 632,704 additions and 437,579 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
pushd tools
python3 -m pip install -r requirements.txt
touch tables/*.py
python3 make.py
python3 make.py -c
popd
- name: Grant execute permission for gradlew
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
pushd tools
python3 -m pip install -r requirements.txt
touch tables/*.py
python3 make.py
python3 make.py -c
popd
9 changes: 4 additions & 5 deletions app/src/main/assets/help/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
font-family: ipa;
src: url("file:///android_res/font/ipa.ttf")
}
body {font-size: 16px}
h1 {font-size: 24px; color: #9D261D}
h2 {font-size: 20px; color: #000080; text-indent: 10px}
h1 {font-size: 1.8em; color: #9D261D}
h2 {font-size: 1.2em; color: #000080; text-indent: 10px}
img.icon {vertical-align: bottom; height: 18px; width: 18px}
img.example {width: 80%}
a:link {color: blue}
Expand All @@ -22,10 +21,10 @@
.emph {color: red}
.dim {color: #808080}
.block {border: 1px gray solid; background: #E6E6FA; width: 60%; margin: auto; padding: 3px}
.hz {font-size: 200%; color: #9D261D;}
.hz {font-size: 2em; color: #9D261D;}
.ipa {font-family: ipa;}
.dialect {border: 1px gray solid; border-radius: 3px;}
.comment {font-size: 70%;}
.comment {font-size: 0.7em;}
</style>

<script language=javascript>
Expand Down
18 changes: 11 additions & 7 deletions app/src/main/java/com/osfans/mcpdict/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,16 @@ public static String getIntroText(String language) {
sb.append("</table>");
intro = sb.toString();
} else {
String phonology = getFieldByLanguage(language, "音系").replace("\n", "<br>");
intro = String.format(Locale.getDefault(), "<h1>%s</h1>%s<h2>音系說明</h2>%s<h2>同音字表</h2>", language, intro, phonology);
StringBuilder sb = new StringBuilder();
sb.append(String.format("<h1>%s</h1>", language));
sb.append(intro);
String[] fields = new String[]{"音系說明", "解析日志", "同音字表"};
for (String field: fields) {
String text = getFieldByLanguage(language, field).replace("\n", "<br>");
if (TextUtils.isEmpty(text)) continue;
sb.append(String.format("<h2>%s</h2>%s", field, text));
}
intro = sb.toString();
}
return intro;
}
Expand Down Expand Up @@ -794,12 +802,8 @@ public static int getSize(String lang) {
return Integer.parseInt(s);
}

private static String getLangType(String lang) {
return getFieldByLabel(lang, FIRST_FQ);
}

public static boolean isLang(String lang) {
return !TextUtils.isEmpty(getLangType(lang)) && !lang.contentEquals(HZ);
return !TextUtils.isEmpty(getFieldByLabel(lang, "方言島")) && !lang.contentEquals(HZ);
}

public static String[] getFqColumns() {
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/java/com/osfans/mcpdict/DisplayHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public String displayOne(String s) {
public String mLang;

public static CharSequence getRichText(String richTextString) {
String s = richTextString
.replace("\n", "<br/>")
String s = richTextString.replace("<", "&lt;").replace(">", "&gt;")
.replace("?", "?").replace("!", "!").replace(":", ":").replace(";", ";").replace("~", "~")
.replace("\n", "<br>")
.replaceAll("\\*\\*(.+?)\\*\\*", "<b>$1</b>")
.replaceAll("\\*(.+?)\\*", "<i>$1</i>")
.replaceAll("`(.+?)`", "<span style='color: #808080;'>$1</span>");
int i = Pref.getDisplayFormat();
if (i == 1) {
Expand Down Expand Up @@ -82,7 +84,7 @@ public static CharSequence formatPopUp(String hz, int i, String s) {
else if (i == COL_GYHZ) s = Pref.getString(R.string.book_format, DB.getLanguageByLabel(DB.getColumn(i))) + s.replaceFirst(PAGE_FORMAT, "第$1頁第$2字");
else if (i == COL_HD) s = Pref.getString(R.string.book_format, DB.getLanguageByLabel(DB.getColumn(i))) + s.replaceAll(PAGE_FORMAT, "<a href=https://homeinmists.ilotus.org/hd/png/$1.png>第$1頁</a>第$2字").replace("lv", "lü").replace("nv", "nü");
String[] fs = (s + "\n").split("\n", 2);
String text = String.format("<p><big><big><big>%s</big></big></big> %s</p><br><p>%s</p>", hz, fs[0], fs[1].replace("\n", "<br/>"));
String text = String.format("<p><big><big><big>%s</big></big></big> %s</p><br><p>%s</p>", hz, fs[0], fs[1].replace("\n", "<br>"));
return HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_COMPACT);
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/osfans/mcpdict/Orth/Orthography.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private static String getJSONString(JSONArray styles, int index) {
}

public static String formatRoman(String s) {
return String.format("<i>%s</i>", s);
return String.format("*%s*", s); // 斜體
}

private static final String[] toneBars = {"ˀ˩˨˧˦˥ˀ", "ˀ꜖꜕꜔꜓꜒ˀ", "ˀ꜌꜋꜊꜉꜈ˀ", "ˀ꜑꜐꜏꜎꜍ˀ", "⁰¹²³⁴⁵⁶"};
Expand Down
74 changes: 37 additions & 37 deletions app/src/main/java/com/osfans/mcpdict/ResultFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -419,44 +419,44 @@ private void setWebData(String query, Cursor cursor) {
sb.append(String.format("nyushu, p0, p2, p3, pua, %s; }\n", FontUtil.getDefaultFont()));
} else {
sb.append(FontUtil.useFontTone() ? "tone," : "ipa,");
sb.append(String.format("%s, nyushu, p0, p2, p3, pua; }\n", FontUtil.getDefaultFont()));
sb.append(String.format("%s, nyushu, p2, p3, pua; }\n", FontUtil.getDefaultFont()));
}
sb.append("""
.ipa {
padding: 0 5px;
}
.desc {
font-size: 0.6em;
}
.hz {
font-size: 1.8em;
color: #9D261D;
}
.variant {
color: #808080;
}
.ivs {
font-size: 1.8em;
font-family: nyushu, p0, p2, p3, pua;
}
.y {
color: #1E90FF;
margin: 0 5px;
}
p {
margin: 0.2em 0;
}
td {
vertical-align: top;
align: left;
}
ul {
margin: 1px;
padding: 0px 6px;
}
rt {font-size: 0.9em; background-color: #F0FFF0;}
</style></head><body>
""");
.ipa {
padding: 0 5px;
}
.desc {
font-size: 0.6em;
}
.hz {
font-size: 1.8em;
color: #9D261D;
}
.variant {
color: #808080;
}
.ivs {
font-size: 1.8em;
font-family: nyushu, p0, p2, p3, pua;
}
.y {
color: #1E90FF;
margin: 0 5px;
}
p {
margin: 0.2em 0;
}
td {
vertical-align: top;
align: left;
}
ul {
margin: 1px;
padding: 0px 6px;
}
rt {font-size: 0.9em; background-color: #F0FFF0;}
</style></head><body>
""");
if (TextUtils.isEmpty(query)) {
sb.append(DB.getIntro());
} else if (cursor == null || cursor.getCount() == 0) {
Expand Down Expand Up @@ -571,7 +571,7 @@ private void setWebData(String query, Cursor cursor) {
}
sb.append(ssb);
}
mWebView.loadDataWithBaseURL(null, sb.toString(), "text/html", "utf-8", null);
mWebView.loadDataWithBaseURL(null, sb.toString(), "text/html; charset=utf-8", "utf-8", null);
}

private CharSequence setTextData(String query, Cursor cursor) {
Expand Down
40 changes: 29 additions & 11 deletions app/src/main/java/com/osfans/mcpdict/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,35 @@ public static Context getContext() {

public static void info(Context context, String lang) {
WebView webView = new WebView(context, null);
String sb = "<style>\n" +
" @font-face {\n" +
" font-family: ipa;\n" +
" src: url(\"file:///android_res/font/ipa.ttf\")\n" +
" }\n" +
" body {font-size: 16px}\n" +
" h1 {font-size: 24px; color: #9D261D}\n" +
" h2 {font-size: 20px; color: #000080; text-indent: 10px}\n" +
" </style>" +
DB.getIntroText(DB.getLanguageByLabel(lang));
webView.loadDataWithBaseURL(null, sb, "text/html", "utf-8", null);
StringBuilder sb = new StringBuilder();
sb.append("<html><head><style>\n")
.append(" @font-face {\n")
.append(" font-family: ipa;\n")
.append(" src: url('file:///android_res/font/ipa.ttf');\n")
.append(" }\n")
.append(" @font-face {\n")
.append(" font-family: p0;\n")
.append(" src: url('file:///android_res/font/p0.otf') format('opentype');\n")
.append(" }\n")
.append(" @font-face {\n")
.append(" font-family: p2;\n")
.append(" src: url('file:///android_res/font/p2.otf') format('opentype');\n")
.append(" }\n")
.append(" @font-face {\n")
.append(" font-family: p3;\n")
.append(" src: url('file:///android_res/font/p3.otf') format('opentype');\n")
.append(" }\n")
.append(" h1 {font-size: 1.8em; color: #9D261D}\n")
.append(" h2 {font-size: 1.2em; color: #000080;}\n")
.append(" body {font-family: ipa, ");
if (FontUtil.fontExFirst()) {
sb.append(String.format("p0, p2, p3, %s;}", FontUtil.getDefaultFont()));
} else {
sb.append(String.format("%s, p2, p3;}", FontUtil.getDefaultFont()));
}
sb.append("</style></head><body>");
sb.append(DB.getIntroText(DB.getLanguageByLabel(lang)));
webView.loadDataWithBaseURL(null, sb.toString(), "text/html; charset=utf-8", "utf-8", null);

new AlertDialog.Builder(context)
.setView(webView)
Expand Down
Binary file modified app/src/main/res/font/p0.otf
Binary file not shown.
Binary file modified app/src/main/res/font/p2.otf
Binary file not shown.
Binary file modified app/src/main/res/font/p3.otf
Binary file not shown.
17 changes: 8 additions & 9 deletions cgi/cgi-bin/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def rich(r, k):
s = r[k]
if k == "白-沙": return s
s = s.replace(" ", "")
s = s.replace(" ", " ").replace(" ", "").replace(" ", " ")
s = re.sub(", ?", ", ", s)
s = s.replace("\n", "<br>")
s = re.sub("\{(.*?)\}", "<div class=desc>\\1</div>", s)
Expand Down Expand Up @@ -73,6 +73,7 @@ def getColorName(k):
return fmt % (color, name)

def getVariant(hzs, vars):
if not vars: return ""
for i in hzs:
if i in vars:
return i
Expand Down Expand Up @@ -115,17 +116,15 @@ def formatIntro(i):
s = ""
if i["簡稱"].encode() == HZ:
for k in ("版本","字數"):
if i[k]:
s += "%s:%s<br/>" % (k, i[k])
if i["說明"]:
s += i["說明"]
if i[k]: s += "%s:%s<br/>" % (k, i[k])
if i["說明"]: s += i["說明"]
else:
for k in ("地點","經緯度", "作者", "錄入人", "維護人","來源", "參考文獻","文件名","版本","字數","□數", "音節數","不帶調音節數"):
if i[k]:
s += "%s:%s<br/>" % (k, i[k])
if i[k]: s += "%s:%s<br/>" % (k, i[k])
if s: s += "<br/>"
if i["說明"]:
s += i["說明"]
if i["說明"]: s += i["說明"]
for k in ("音系說明", "解析日志", "同音字表"):
if i[k]: s += "<h2>%s</h2>%s" % (k, i[k])
s = s.replace("\n", "<br/>").replace("href=", "target='_blank' href=")
return s

Expand Down
4 changes: 2 additions & 2 deletions cgi/cgi-bin/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
tvs = getStrings("pref_entries_tone_value_display")
options_tv = "\n".join(["<option value=%s>%s</option>"%(i, j) for i,j in enumerate(tvs)])

print(getStringFromFile("template.html",APP,APP,
print(getStringFromFile("template.htm",APP,APP,
options_types,
getString("search_hint"),hzs,getString("clear"),"查詢",
options_search,options_dict,options_filters,getString("hz_option"),
Expand Down Expand Up @@ -87,7 +87,7 @@
for r in getSqls(value, word):
hz = r[HZ]
output += "<p><div class=hz>%s</div>"%(hz)
if variant:
if variant and r[VA]:
va = getVariant(hzs, r[VA])
if va: output += "<div class=variant>(%s)</div>"%(va)
output += "<div class=y>U+%04X</div>" % (ord(hz))
Expand Down
9 changes: 6 additions & 3 deletions cgi/cgi-bin/template.html → cgi/cgi-bin/template.htm
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,26 @@
text-align: center;
vertical-align: top;
transform-origin: right;
font-size: 80%;
font-size: 0.8em;
}

body {
font-family: ipa, sans;
}

h1 {font-size: 1.8em; color: #9D261D}
h2 {font-size: 1.2em; color: #000080; text-indent: 10px}

.ipa {
padding: 0 5px;
}

.desc {
font-size: 70%;
font-size: 0.7em;
}

.hz {
font-size: 300%;
font-size: 3em;
color: #9D261D;
}

Expand Down
5 changes: 3 additions & 2 deletions tools/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
import argparse

parser = argparse.ArgumentParser(description='Create mcpdict database')
parser.add_argument('-c', action='store_true', help='check 同音字頻', required=False)
parser.add_argument('-省', help='province to include', required=False)
args, argv = parser.parse_known_args()
start = time()

dicts = defaultdict(dict)
langs = getLangs(dicts, argv, =args.)
keys = [f"{lang}" for lang in langs]
langs = getLangs(dicts, argv, args)
keys = [f"{lang.簡稱}" for lang in langs]
fields = [f"`{i}`" for i in keys]
CREATE = 'CREATE VIRTUAL TABLE mcpdict USING fts3 (%s)' % (",".join(fields))
INSERT = 'INSERT INTO mcpdict VALUES (%s)'% (','.join('?' * len(keys)))
Expand Down
24 changes: 12 additions & 12 deletions tools/tables/1796建甌.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ class 表(_表):
sms = None
ym = None

def format(self, line):
return line.lstrip("#")
def (, ):
return .lstrip("#")

def parse(self, fs):
if not self.sms:
self.sms = fs
def (, ):
if not .sms:
.sms =
return
if fs[0]:
self.ym = fs[0]
sd = fs[1]
if [0]:
.ym = [0]
sd = [1]
l = list()
for i,sm in enumerate(self.sms):
for i,sm in enumerate(.sms):
if not sm: continue
yb = sm + self.ym + sd
for hz in fs[i]:
l.append((hz, yb))
yb = sm + .ym + sd
for in [i]:
l.append((, yb))
return l
Loading

0 comments on commit 1f7297b

Please sign in to comment.