https://github.com/coderofsalvation/d2x
d2x (=dir to x) is a cute bash utility which transforms a directory structure into something else (html etc)
https://github.com/coderofsalvation/d2x
bash html website
Last synced: 2 months ago
JSON representation
d2x (=dir to x) is a cute bash utility which transforms a directory structure into something else (html etc)
- Host: GitHub
- URL: https://github.com/coderofsalvation/d2x
- Owner: coderofsalvation
- Created: 2020-12-17T16:29:28.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-18T14:34:35.000Z (over 5 years ago)
- Last Synced: 2025-04-06T00:13:51.928Z (about 1 year ago)
- Topics: bash, html, website
- Language: Shell
- Homepage:
- Size: 4.68 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

Ultra simple map-a-directory-to-something-else ([SEE DEMO HERE](https://coderofsalvation.gitlab.io/d2x/))
# Usage
```
$ wget "https://raw.githubusercontent.com/coderofsalvation/d2x/master/d2x"
$ chmod 755 d2x
$ d2x init # optional: create example theme + src-folder
$ d2x src html --server
[x] copying theme/assets => html/assets
[x] rendering src => html......[x] done
[x] starting server at port 8000
Serving HTTP on 0.0.0.0 port 8000 ...
$ ls html/* # profit!
```

## features
* simplicity / zero dependencies (just bash)
* directory structure is the navigation
* transparent urls: `src/foo.txt` will be accessible as `html/foo.txt` and `html/foo.txt.html`
* easily to be used on embedded systems or to publish github/gitlab pages (see `.gitlab-ci.yml`)
* template language is bash
* easy writable plugins (in any language)
* easy to host from a subdirectory (just run `echo 'https://foo.com/my/sub/folder' > theme/url` like in `.gitlab.yml`)
> it only uses: cat sed find xargs test which grep ls
## What is a theme?
In the theme-dir you just put your custom html + bashfunctions, to transform the input-files.
Lets take a look at the example theme:
```
theme/assets # here you can put stuff like stylesheet or images
theme/index.html # master template
theme/title # textfile with inline shellscript
theme/foobar # shellscript
theme/plugins/myplugin # allows you to hook into d2x functions
theme/plugins/filetype/txt
theme/plugins/filetype/png # process every desirable extension here
theme/plugins/filetype/html
theme/plugins/filetype/....
theme/render # a helper, to be able to do $( render another.html ) inside html
theme/rendermenu # index.html calls by containing $( rendermenu )
```
Could it be any easier and unsafer?
Absolutely, the `index.html` even supports environvariables:
```
$(render title) $(foobar) $HOME
$( rendermenu )
```
And this theme will basically process a given directory-structure (`src` in the example):
```
src/10 collection A/bar.html
src/10 collection A/foo.html
src/10 collection A/textfile.txt
src/20 collection B/flop.html
src/20 collection B/shader.frag
src/index.html
```
In theory you could also use this to generate photoalbums, productlistings, source-code documentation etc!
## Why
Natural selection does [not always lead to greater complexity](https://www.newscientist.com/article/dn13617-evolution-myths-natural-selection-leads-to-ever-greater-complexity/).
Not being stuck in a rut (of zillion dependencies) is bliss.
## Inspiration / similar simplicity tools
* [Expose](https://github.com/Jack000/Expose)
* [ssg](https://www.romanzolotarev.com/ssg.html)