Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

Commit 9603194

Browse files
Merge pull request #40 from ipfs/feat/add-build-script
feat: Build script
2 parents fa0f5a0 + 8a9c62e commit 9603194

File tree

10 files changed

+768
-117
lines changed

10 files changed

+768
-117
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build
2+
on:
3+
push:
4+
5+
jobs:
6+
no-uncommitted-changes:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
with:
11+
ref: ${{ github.head_ref }}
12+
- name: Run Build
13+
uses: actions/setup-node@v1
14+
with:
15+
node-version: '12.x'
16+
- run: npm run build
17+
- name: Check working tree
18+
id: changes
19+
uses: UnicornGlobal/[email protected]
20+
- name: Check for uncommited changes
21+
if: steps.changes.outputs.changed == 1
22+
run: git status && echo "Output does not match src/, uncommitted changes exist, follow build instructions from README" && exit 1

README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
11
# dir-index-html
22

3-
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)
4-
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.io/)
3+
[![Made by Protocol Labs](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)
4+
[![Project: IPFS](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.io/)
55
[![Matrix](https://img.shields.io/badge/matrix-%23ipfs%3Amatrix.org-blue.svg?style=flat-square)](https://matrix.to/#/room/#ipfs:matrix.org)
66
[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
77
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
88

9-
> Directory listing HTML for go-ipfs gateways
9+
> Directory listing HTML for `go-ipfs` gateways
1010
11-
This repo is not be used standalone. It's used by the gateway code in go-ipfs. It'll be merged into the gateway package, once the gateway has been extracted from go-ipfs.
11+
**NOTE:** This repo is not intended to be used as a standalone project! This code is used by the gateway code within [`go-ipfs`](https://github.com/ipfs/go-ipfs). In the long term, once the the gateway is extracted from `go-ipfs`, the code in this repo will be merged into that gateway package.
1212

1313
![](https://user-images.githubusercontent.com/157609/88379209-ce6f0600-cda2-11ea-9620-20b9237bb441.png)
1414

1515
## Updating
1616

17-
1. Make changes to _both_ dir-index.html and dir-index-uncat.html.
18-
2. Follow the instructions in [go-ipfs](https://github.com/ipfs/go-ipfs/tree/master/assets#updating-dir-index-html) for updating the directory index.
17+
When making updates to the directory listing page template, please note the following:
18+
19+
1. Make your changes to the (human-friendly) source documents in the `src` directory
20+
2. Before testing or releasing, make sure to run the build script to update the minified version in the top-level directory:
21+
22+
```bash
23+
> npm run build
24+
```
25+
3. To get your updates into `go-ipfs`, you'll need to do the following:
26+
- Cut a new, appropriately versioned release of `dir-index-html` (don't forget to bump the version number in `package.json`)
27+
- Make a PR against `go-ipfs` following [these instructions](https://github.com/ipfs/go-ipfs/tree/master/assets#updating-dir-index-html) for updating the directory index
1928

2029
## Testing
2130

22-
1. Install [go](https://golang.org/dl/).
23-
2. Run the test server:
31+
1. Make sure you have [Go](https://golang.org/dl/) installed
32+
2. Start the test server, which lives in its own directory:
2433

2534
```bash
2635
> cd test
2736
> go run .
2837
```
38+
This will listen on [`localhost:3000`](http://localhost:3000/) and reload the template every time you refresh the page.
2939

30-
This will listen on `localhost:3000` and re-load the template every time you refresh the page.
40+
If you get a "no such file or directory" error upon trying `go run .`, make sure you ran `npm run build` to generate the minified artifact that the test is looking for.
3141

3242
## Contribute
3343

34-
Feel free to join in. All welcome. A good place to start is [the issues](https://github.com/ipfs/dir-index-html/issues).
44+
Feel free to join in. All are welcome! A good place to start is to check the [issues](https://github.com/ipfs/dir-index-html/issues) for anything you find interesting.
3545

3646
This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
3747

dir-index-uncat.html

Lines changed: 0 additions & 98 deletions
This file was deleted.

dir-index.html

Lines changed: 3 additions & 4 deletions
Large diffs are not rendered by default.

gw-assets/icons.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

gw-assets/style.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
2+
"name": "dir-index-html",
23
"author": "lgierth",
4+
"description": "Directory listing HTML for go-ipfs gateways",
5+
"version": "1.2.0",
6+
"homepage": "https://github.com/ipfs/dir-index-html#readme",
37
"bugs": {
48
"url": "https://github.com/ipfs/dir-index-html"
59
},
@@ -11,8 +15,13 @@
1115
"gxVersion": "0.14.0",
1216
"language": "go",
1317
"license": "MIT",
14-
"name": "dir-index-html",
1518
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
16-
"version": "1.0.4"
19+
"scripts": {
20+
"build": "npm run build:clean && npm run build:remove-style-links && npm run build:minify-wrap-css && npm run build:combine-html-css && npm run build:remove-unused",
21+
"build:clean": "rm dir-index.html",
22+
"build:remove-style-links": "sed '/<link rel=\"stylesheet\"/d' ./src/dir-index.html > ./base-html.html",
23+
"build:minify-wrap-css": "(echo \"<style>\" && cat ./src/icons.css ./src/style.css | tr -d \"\t\n\r\" && echo -e \"\\n</style>\") > ./minified-wrapped-style.html",
24+
"build:combine-html-css": "sed '/<head>/ r ./minified-wrapped-style.html' ./base-html.html > ./dir-index.html",
25+
"build:remove-unused": "rm ./base-html.html && rm ./minified-wrapped-style.html"
26+
}
1727
}
18-

src/dir-index.html

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!DOCTYPE html>
2+
{{ $root := . }}
3+
<html>
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="description" content="A directory of files hosted on the distributed, decentralized web using IPFS">
7+
<meta property="og:title" content="Files on IPFS">
8+
<meta property="og:description" content="{{ .Path }}">
9+
<meta property="og:type" content="website">
10+
<meta property="og:image" content="https://gateway.ipfs.io/ipfs/QmSDeYAe9mga6NdTozAZuyGL3Q1XjsLtvX28XFxJH8oPjq">
11+
<meta name="twitter:title" content="{{ .Path }}">
12+
<meta name="twitter:description" content="A directory of files hosted on the distributed, decentralized web using IPFS">
13+
<meta name="twitter:card" content="summary_large_image">
14+
<meta name="twitter:image" content="https://gateway.ipfs.io/ipfs/QmSDeYAe9mga6NdTozAZuyGL3Q1XjsLtvX28XFxJH8oPjq">
15+
<meta name="twitter:creator" content="@ipfs">
16+
<meta name="twitter:site" content="@ipfs">
17+
<meta name="image" content="https://gateway.ipfs.io/ipfs/QmSDeYAe9mga6NdTozAZuyGL3Q1XjsLtvX28XFxJH8oPjq">
18+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
19+
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlo89/56ZQ/8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACUjDu1lo89/6mhTP+zrVP/nplD/5+aRK8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHNiIS6Wjz3/ubFY/761W/+vp1D/urRZ/8vDZf/GvmH/nplD/1BNIm8AAAAAAAAAAAAAAAAAAAAAAAAAAJaPPf+knEj/vrVb/761W/++tVv/r6dQ/7q0Wf/Lw2X/y8Nl/8vDZf+tpk7/nplD/wAAAAAAAAAAAAAAAJaPPf+2rVX/vrVb/761W/++tVv/vrVb/6+nUP+6tFn/y8Nl/8vDZf/Lw2X/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" href="style.css"/>
21+
<link rel="stylesheet" href="icons.css">
22+
<title>{{ .Path }}</title>
23+
</head>
24+
<body>
25+
<div id="page-header">
26+
<div id="page-header-logo" class="ipfs-logo">&nbsp;</div>
27+
<div id="page-header-menu">
28+
<div class="menu-item-wide"><a href="https://ipfs.io" target="_blank" rel="noopener noreferrer">About IPFS</a></div>
29+
<div class="menu-item-wide"><a href="https://ipfs.io#install" target="_blank" rel="noopener noreferrer">Install IPFS</a></div>
30+
<div class="menu-item-narrow"><a href="https://ipfs.io" target="_blank" rel="noopener noreferrer">About</a></div>
31+
<div class="menu-item-narrow"><a href="https://ipfs.io#install" target="_blank" rel="noopener noreferrer">Install</a></div>
32+
<div>
33+
<a href="https://github.com/ipfs/dir-index-html/issues/" target="_blank" rel="noopener noreferrer">
34+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18.4 21"><circle cx="7.5" cy="4.8" r="1"/><circle cx="11.1" cy="4.8" r="1"/><path d="M12.7 8.4c-0.5-1.5-1.9-2.5-3.5-2.5 -1.6 0-3 1-3.5 2.5H12.7z"/><path d="M8.5 9.7H5c-0.5 0.8-0.7 1.7-0.7 2.7 0 2.6 1.8 4.8 4.2 5.2V9.7z"/><path d="M13.4 9.7H9.9v7.9c2.4-0.4 4.2-2.5 4.2-5.2C14.1 11.4 13.9 10.5 13.4 9.7z"/><circle cx="15.7" cy="12.9" r="1"/><circle cx="15.1" cy="15.4" r="1"/><circle cx="15.3" cy="10.4" r="1"/><circle cx="2.7" cy="12.9" r="1"/><circle cx="3.3" cy="15.4" r="1"/><circle cx="3.1" cy="10.4" r="1"/></svg>
35+
</a>
36+
</div>
37+
</div>
38+
</div>
39+
<div id="content">
40+
<div id="content-header" class="d-flex flex-wrap">
41+
<div>
42+
<strong>
43+
Index of
44+
{{ range .Breadcrumbs -}}
45+
/{{ if .Path }}<a href="{{ $root.GatewayURL }}{{ .Path | urlEscape }}">{{ .Name }}</a>{{ else }}{{ .Name }}{{ end }}
46+
{{- else }}
47+
{{ .Path }}
48+
{{ end }}
49+
</strong>
50+
{{ if .Hash }}
51+
<div class="ipfs-hash">
52+
{{ .Hash }}
53+
</div>
54+
{{ end }}
55+
</div>
56+
{{ if .Size }}
57+
<div class="no-linebreak flex-shrink-1 ml-auto">
58+
<strong>&nbsp;{{ .Size }}</strong>
59+
</div>
60+
{{ end }}
61+
</div>
62+
<div class="table-responsive">
63+
<table>
64+
<tr>
65+
<td class="type-icon">
66+
<div class="ipfs-_blank">&nbsp;</div>
67+
</td>
68+
<td>
69+
<a href="{{.BackLink | urlEscape}}">..</a>
70+
</td>
71+
<td></td>
72+
<td></td>
73+
</tr>
74+
{{ range .Listing }}
75+
<tr>
76+
<td class="type-icon">
77+
<div class="{{iconFromExt .Name}}">&nbsp;</div>
78+
</td>
79+
<td>
80+
<a href="{{ .Path | urlEscape }}">{{ .Name }}</a>
81+
</td>
82+
<td class="no-linebreak">
83+
{{ if .Hash }}
84+
<a class="ipfs-hash" href="{{ $root.GatewayURL }}/ipfs/{{ .Hash | urlEscape }}">
85+
{{ .ShortHash }}
86+
</a>
87+
{{ end }}
88+
</td>
89+
<td class="no-linebreak">{{ .Size }}</td>
90+
</tr>
91+
{{ end }}
92+
</table>
93+
</div>
94+
</div>
95+
</body>
96+
</html>

0 commit comments

Comments
 (0)