Mirrored from GitHub

git clone https://github.com/christc4/mirror.git

Jump to: README.md index.tpl list-curl.sh


README.md

1	# mirror
2	
3	this is a werc .tpl page to mirror RAW content from your github repo, using the provided list-curl.sh script
4	
5	GitHub repos (via REST API) return structured JSON describing each file/folder at a path, including things like file name, size, type, download URL, etc.
6	
7	If you just want the names of all files in the root directory, the script list-curl.sh returns that
8	
9	dependencies 
10	
11	- curl: to fetch the data
12	- jq: to filter out just the file names
13	
14	see <https://bauherren.ovh/dump/kode/christos/werc/tpl/mirror/> for an example

index.tpl

1	<!-- EXAMPLE -->
2	
3	<h1>mirror</h1>
4	
5	<p>werc .tpl file to mirror github raw content
6	
7	<p>Mirrored from <a href=//github.com/christc4/mirror>GitHub</a>
8	
9	<p><pre>git clone https://github.com/christc4/mirror.git</pre>
10	
11	<p>Jump to:
12	% apilink=https://api.github.com/repos/christc4/mirror
13	% gitlink=https://raw.githubusercontent.com/christc4/mirror/refs/heads/main/
14	%	files=`{list-curl $apilink}
15	%		for(match in $files){
16	<a href=#%($"match%)>%($"match%)</a>
17	% }
18	<hr>
19	%	files=`{list-curl $apilink}
20	%		for(match in $files){
21	<h2><a name=%($"match%)>%($"match%)</a></h2>
22	<pre>
23	%			curl -L  $gitlink/$match | escape_html
24	</pre>
25	%		}
26	
27	

list-curl.sh

1	#!/bin/sh
2	
3	if [ -z "$1" ]; then
4	  echo "Usage: $0 <github_repo_api_url>"
5	  exit 1
6	fi
7	
8	curl -s "$1/contents/?ref=main" | jq -r '.[].name'