Skip to content

Commit

Permalink
feat: Updated assets and added script to download updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokopenko committed Feb 23, 2024
1 parent 8558114 commit a8a36fb
Show file tree
Hide file tree
Showing 17 changed files with 2,054 additions and 53 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.sh]
indent_size = 2

[*.{css,js,json}]
indent_size = 2

[*.{yml,yaml}]
indent_size = 2
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/docker-compose.yml
/docroot
tmp
Dockerfile.*
.idea
.vscode
69 changes: 69 additions & 0 deletions bin/assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"assets": [
{
"asset": "js/docsify.min.js",
"source": "https://cdn.jsdelivr.net/npm/docsify@4",
"info": "https://docsify.js.org/#/quickstart"
},
{
"asset": "js/docsify-themeable.min.js",
"source": "https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/js/docsify-themeable.min.js",
"info": "https://jhildenbiddle.github.io/docsify-themeable/#/quick-start"
},
{
"asset": "js/mermaid.min.js",
"source": "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"
},
{
"asset": "js/plugins/code-inline.min.js",
"source": "https://unpkg.com/@rakutentech/docsify-code-inline/dist/index.min.js",
"info": "https://www.npmjs.com/package/@rakutentech/docsify-code-inline"
},
{
"asset": "js/plugins/docsify-copy-code.min.js",
"source": "https://cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"
},
{
"asset": "js/plugins/docsify-mermaid.min.js",
"source": "https://unpkg.com/[email protected]/dist/docsify-mermaid.js",
"info": "https://github.com/Leward/mermaid-docsify"
},
{
"asset": "js/plugins/search.min.js",
"source": "https://cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"
},
{
"asset": "css/docsify4-themes-vue.css",
"source": "https://cdn.jsdelivr.net/npm/docsify@4/themes/vue.css"
},
{
"asset": "css/themeable-simple.css",
"source": "https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple.css"
},
{
"asset": "css/themeable-simple-dark.css",
"source": "https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple-dark.css"
}
],
"prism": {
"asset": "js/prism/*",
"source": "https://raw.githubusercontent.com/PrismJS/prism/v1.29.0/components/*",
"supports": [
"prism-bash.min.js",
"prism-diff.min.js",
"prism-docker.min.js",
"prism-git.min.js",
"prism-groovy.min.js",
"prism-ignore.min.js",
"prism-ini.min.js",
"prism-json.min.js",
"prism-makefile.min.js",
"prism-php.min.js",
"prism-regex.min.js",
"prism-scss.min.js",
"prism-sql.min.js",
"prism-typescript.min.js",
"prism-yaml.min.js"
]
}
}
34 changes: 34 additions & 0 deletions bin/download-assets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env php
<?php

$assetsDir = __DIR__ . '/../html/assets';
$json = file_get_contents(__DIR__ . '/assets.json');
$assets = json_decode($json, true);

$sources = $assets['assets'];
echo "\nFound " . count($sources) . " docsify assets to download.";
echo "\nFound " . count($assets['prism']['supports']) . " prism.js language packs to download.";

foreach ($assets['prism']['supports'] as $name) {
$sources[] = [
'asset' => str_replace('*', $name, $assets['prism']['asset']),
'source' => str_replace('*', $name, $assets['prism']['source']),
];
}

echo "\n\nDownloading...\n";

foreach ($sources as $source) {
if (! $script = file_get_contents($source['source'])) {
echo " FAILED to download {$source['asset']}\n";
continue;
}

$status = file_put_contents("{$assetsDir}/{$source['asset']}", $script)
? 'saved'
: 'FAILED to save';
echo " {$status} {$source['asset']}\n";
}

echo "Done.\n";
exit(0);
19 changes: 19 additions & 0 deletions html/assets/css/themeable-customization.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
:root {
--content-max-width: 84em;
--link-color: var(--theme-color);
--code-inline-color: #e96900;
}
@media (prefers-color-scheme: dark) {
:root {
--code-inline-background: #0e2233;
}
}
@media (prefers-color-scheme: light) {
:root {
--code-inline-background: #f8f8f8;
}
}

.mermaid {
background-color: #fff;
}
3 changes: 3 additions & 0 deletions html/assets/css/themeable-simple-dark.css

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions html/assets/css/themeable-simple.css

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions html/assets/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Docsify docker image

## About

This is docker image to fast start with [docsify](https://docsify.js.org/) markdown docs viewer.

It's based on [nginx docker image](https://hub.docker.com/_/nginx).

### Included Plugins

- [search](https://docsify.js.org/#/plugins?id=full-text-search) - a docsify full text search plugin.
- [mermaid-docsify](https://github.com/Leward/mermaid-docsify) - a docsify plugin which allows to render mermaid diagrams in docsify.
- [docsify-copy-code](https://github.com/jperasmus/docsify-copy-code) - a docsify plugin that adds a button to easily copy code blocks to your clipboard.

## Quick start

Just launch the container to see it in action

```
docker run --name docsify-example -d -p 8080:80 justcoded/docsify:latest
```

Access the demo page on [127.0.0.1:8080](http://127.0.0.1:8080).

## Display your docs

Just mount your docs folder to `/usr/share/nginx/html/docs`.

Special files you may want to create:

- `_sidebar.md` - Left nav
- `_navbar.md` - Top nav

## Docker compose example

```yaml
---
version: "3.7"
services:
docsify:
image: justcoded/docsify:latest
volumes:
- ./docs/:/usr/share/nginx/html/docs
ports:
- 8080:80
```
## Configurations
### Custom docsify config
If you want custom config you can override `/usr/share/nginx/html/assets/docsify.conf.js`
with your mounted file.

Alternatively, you can set env variable with json to override the config:

```yaml
...
environment:
OPT_DOCSIFY_CONF: "{subMaxLevel: 3}"
```

### Custom page title

To specify custom page title on page load you can use env variable:

```yaml
...
environment:
OPT_INDEX_TITLE: My custom page title
```
1 change: 1 addition & 0 deletions html/assets/docs/_navbar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [Home](/)
1 change: 1 addition & 0 deletions html/assets/docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [Getting Started](/)
9 changes: 9 additions & 0 deletions html/assets/js/docsify-themeable.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion html/assets/js/docsify.min.js

Large diffs are not rendered by default.

1,655 changes: 1,642 additions & 13 deletions html/assets/js/mermaid.min.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions html/assets/js/plugins/docsify-copy-code.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a8a36fb

Please sign in to comment.