Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.

Commit 4dabea1

Browse files
committed
implement package
1 parent a057591 commit 4dabea1

File tree

5 files changed

+218
-112
lines changed

5 files changed

+218
-112
lines changed

routes/files.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,27 @@ router.get("/", function(req, res, next) {
1212
var pkgname = req.originalUrl.split("/")[4];
1313
db.each("SELECT * FROM package WHERE repo = '" + repo + "' AND arch = '" + arch + "' AND pkgname = '" + pkgname + "'", function(err, row){
1414
if (!err) {
15-
res.render("package", {
16-
title: pkgname + " " + row.pkgver + "-" + row.pkgrel + " (" + arch + ")",
17-
package: row,
15+
if(arch == "any"){
16+
var archf = "x86_64";
17+
}else{
18+
var archf = arch;
19+
}
20+
var file = fs.readFileSync("admin/past/" + repo + "/" + archf + "/" + pkgname + "-" + row["pkgver"] + "-" + row["pkgrel"] + "/files", "utf-8").split("\n");
21+
var files = new Array(), numd = 0, numf = 0;
22+
for(var i = 1; i < file.length - 1; i++){
23+
if(file[i].substr(-1) == "/"){
24+
files.push({ type: "d", file: file[i] });
25+
numd++;
26+
}else{
27+
files.push({ type: "f", file: file[i] });
28+
numf++;
29+
}
30+
}
31+
res.render("files", {
32+
title: pkgname + " " + row.pkgver + "-" + row.pkgrel + " (" + arch + ") - ファイルリスト",
33+
files: files,
34+
numf: numf,
35+
numd: numd,
1836
selected: "anb-packages"
1937
});
2038
}

routes/search.js

Lines changed: 92 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ router.get("/", function(req, res, next) {
1212
case "repo":
1313
case "pkgname":
1414
case "last_update":
15-
order = "ORDER BY " + req.query.sort + " ASC";
15+
order = " ORDER BY " + req.query.sort + " ASC";
1616
break;
1717
case "-arch":
1818
case "-repo":
1919
case "-pkgname":
2020
case "-last_update":
21-
order = "ORDER BY " + req.query.sort.substr(1) + " DESC";
21+
order = " ORDER BY " + req.query.sort.substr(1) + " DESC";
2222
break;
2323
default:
24-
order = "ORDER BY pkgname ASC";
24+
order = " ORDER BY pkgname ASC";
25+
break;
2526
}
2627

2728
// 検索条件
@@ -41,19 +42,103 @@ router.get("/", function(req, res, next) {
4142
}else{
4243
var q = "";
4344
}
45+
if(Array.isArray(req.query.arch)){
46+
var arch = "";
47+
for(var i = 0; i < req.query.arch.length; i++){
48+
switch(req.query.arch[i]){
49+
case "any":
50+
case "i686":
51+
case "x86_64":
52+
if(arch != ""){
53+
arch += " OR ";
54+
}
55+
arch += "arch = \"" + req.query.arch[i] + "\"";
56+
break;
57+
}
58+
}
59+
if(arch != ""){
60+
if(where != ""){
61+
where += " AND ( " + arch +" )";
62+
}else{
63+
where += " ( " + arch +" )";
64+
}
65+
}
66+
}else if(req.query.arch != undefined){
67+
switch(req.query.arch){
68+
case "any":
69+
case "i686":
70+
case "x86_64":
71+
if(where != ""){
72+
where += " AND arch = \"" + req.query.arch + "\"";
73+
}else{
74+
where += " arch = \"" + req.query.arch + "\"";
75+
}
76+
break;
77+
}
78+
}
79+
if(Array.isArray(req.query.repo)){
80+
var repo = "";
81+
for(var i = 0; i < req.query.repo.length; i++){
82+
switch(req.query.repo[i]){
83+
case "community":
84+
case "community-testing":
85+
case "core":
86+
case "extra":
87+
case "multilib":
88+
case "multilib-testing":
89+
case "testing":
90+
if(repo != ""){
91+
repo += " OR ";
92+
}
93+
repo += "repo = \"" + req.query.repo[i] + "\"";
94+
break;
95+
}
96+
}
97+
if(repo != ""){
98+
if(where != ""){
99+
where += " AND ( " + repo +" )";
100+
}else{
101+
where += " ( " + repo +" )";
102+
}
103+
}
104+
}else if(req.query.repo != undefined){
105+
switch(req.query.repo){
106+
case "community":
107+
case "community-testing":
108+
case "core":
109+
case "extra":
110+
case "multilib":
111+
case "multilib-testing":
112+
case "testing":
113+
if(where != ""){
114+
where += " AND repo = \"" + req.query.repo + "\"";
115+
}else{
116+
where += " repo = \"" + req.query.repo + "\"";
117+
}
118+
break;
119+
}
120+
}
44121
if(where != ""){
45122
where = " WHERE" + where;
46123
}
47124

48125
// オフセット
49-
var limit = "LIMIT 100";
126+
var limit = " LIMIT 100";
50127
var page = (req.query.page != undefined) ? parseInt(req.query.page) : 1;
51128
if(page > 1){
52-
limit = "LIMIT " + ((page - 1) * 100) + ", 100";
129+
limit = " LIMIT " + ((page - 1) * 100) + ", 100";
53130
}
54131

55-
db.all("SELECT *, (SELECT COUNT(pkgname) FROM package" + where + ") AS count FROM package " + where + order + " " + limit, function(err, rows){
132+
db.all("SELECT arch, repo, pkgname, pkgver, pkgrel, pkgdesc, last_update, (SELECT COUNT(pkgname) FROM package" + where + ") AS count FROM package" + where + order + limit, function(err, rows){
56133
if (!err) {
134+
var criteria = "";
135+
if(Object.keys(req.query).length > 0){
136+
criteria = req.originalUrl.split("?").pop().replace(/page=[0-9]+/, "").replace(/\"/,"").replace(/\'/,"").replace(/\>/,"").replace(/\</,"");
137+
if(criteria != "" && criteria[0] != "&"){
138+
criteria = "&" + criteria;
139+
}
140+
}
141+
57142
if(rows.length == 0){
58143
res.render("search", {
59144
title: "パッケージ検索",
@@ -63,23 +148,14 @@ router.get("/", function(req, res, next) {
63148
total: 1,
64149
nextp: 0,
65150
prevp: 0,
66-
criteria: "",
151+
criteria: criteria,
67152
q: q,
68153
selected: "anb-packages"
69154
});
70155
}else{
71156
var total = Math.ceil(rows[0].count * 0.01);
72157
var nextp = (page < total) ? page + 1 : 0;
73158
var prevp = (page > 1) ? page - 1 : 0;
74-
var criteria = "";
75-
if(Object.keys(req.query).length > 1){
76-
criteria = req.originalUrl.split("?").pop().replace("page=" + page, "");
77-
if(criteria[0] != "&"){
78-
criteria = "&" + criteria;
79-
}
80-
}else if(Object.keys(req.query).length == 1 && req.query.page == undefined){
81-
criteria = "&" + req.originalUrl.split("?").pop();
82-
}
83159

84160
res.render("search", {
85161
title: "パッケージ検索",

views/files.jade

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,13 @@ extends layout
22

33
block content
44
div#pkgdetails.box
5-
h2 0ad a19-3
6-
div#detailslinks.listing
7-
div#actionlist
8-
h4 パッケージアクション
9-
ul.small
10-
li <a href="https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/0ad" title="0ad のソースファイル">ソースファイル</a> / <a href="https://projects.archlinux.org/svntogit/community.git/log/trunk?h=packages/0ad" title="0ad の変更履歴">変更履歴</a>
11-
li
12-
a(href="https://wiki.archlinuxjp.org/index.php?title=%E7%89%B9%E5%88%A5%3A%E6%A4%9C%E7%B4%A2&search=0ad", title="0ad について wiki で検索") ArchWiki を検索
13-
li <a href="https://www.archlinux.org/packages/community/i686/0ad/flag/" title="0ad の out-of-date フラグを立てる">パッケージの Out-of-Date フラグを立てる</a> <a href="/packages/flaghelp/" title="パッケージのフラグ立てに関するヘルプ" onclick="return !window.open('/packages/flaghelp/','FlagHelp','height=350,width=450,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=no');">(?)</a>
14-
li
15-
a(href="https://www.archlinux.org/packages/community/i686/0ad/download/", rel="nofollow", title="ミラーから 0ad をダウンロード") ミラーからダウンロード
16-
div(itemscope, itemtype="http://schema.org/SoftwareApplication")
17-
meta(itemprop="name", content="0ad")
18-
meta(itemprop="version", content="a19-3")
19-
meta(itemprop="softwareVersion", content="a19-3")
20-
meta(itemprop="fileSize", content="7807156")
21-
meta(itemprop="dateCreated", content="2015-12-22")
22-
meta(itemprop="datePublished", content="2015-12-22")
23-
meta(itemprop="operatingSystem", content="Arch Linux")
24-
table#pkginfo
25-
tr
26-
th アーキテクチャ:
27-
td
28-
a(href="/packages/?arch[]=i686", title="i686 アーキテクチャのパッケージ") i686
29-
tr
30-
th リポジトリ:
31-
td
32-
a(href="/packages/?repo[]=Community", title="Community リポジトリ") Community
33-
tr
34-
th 説明:
35-
td(itemprop="description")#pkgdesc.wrap Cross-platform, 3D and historically-based real-time strategy game
36-
tr
37-
th 上流 URL:
38-
td
39-
a(itemprop="url", href="http://play0ad.com/", title="0ad のウェブサイト") http://play0ad.com/
40-
tr
41-
th ライセンス:
42-
td.wrap GPL2, CCPL
43-
tr
44-
th パッケージ容量:
45-
td 7.4 MB
46-
tr
47-
th インストール容量:
48-
td 29 MB
49-
tr
50-
th パッケージ作成者:
51-
td Felix Yan
52-
tr
53-
th 最終更新
54-
td 2015-12-22 03:58:59 JST
5+
h2= title.replace(" -", "")
6+
p パッケージには!{numf}個のファイルと!{numd}個のディレクトリが入っています。
7+
p
8+
a(href="../") パッケージに戻る
559
div#metadata
56-
div#pkgdeps.listing
57-
h3(title="0ad は以下のパッケージに依存しています") 依存パッケージ (25)
58-
ul#pkgdepslist
59-
li binutils
60-
li boost-libs
61-
li boost <span class="make-dep"> (ビルド)</span>
62-
div#pkgreqs.listing
63-
h3  
64-
div#pkgfiles.listing
65-
h3(title="このパッケージに含まれている全てのファイルのリスト") パッケージの中身
66-
div#pkgfilelist
67-
p
68-
a(href="files/", title="クリックして 0ad の全てのファイルのリストを見る") 0ad のファイルリストを表示
10+
div#pkgfilelist
11+
ul
12+
- for(var i = 0; i < files.length; i++){
13+
li(class=files[i].type)= files[i].file
14+
- }

views/package.jade

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,93 @@ extends layout
22

33
block content
44
div#pkgdetails.box
5-
h2 0ad a19-3
5+
h2 !{package["pkgname"]} !{package["pkgver"]}-!{package["pkgrel"]}
66
div#detailslinks.listing
77
div#actionlist
88
h4 パッケージアクション
99
ul.small
10-
li <a href="https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/0ad" title="0ad のソースファイル">ソースファイル</a> / <a href="https://projects.archlinux.org/svntogit/community.git/log/trunk?h=packages/0ad" title="0ad の変更履歴">変更履歴</a>
10+
- var repo = (package["repo"] == "community" || package["repo"] == "community-testing") ? "community" : "packages";
11+
li <a href="https://projects.archlinux.org/svntogit/!{repo}.git/tree/trunk?h=packages/#{package["pkgname"]}" title="#{package["pkgname"]} のソースファイル">ソースファイル</a> / <a href="https://projects.archlinux.org/svntogit/!{repo}.git/log/trunk?h=packages/#{package["pkgname"]}" title="#{package["pkgname"]} の変更履歴">変更履歴</a>
1112
li
12-
a(href="https://wiki.archlinuxjp.org/index.php?title=%E7%89%B9%E5%88%A5%3A%E6%A4%9C%E7%B4%A2&search=0ad", title="0ad について wiki で検索") ArchWiki を検索
13-
li <a href="https://www.archlinux.org/packages/community/i686/0ad/flag/" title="0ad の out-of-date フラグを立てる">パッケージの Out-of-Date フラグを立てる</a> <a href="/static/flaghelp.html" title="パッケージのフラグ立てに関するヘルプ" onclick="return !window.open('/static/flaghelp.html','FlagHelp','height=350,width=450,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=no');">(?)</a>
13+
a(href="https://wiki.archlinuxjp.org/index.php?title=%E7%89%B9%E5%88%A5%3A%E6%A4%9C%E7%B4%A2&search=" + package["pkgname"], title=package["pkgname"] + " について wiki で検索") ArchWiki を検索
14+
li <a href="https://www.archlinux.org/packages/#{package["repo"]}/#{package["arch"]}/#{package["pkgname"]}/flag/" title="#{package["pkgname"]} の out-of-date フラグを立てる">パッケージの Out-of-Date フラグを立てる</a> <a href="/static/flaghelp.html" title="パッケージのフラグ立てに関するヘルプ" onclick="return !window.open('/static/flaghelp.html','FlagHelp','height=350,width=450,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=no');">(?)</a>
1415
li
15-
a(href="https://www.archlinux.org/packages/community/i686/0ad/download/", rel="nofollow", title="ミラーから 0ad をダウンロード") ミラーからダウンロード
16+
a(href="https://www.archlinux.org/packages/" + package["repo"] + "/" + package["arch"] + "/" + package["pkgname"] + "/download/", rel="nofollow", title="ミラーから " + package["pkgname"] + " をダウンロード") ミラーからダウンロード
1617
div(itemscope, itemtype="http://schema.org/SoftwareApplication")
17-
meta(itemprop="name", content="0ad")
18-
meta(itemprop="version", content="a19-3")
19-
meta(itemprop="softwareVersion", content="a19-3")
20-
meta(itemprop="fileSize", content="7807156")
21-
meta(itemprop="dateCreated", content="2015-12-22")
22-
meta(itemprop="datePublished", content="2015-12-22")
18+
meta(itemprop="name", content=package["pkgname"])
19+
meta(itemprop="version", content=package["pkgver"] + "-" + package["pkgrel"])
20+
meta(itemprop="softwareVersion", content=package["pkgver"] + "-" + package["pkgrel"])
21+
meta(itemprop="fileSize", content=package["csize"])
22+
meta(itemprop="dateCreated", content=package["last_update"].split(" ")[0])
23+
meta(itemprop="datePublished", content=package["last_update"].split(" ")[0])
2324
meta(itemprop="operatingSystem", content="Arch Linux")
2425
table#pkginfo
2526
tr
2627
th アーキテクチャ:
2728
td
28-
a(href="/packages/?arch[]=i686", title="i686 アーキテクチャのパッケージ") i686
29+
a(href="/packages/?arch=" + package["arch"], title=package["arch"] + " アーキテクチャのパッケージ")= package["arch"]
2930
tr
3031
th リポジトリ:
3132
td
32-
a(href="/packages/?repo[]=Community", title="Community リポジトリ") Community
33+
a(href="/packages/?repo=" + package["repo"], title=package["repo"] + " リポジトリ")= package["repo"]
34+
- if(package["pkgbase"] != ""){
35+
tr
36+
th ベースパッケージ:
37+
td= package["pkgbase"]
38+
- }
3339
tr
3440
th 説明:
35-
td(itemprop="description")#pkgdesc.wrap Cross-platform, 3D and historically-based real-time strategy game
41+
td(itemprop="description")#pkgdesc.wrap= package["pkgdesc"]
3642
tr
3743
th 上流 URL:
3844
td
39-
a(itemprop="url", href="http://play0ad.com/", title="0ad のウェブサイト") http://play0ad.com/
45+
a(itemprop="url", href=package["url"], title=package["pkgname"] + " のウェブサイト")= package["url"]
4046
tr
4147
th ライセンス:
42-
td.wrap GPL2, CCPL
48+
td.wrap= package["license"].replace(/ /,", ")
49+
- if(package["provides"] != ""){ var provides = "<span class=\"related\">" + package["provides"].replace(/ /, "</span>, <span class=\"related\">") + "</span>";
50+
tr
51+
th 提供:
52+
td.wrap.relatedto!= provides
53+
- } if(package["replaces"] != ""){ var replaces = "<span class=\"related\">" + package["replaces"].replace(/ /, "</span>, <span class=\"related\">") + "</span>";
54+
tr
55+
th 置換パッケージ:
56+
td.wrap.relatedto!= replaces
57+
- } if(package["conflicts"] != ""){ var conflicts = "<span class=\"related\">" + package["conflicts"].replace(/ /, "</span>, <span class=\"related\">") + "</span>";
58+
tr
59+
th 衝突パッケージ:
60+
td.wrap.relatedto!= conflicts
61+
- }
4362
tr
4463
th パッケージ容量:
45-
td 7.4 MB
64+
- if(package["csize"] > 1000000){ var csize = (package["csize"] * 0.000001).toFixed(1) + " MB"; }else if(package["csize"] > 1000){ var csize = (package["csize"] * 0.001).toFixed(1) + " KB"; }else{ var csize = package["csize"] + " B"; }
65+
td= csize
4666
tr
4767
th インストール容量:
48-
td 29 MB
68+
- if(package["isize"] > 1000000){ var isize = (package["isize"] * 0.000001).toFixed(1) + " MB"; }else if(package["isize"] > 1000){ var isize = (package["isize"] * 0.001).toFixed(1) + " KB"; }else{ var isize = package["isize"] + " B"; }
69+
td= isize
4970
tr
5071
th パッケージ作成者:
51-
td Felix Yan
72+
td= package["packager"].split(" <")[0]
5273
tr
53-
th 最終更新
54-
td 2015-12-22 03:58:59 JST
74+
th 最終更新:
75+
td !{package["last_update"]} JST
5576
div#metadata
5677
div#pkgdeps.listing
57-
h3(title="0ad は以下のパッケージに依存しています") 依存パッケージ (25)
78+
- if(package["depends"] != ""){ var deps = package["depends"].split(" "); }else{ var deps = new Array(); } if(package["optdeps"] != ""){ var optdeps = package["optdeps"].split("<>"); }else{ var optdeps = new Array(); } if(package["makedeps"] != ""){ var makedeps = package["makedeps"].split(" "); }else{ var makedeps = new Array(); } var totaldeps = deps.length + optdeps.length + makedeps.length;
79+
h3(title=package["pkgname"] + " は以下のパッケージに依存しています") 依存パッケージ (!{totaldeps})
5880
ul#pkgdepslist
59-
li binutils
60-
li boost-libs
61-
li boost <span class="make-dep"> (ビルド)</span>
81+
- for(var i = 0; i < deps.length; i++){
82+
li= deps[i]
83+
- } for(var i = 0; i < optdeps.length; i++){
84+
li !{optdeps[i].split(":")[0]} <span class="opt-dep">(任意)</span>
85+
- } for(var i = 0; i < makedeps.length; i++){
86+
li !{makedeps[i]} <span class="make-dep">(ビルド)</span>
87+
- }
6288
div#pkgreqs.listing
6389
h3  
6490
div#pkgfiles.listing
6591
h3(title="このパッケージに含まれている全てのファイルのリスト") パッケージの中身
6692
div#pkgfilelist
6793
p
68-
a(href="files/", title="クリックして 0ad の全てのファイルのリストを見る") 0ad のファイルリストを表示
94+
a(href="files/", title="クリックして " + package["pkgname"] + " の全てのファイルのリストを見る") !{package["pkgname"]} のファイルリストを表示

0 commit comments

Comments
 (0)