-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen.sh
executable file
·100 lines (91 loc) · 4.1 KB
/
gen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
domain="moul.io"
rootdir="public"
create_package() {
project_name="$1"
project_url="$2"
echo "$project_name" >> $rootdir/go-packages.txt
echo "/$project_name/* go-get=1 /$project_name/go-get.html 200!" >> $rootdir/_redirects
#echo "/$project_name/ $project_url 301!" >> $rootdir/_redirects
#echo "/$project_name/* $project_url 301!" >> $rootdir/_redirects
mkdir -p $rootdir/$project_name
cat > $rootdir/$project_name/go-get.html <<EOF
<html><head>
<meta name="go-import" content="$domain/$project_name git $project_url">
<meta name="go-source" content="$domain/$project_name $project_url $project_url/tree/master{/dir} $project_url/tree/master{/dir}/{file}#L{line}">
</head></html>
EOF
cat > $rootdir/$project_name/index.html <<EOF
<html>
<head>
<title>$domain/$project_name</title>
<link rel="stylesheet" type="text/css" href="/style.css">
<meta property="og:title" content="$domain/$project_name Go module">
<meta property="og:type" content="article">
<meta property="og:author" content="article">
<meta property="og:url" content="https://$domain/$project_name">
<meta property="og:image" content="https://$domain/moul-codes.png">
<meta property="og:site_name" content="$domain">
<meta property="article:author" content="https://manfred.life">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#9f00a7">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<h1>$domain/$project_name</h1>
<pre><code>go get $domain/$project_name</code></pre>
<pre><code>import "$domain/$project_name"</code></pre>
Home: <a href="$project_url">$project_url</a><br />
Doc: <a href="https://pkg.go.dev/$domain/$project_name">https://pkg.go.dev/$domain/$project_name</a>
<script async defer src="https://sa.moul.io/latest.js"></script>
<noscript><img src="https://sa.moul.io/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
</body>
</html>
EOF
}
while read line; do
if echo $line | grep --silent -E '^#'; then continue; fi
project_name=$(echo $line | awk '{print $1}')
project_url=$(echo $line | awk '{print $2}')
create_package "$project_name" "$project_url"
done < vanity.csv
cat $rootdir/go-packages.txt | sort -u > $rootdir/go-packages-sorted.txt
mv $rootdir/go-packages-sorted.txt $rootdir/go-packages.txt
# generate root index.html
cat > $rootdir/index.html <<EOF
<html>
<head>
<title>$domain Go modules</title>
<link rel="stylesheet" type="text/css" href="/style.css">
<meta property="og:title" content="$domain Go modules">
<meta property="og:type" content="website">
<meta property="og:url" content="https://$domain/">
<meta property="og:image" content="https://$domain/moul-codes.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#9f00a7">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<h1>$domain Go Modules</h1>
<ul>
EOF
while read line; do
echo ' <li><a href="'./$line/'">'$domain/$line'</a></li>' >> $rootdir/index.html
done < $rootdir/go-packages.txt
cat >> $rootdir/index.html <<EOF
</ul>
<hr />
Generated by <a href="https://github.com/moul/moul.io">github.com/moul/moul.io</a>.
<script async defer src="https://sa.moul.io/latest.js"></script>
<noscript><img src="https://sa.moul.io/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
</body>
</html>
EOF