Commit 0d6eff73 authored by tavit ohanian's avatar tavit ohanian

fix merge conflicts

parents 66899c99 a3ecf070
Pipeline #1369 failed with stages
in 0 seconds
blank_issues_enabled: false
contact_links:
- name: Getting Help on IPFS
url: https://ipfs.io/help
about: All information about how and where to get help on IPFS.
- name: IPFS Official Forum
url: https://discuss.ipfs.io
about: Please post general questions, support requests, and discussions here.
---
name: Open an issue
about: Only for actionable issues relevant to this repository.
title: ''
labels: need/triage
assignees: ''
---
<!--
Hello! To ensure this issue is correctly addressed as soon as possible by the IPFS team, please try to make sure:
- This issue is relevant to this repository's topic or codebase.
- A clear description is provided. It should includes as much relevant information as possible and clear scope for the issue to be actionable.
FOR GENERAL DISCUSSION, HELP OR QUESTIONS, please see the options at https://ipfs.io/help or head directly to https://discuss.ipfs.io.
(you can delete this section after reading)
-->
# Configuration for welcome - https://github.com/behaviorbot/welcome
# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome
# Comment to be posted to on first time issues
newIssueWelcomeComment: >
Thank you for submitting your first issue to this repository! A maintainer
will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the
necessary information to make this process easy! Any information that can
help save additional round trips is useful! We currently aim to give
initial feedback within **two business days**. If this does not happen, feel
free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an
overview of priorities, assignments and additional actions requested by the
maintainers:
- "Priority" labels will show how urgent this is for the team.
- "Status" labels will show if this is ready to be worked on, blocked, or in progress.
- "Need" labels will indicate if additional input or analysis is required.
Finally, remember to use https://discuss.ipfs.io if you just need general
support.
# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
# Comment to be posted to on PRs from first time contributors in your repository
newPRWelcomeComment: >
Thank you for submitting this PR!
A maintainer will be here shortly to review it.
We are super grateful, but we are also overloaded! Help us by making sure
that:
* The context for this PR is clear, with relevant discussion, decisions
and stakeholders linked/mentioned.
* Your contribution itself is clear (code comments, self-review for the
rest) and in its best form. Follow the [code contribution
guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md#code-contribution-guidelines)
if they apply.
Getting other community members to do a review would be great help too on
complex PRs (you can ask in the chats/forums). If you are unsure about
something, just leave us a comment.
Next steps:
* A maintainer will triage and assign priority to this PR, commenting on
any missing things and potentially assigning a reviewer for high
priority items.
* The PR gets reviews, discussed and approvals as needed.
* The PR is merged by maintainers when it has been approved and comments addressed.
We currently aim to provide initial feedback/triaging within **two business
days**. Please keep an eye on any labelling actions, as these will indicate
priorities and status of your contribution.
We are very grateful for your contribution!
# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
# Comment to be posted to on pull requests merged by a first time user
# Currently disabled
#firstPRMergeComment: ""
name: Build
on: [push, pull_request]
jobs:
no-uncommitted-changes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Run Build
uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: npm run build
- name: Check working tree
id: changes
uses: UnicornGlobal/has-changes-action@v1.0.11
- name: Check for uncommited changes
if: steps.changes.outputs.changed == 1
run: git status && git --no-pager diff --patch-with-raw && echo "Output does not match src/, uncommitted changes exist, follow build instructions from README" && exit 1
1.0.4: QmT1jwrqzSMjSjLG5oBd9w4P9vXPKQksWuf5ghsE3Q88ZV
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v0.0.1] - 2021-10-10
This release is the first dms3 dir-index-html release:
## [v1.2.0] - 2020-08-03
This release streamlines the process for making future updates to this repo:
- Moves source-of-truth HTML and CSS files into new `src` directory ([details](https://github.com/ipfs/dir-index-html/pull/40#issue-456530181))
- Adds build script in `package.json` to generate minified/inlined `dir-index.html` at top level from individual files in `src` directory ([details](https://github.com/ipfs/dir-index-html/pull/40#issue-456530181))
- Adds GitHub Action to guard against committing state where `dir-index.html` does not match source materials in `src` ([details](https://github.com/ipfs/dir-index-html/pull/40#pullrequestreview-456126397))
## [v1.1.0] - 2020-07-24
This release brings general tidying, plus some substantial UI enhancements! Big thanks to @neatonk for all the work.
- Adds a column for CIDs between the name and size columns; CIDs are clickable links that open the item as a new "root path", enabling users to copy direct links to images or subdirectories (see https://github.com/ipfs/dir-index-html/issues/37 and https://github.com/ipfs/dir-index-html/issues/15)
- Adds the size of the current directory to the header of the table (see https://github.com/ipfs/dir-index-html/issues/37 and https://github.com/ipfs/dir-index-html/issues/25)
- Makes path components in table headers into links, so clicking on segments between directory slashes will go to that level of the directory tree (see https://github.com/ipfs/dir-index-html/issues/37 and https://github.com/ipfs/dir-index-html/issues/2)
- Updates tests to include testing the above (see https://github.com/ipfs/dir-index-html/pull/38)
- Reconciles legacy discrepancies between `dir-index.html` and `dir-index-uncat.html` (see https://github.com/ipfs/dir-index-html/pull/39)
## [v1.0.6] - 2020-06-25
- Adds favicon: visual consistency/prettiness, but more importantly prevents 404 error on an implicit /favicon.ico (see [#35](https://github.com/ipfs/dir-index-html/issues/35))
- Adds social sharing metadata (see [#34](https://github.com/ipfs/dir-index-html/issues/34))
- Updates contributing link in readme (thanks @stensonb!)
## [v1.0.5] - 2020-05-05
- Removes extraneous references to Glyphicons (closes [#23](https://github.com/ipfs/dir-index-html/issues/23))
- Makes page responsive overall (closes [#24](https://github.com/ipfs/dir-index-html/issues/24))
- Adds file icons for .wmv, .mov, .mkv (closes [#19](https://github.com/ipfs/dir-index-html/issues/19))
- Strips out unneeded CSS
- Makes colors more accessible consistent with those in ipfs-css
- Tidies up in general
## [v1.0.4] - 2020-04-21
- Update style to match IPFS branding
- Add links to ipfs.io, install help, and the bug tracker
## [v1.0.3] - 2016-08-31
- No release notes added
## [v1.0.2] - 2016-08-31
- No release notes added
## [v1.0.1] - 2016-08-31
- No release notes added
The MIT License (MIT)
Copyright (c) 2016 IPFS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# dir-index-html
dms3 submodule dir-index-html
[![Made by Protocol Labs](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)
[![Project: DMS3](https://img.shields.io/badge/project-DMS3-blue.svg?style=flat-square)](https://dms3.io/)
[![Matrix](https://img.shields.io/badge/matrix-%23dms3%3Amatrix.org-blue.svg?style=flat-square)](https://matrix.to/#/room/#dms3:matrix.org)
[![IRC](https://img.shields.io/badge/freenode-%23dms3-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23dms3)
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
> Directory listing HTML for `go-dms3` gateways
**NOTE:** This repo is not intended to be used as a standalone project! This code is used by the gateway code within [`go-dms3`](https://gitlab.dms3.io/dms3/go-dms3). In the long term, once the the gateway is extracted from `go-dms3`, the code in this repo will be merged into that gateway package.
![](https://user-images.githubusercontent.com/157609/88379209-ce6f0600-cda2-11ea-9620-20b9237bb441.png)
## Updating
When making updates to the directory listing page template, please note the following:
1. Make your changes to the (human-friendly) source documents in the `src` directory
2. Before testing or releasing, make sure to run the build script to update the minified version in the top-level directory:
```bash
> npm run build
```
3. To get your updates into `go-dms3`, you'll need to do the following:
- Cut a new, appropriately versioned release of `dir-index-html` (don't forget to bump the version number in `package.json`)
- Make a PR against `go-dms3` following [these instructions](https://gitlab.dms3.io/dms3/go-dms3/tree/master/assets#updating-dir-index-html) for updating the directory index
## Testing
1. Make sure you have [Go](https://golang.org/dl/) installed
2. Start the test server, which lives in its own directory:
```bash
> cd test
> go run .
```
This will listen on [`localhost:3000`](http://localhost:3000/) and reload the template every time you refresh the page.
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.
## Contribute
Feel free to join in. All are welcome! A good place to start is to check the [issues](https://gitlab.dms3.io/dms3/dir-index-html/issues) for anything you find interesting.
This repository falls under the DMS3 [Code of Conduct](https://gitlab.dms3.io/dms3/community/blob/master/code-of-conduct.md).
### Want to hack on DMS3?
[![](https://cdn.rawgit.com/jbenet/contribute-dms3-gif/master/img/contribute.gif)](https://gitlab.dms3.io/dms3/community/blob/master/CONTRIBUTING.md)
## License
MIT
This diff is collapsed.
package dirindexhtml
.aac
.aiff
.ai
.avi
.bmp
.c
.cpp
.css
.dat
.dmg
.doc
.dotx
.dwg
.dxf
.eps
.exe
.flv
.gif
.h
.hpp
.html
.ics
.iso
.java
.jpg
.jpeg
.js
.key
.less
.mid
.mkv
.mov
.mp3
.mp4
.mpg
.odf
.ods
.odt
.otp
.ots
.ott
.pdf
.php
.png
.ppt
.psd
.py
.qt
.rar
.rb
.rtf
.sass
.scss
.sql
.tga
.tgz
.tiff
.txt
.wav
.wmv
.xls
.xlsx
.xml
.yml
.zip
{
"name": "dir-index-html",
"author": "lgierth",
"description": "Directory listing HTML for go-DMS3 gateways",
"version": "0.0.1",
"homepage": "https://gitlab.dms3.io/dms3/dir-index-html#readme",
"bugs": {
"url": "https://gitlab.dms3.io/dms3/dir-index-html"
},
"gx": {
"dvcsimport": "gitlab.dms3.io/dms3/dir-index-html",
"goversion": "1.15"
},
"gxDependencies": [],
"gxVersion": "0.14.0",
"language": "go",
"license": "MIT",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"scripts": {
"start": "cd test && go run .",
"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",
"build:clean": "rm dir-index.html",
"build:remove-style-links": "sed '/<link rel=\"stylesheet\"/d' ./src/dir-index.html > ./base-html.html",
"build:minify-wrap-css": "(echo \"<style>\" && cat ./src/icons.css ./src/style.css | tr -d \"\t\n\r\" && echo && echo \"</style>\") > ./minified-wrapped-style.html",
"build:combine-html-css": "sed '/<head>/ r ./minified-wrapped-style.html' ./base-html.html > ./dir-index.html",
"build:remove-unused": "rm ./base-html.html && rm ./minified-wrapped-style.html"
}
}
<!DOCTYPE html>
{{ $root := . }}
<html>
<head>
<meta charset="utf-8" />
<meta name="description" content="A directory of files hosted on the distributed, decentralized web using DMS3">
<meta property="og:title" content="Files on DMS3">
<meta property="og:description" content="{{ .Path }}">
<meta property="og:type" content="website">
<meta property="og:image" content="https://gateway.dms3.io/dms3/QmSDeYAe9mga6NdTozAZuyGL3Q1XjsLtvX28XFxJH8oPjq">
<meta name="twitter:title" content="{{ .Path }}">
<meta name="twitter:description" content="A directory of files hosted on the distributed, decentralized web using DMS3">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://gateway.dms3.io/dms3/QmSDeYAe9mga6NdTozAZuyGL3Q1XjsLtvX28XFxJH8oPjq">
<meta name="twitter:creator" content="@dms3">
<meta name="twitter:site" content="@dms3">
<meta name="image" content="https://gateway.dms3.io/dms3/QmSDeYAe9mga6NdTozAZuyGL3Q1XjsLtvX28XFxJH8oPjq">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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/y8Nl/8G6Xv+emUP/AAAAAAAAAACWjz3/vrVb/761W/++tVv/vrVb/761W/+vp1D/urRZ/8vDZf/Lw2X/y8Nl/8vDZf/Lw2X/nplD/wAAAAAAAAAAlo89/761W/++tVv/vrVb/761W/++tVv/r6dQ/7q0Wf/Lw2X/y8Nl/8vDZf/Lw2X/y8Nl/56ZQ/8AAAAAAAAAAJaPPf++tVv/vrVb/761W/++tVv/vbRa/5aPPf+emUP/y8Nl/8vDZf/Lw2X/y8Nl/8vDZf+emUP/AAAAAAAAAACWjz3/vrVb/761W/++tVv/vrVb/5qTQP+inkb/op5G/6KdRv/Lw2X/y8Nl/8vDZf/Lw2X/nplD/wAAAAAAAAAAlo89/761W/++tVv/sqlS/56ZQ//LxWb/0Mlp/9DJaf/Kw2X/oJtE/7+3XP/Lw2X/y8Nl/56ZQ/8AAAAAAAAAAJaPPf+9tFr/mJE+/7GsUv/Rymr/0cpq/9HKav/Rymr/0cpq/9HKav+xrFL/nplD/8vDZf+emUP/AAAAAAAAAACWjz3/op5G/9HKav/Rymr/0cpq/9HKav/Rymr/0cpq/9HKav/Rymr/0cpq/9HKav+inkb/nplD/wAAAAAAAAAAAAAAAKKeRv+3slb/0cpq/9HKav/Rymr/0cpq/9HKav/Rymr/0cpq/9HKav+1sFX/op5G/wAAAAAAAAAAAAAAAAAAAAAAAAAAop5GUKKeRv/Nxmf/0cpq/9HKav/Rymr/0cpq/83GZ/+inkb/op5GSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAop5G16KeRv/LxWb/y8Vm/6KeRv+inkaPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAop5G/6KeRtcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/n8AAPgfAADwDwAAwAMAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAwAMAAPAPAAD4HwAA/n8AAA==" />
<link rel="stylesheet" href="style.css"/>
<link rel="stylesheet" href="icons.css">
<title>{{ .Path }}</title>
</head>
<body>
<div id="page-header">
<div id="page-header-logo" class="dms3-logo">&nbsp;</div>
<div id="page-header-menu">
<div class="menu-item-wide"><a href="https://dms3.io" target="_blank" rel="noopener noreferrer">About DMS3</a></div>
<div class="menu-item-wide"><a href="https://dms3.io#install" target="_blank" rel="noopener noreferrer">Install DMS3</a></div>
<div class="menu-item-narrow"><a href="https://dms3.io" target="_blank" rel="noopener noreferrer">About</a></div>
<div class="menu-item-narrow"><a href="https://dms3.io#install" target="_blank" rel="noopener noreferrer">Install</a></div>
<div>
<a href="https://github.com/dms3/dir-index-html/issues/" target="_blank" rel="noopener noreferrer">
<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>
</a>
</div>
</div>
</div>
<div id="content">
<div id="content-header" class="d-flex flex-wrap">
<div>
<strong>
Index of
{{ range .Breadcrumbs -}}
/{{ if .Path }}<a href="{{ $root.GatewayURL }}{{ .Path | urlEscape }}">{{ .Name }}</a>{{ else }}{{ .Name }}{{ end }}
{{- else }}
{{ .Path }}
{{ end }}
</strong>
{{ if .Hash }}
<div class="dms3-hash">
{{ .Hash }}
</div>
{{ end }}
</div>
{{ if .Size }}
<div class="no-linebreak flex-shrink-1 ml-auto">
<strong>&nbsp;{{ .Size }}</strong>
</div>
{{ end }}
</div>
<div class="table-responsive">
<table>
<tr>
<td class="type-icon">
<div class="dms3-_blank">&nbsp;</div>
</td>
<td>
<a href="{{.BackLink | urlEscape}}">..</a>
</td>
<td></td>
<td></td>
</tr>
{{ range .Listing }}
<tr>
<td class="type-icon">
<div class="{{iconFromExt .Name}}">&nbsp;</div>
</td>
<td>
<a href="{{ .Path | urlEscape }}">{{ .Name }}</a>
</td>
<td class="no-linebreak">
{{ if .Hash }}
<a class="dms3-hash" href={{ if $root.DNSLink }}"https://cid.dms3.io/#{{ .Hash | urlEscape}}" target="_blank" rel="noreferrer noopener"{{ else }}"{{ $root.GatewayURL }}/dms3/{{ .Hash | urlEscape}}?filename={{ .Name | urlEscape }}"{{ end }}>
{{ .ShortHash }}
</a>
{{ end }}
</td>
<td class="no-linebreak">{{ .Size }}</td>
</tr>
{{ end }}
</table>
</div>
</div>
</body>
</html>
This diff is collapsed.
body {
color:#34373f;
font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
font-size:14px;
line-height:1.43;
margin:0;
word-break:break-all;
-webkit-text-size-adjust:100%;
-ms-text-size-adjust:100%;
-webkit-tap-highlight-color:transparent
}
a {
color:#117eb3;
text-decoration:none
}
a:hover {
color:#00b0e9;
text-decoration:underline
}
a:active,
a:visited {
color:#00b0e9
}
strong {
font-weight:700
}
table {
border-collapse:collapse;
border-spacing:0;
max-width:100%;
width:100%
}
table:last-child {
border-bottom-left-radius:3px;
border-bottom-right-radius:3px
}
tr:first-child td {
border-top:0
}
tr:nth-of-type(even) {
background-color:#f7f8fa
}
td {
border-top:1px solid #d9dbe2;
padding:.65em;
vertical-align:top
}
#page-header {
align-items:center;
background:#0b3a53;
border-bottom:4px solid #69c4cd;
color:#fff;
display:flex;
font-size:1.12em;
font-weight:500;
justify-content:space-between;
padding:0 1em
}
#page-header a {
color:#69c4cd
}
#page-header a:active {
color:#9ad4db
}
#page-header a:hover {
color:#fff
}
#page-header-logo {
height:2.25em;
margin:.7em .7em .7em 0;
width:7.15em
}
#page-header-menu {
align-items:center;
display:flex;
margin:.65em 0
}
#page-header-menu div {
margin:0 .6em
}
#page-header-menu div:last-child {
margin:0 0 0 .6em
}
#page-header-menu svg {
fill:#69c4cd;
height:1.8em;
margin-top:.125em
}
#page-header-menu svg:hover {
fill:#fff
}
.menu-item-narrow {
display:none
}
#content {
border:1px solid #d9dbe2;
border-radius:4px;
margin:1em
}
#content-header {
background-color:#edf0f4;
border-bottom:1px solid #d9dbe2;
border-top-left-radius:3px;
border-top-right-radius:3px;
padding:.7em 1em
}
.type-icon,
.type-icon>* {
width:1.15em
}
.no-linebreak {
white-space:nowrap
}
.dms3-hash {
color:#7f8491;
font-family:monospace
}
@media only screen and (max-width:500px) {
.menu-item-narrow {
display:inline
}
.menu-item-wide {
display:none
}
}
@media print {
#page-header {
display:none
}
#content-header,
.dms3-hash,
body {
color:#000
}
#content-header {
border-bottom:1px solid #000
}
#content {
border:1px solid #000
}
a,
a:visited {
color:#000;
text-decoration:underline
}
a[href]:after {
content:" (" attr(href) ")"
}
tr {
page-break-inside:avoid
}
tr:nth-of-type(even) {
background-color:transparent
}
td {
border-top:1px solid #000
}
}
@-ms-viewport {
width:device-width
}
.d-flex {
display:flex
}
.flex-wrap {
flex-flow:wrap
}
.flex-shrink-1 {
flex-shrink:1
}
.ml-auto {
margin-left:auto
}
.table-responsive {
display:block;
width:100%;
overflow-x:auto;
-webkit-overflow-scrolling:touch
}
module gitlab.dms3.io/dms3/dir-index-html/test
go 1.15
package main
import (
"fmt"
"net/http"
"net/url"
"os"
"text/template"
)
const templateFile = "../dir-index.html"
// Copied from go-dms3/core/corehttp/gateway_indexPage.go
type listingTemplateData struct {
GatewayURL string
DNSLink bool
Listing []directoryItem
Size string
Path string
Breadcrumbs []breadcrumb
BackLink string
Hash string
}
type directoryItem struct {
Size string
Name string
Path string
Hash string
ShortHash string
}
type breadcrumb struct {
Name string
Path string
}
var testPath = "/dms3/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7/a/b/c"
var testData = listingTemplateData{
GatewayURL: "//localhost:3000",
DNSLink: true,
Listing: []directoryItem{{
Size: "25 MiB",
Name: "short-film.mov",
Path: testPath + "/short-film.mov",
Hash: "QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR",
ShortHash: "QmbW\u2026sMnR",
}, {
Size: "23 KiB",
Name: "250pxيوسف_الوزاني_صورة_ملتقطة_بواسطة_مرصد_هابل_الفضائي_توضح_سديم_السرطان،_وهو_بقايا_مستعر_أعظم._.jpg",
Path: testPath + "/250pxيوسف_الوزاني_صورة_ملتقطة_بواسطة_مرصد_هابل_الفضائي_توضح_سديم_السرطان،_وهو_بقايا_مستعر_أعظم._.jpg",
Hash: "QmUwrKrMTrNv8QjWGKMMH5QV9FMPUtRCoQ6zxTdgxATQW6",
ShortHash: "QmUw\u2026TQW6",
}, {
Size: "1 KiB",
Name: "this-piece-of-papers-got-47-words-37-sentences-58-words-we-wanna-know.txt",
Path: testPath + "/this-piece-of-papers-got-47-words-37-sentences-58-words-we-wanna-know.txt",
Hash: "bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
ShortHash: "bafy\u2026bzdi",
}},
Size: "25 MiB",
Path: testPath,
Breadcrumbs: []breadcrumb{{
Name: "dms3",
}, {
Name: "QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7",
Path: testPath + "/../../..",
}, {
Name: "a",
Path: testPath + "/../..",
}, {
Name: "b",
Path: testPath + "/..",
}, {
Name: "c",
Path: testPath,
}},
BackLink: testPath + "/..",
Hash: "QmFooBazBar2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7",
}
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.Error(w, "Ha-ha, tricked you! There are no files here!", http.StatusNotFound)
return
}
listingTemplate, err := template.New("dir-index.html").Funcs(template.FuncMap{
"iconFromExt": func(name string) string {
return "dms3-_blank" // place-holder
},
"urlEscape": func(rawUrl string) string {
pathUrl := url.URL{Path: rawUrl}
return pathUrl.String()
},
}).ParseFiles(templateFile)
if err != nil {
http.Error(w, fmt.Sprintf("failed to parse template file: %s", err), http.StatusInternalServerError)
return
}
err = listingTemplate.Execute(w, &testData)
if err != nil {
http.Error(w, fmt.Sprintf("failed to execute template: %s", err), http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
})
if _, err := os.Stat(templateFile); err != nil {
wd, _ := os.Getwd()
fmt.Printf("could not open template file %q, relative to %q: %s\n", templateFile, wd, err)
os.Exit(1)
}
fmt.Printf("listening on localhost:3000\n")
http.ListenAndServe("localhost:3000", mux)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment