From cde932ec176d6e43b103f59fc1d1717b17022235 Mon Sep 17 00:00:00 2001 From: Joxit Date: Mon, 1 Mar 2021 23:55:32 +0100 Subject: [PATCH 01/23] feat(riot-v5): create the skeleton for riot5 --- .gitignore | 1 + package.json | 43 ++++++++++++++------------ rollup.config.js | 39 +++++++++++++++++++++++ rollup/html-useref.js | 21 +++++++++++++ src/components/docker-registry-ui.riot | 28 +++++++++++++++++ src/index.html | 8 ++--- src/index.js | 10 ++++++ 7 files changed, 125 insertions(+), 25 deletions(-) create mode 100644 rollup.config.js create mode 100644 rollup/html-useref.js create mode 100644 src/components/docker-registry-ui.riot create mode 100644 src/index.js diff --git a/.gitignore b/.gitignore index 53aa796..f4cc2db 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ registry-data .idea _site *.orig +.serve/ diff --git a/package.json b/package.json index 4f840b9..a7e1a42 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "docker-registry-ui", "version": "1.5.4", "scripts": { - "build": "./node_modules/gulp/bin/gulp.js build", + "start": "ROLLUP_SERVE=true rollup -c -w", + "build": "rollup -c", "build:electron": "npm run build && cd examples/electron && npm install && npm run dist" }, "repository": { @@ -12,24 +13,28 @@ "author": "Jones Magloire (Joxit)", "license": "AGPL-3.0", "description": "A web UI for private docker registry", - "dependencies": {}, + "dependencies": { + "marked": "^0.8.0" + }, "devDependencies": { - "del": "^3.0.0", - "gulp": "^4.0.2", - "gulp-clean-css": "^4.2.0", - "gulp-concat": "^2.6.0", - "gulp-filter": "^5.1.0", - "gulp-htmlmin": "^5.0.1", - "gulp-if": "^2.0.0", - "gulp-inject-version": "^1.0.1", - "gulp-license": "^1.1.0", - "gulp-riot": "^1.1.5", - "gulp-uglify": "^3.0.2", - "gulp-useref": "^3.1.6", - "riot": "^3.13.2", - "riot-mui": "^0.1.1", - "riot-route": "^3.1.4", - "stream-series": "^0.1.1", - "uglify-es": "^3.3.10" + "@babel/core": "^7.12.9", + "@babel/preset-env": "^7.12.7", + "@riotjs/compiler": "^5.3.1", + "@riotjs/route": "^7.0.0", + "@rollup/plugin-babel": "^5.2.2", + "@rollup/plugin-commonjs": "^17.0.0", + "@rollup/plugin-html": "^0.2.3", + "@rollup/plugin-node-resolve": "^11.0.0", + "js-beautify": "^1.13.0", + "riot": "^5.3.1", + "riot-mui": "joxit/riot-5-mui#53a3399a", + "rollup": "^2.34.2", + "rollup-plugin-app-utils": "^1.0.6", + "rollup-plugin-commonjs": "^10.1.0", + "rollup-plugin-riot": "^5.0.0", + "rollup-plugin-scss": "^2.6.1", + "rollup-plugin-serve": "^1.1.0", + "rollup-plugin-styles": "^3.14.1", + "rollup-plugin-terser": "^7.0.2" } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..3ab207d --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,39 @@ +import riot from 'rollup-plugin-riot'; +import nodeResolve from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; +import { terser } from 'rollup-plugin-terser'; +import { emptyDirectories } from 'rollup-plugin-app-utils'; +import { babel } from '@rollup/plugin-babel'; +import scss from 'rollup-plugin-scss'; +import serve from 'rollup-plugin-serve'; +import html from '@rollup/plugin-html'; +import htmlUseref from './rollup/html-useref'; + +const useServe = process.env.ROLLUP_SERVE === 'true'; +const output = useServe ? '.serve' : 'dist'; + +const plugins = [ + riot(), + nodeResolve(), + commonjs(), + scss({ output: `./${output}/docker-registry-ui.css`, outputStyle: 'compressed' }), + babel({ babelHelpers: 'bundled', presets: ['@babel/env'] }), + html({ template: () => htmlUseref('./src/index.html') }), +]; + +if (useServe) { + plugins.push(serve({ host: 'localhost', port: 8000, contentBase: [output, './'] })); +} else { + plugins.push(terser()); +} + +export default [ + { + input: { 'docker-registry-ui': 'src/index.js' }, + output: { + dir: output, + format: 'iife', + }, + plugins: [emptyDirectories(output)].concat(plugins), + }, +]; diff --git a/rollup/html-useref.js b/rollup/html-useref.js new file mode 100644 index 0000000..6211033 --- /dev/null +++ b/rollup/html-useref.js @@ -0,0 +1,21 @@ +import fs from 'fs'; + +const useref = /.*?/; + +const generateBalise = (type, output) => { + switch(type) { + case 'css': + return ``; + case 'js': + return `` + } +} + +export default function(src) { + let html = fs.readFileSync(src).toString().replace(/>\n+\s*/g, '>'); + while (useref.test(html)) { + const [ raw, type, output ] = useref.exec(html); + html = html.replace(raw, generateBalise(type, output)); + } + return html; +} \ No newline at end of file diff --git a/src/components/docker-registry-ui.riot b/src/components/docker-registry-ui.riot new file mode 100644 index 0000000..2219008 --- /dev/null +++ b/src/components/docker-registry-ui.riot @@ -0,0 +1,28 @@ + + +
+
+
+
+
+
+ +
\ No newline at end of file diff --git a/src/index.html b/src/index.html index 91d7af5..d94c4a2 100644 --- a/src/index.html +++ b/src/index.html @@ -19,10 +19,8 @@ - + - - @@ -37,12 +35,10 @@ - + - - diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..3429f97 --- /dev/null +++ b/src/index.js @@ -0,0 +1,10 @@ +import { component } from 'riot'; + +import DockerRegistryUI from './components/docker-registry-ui.riot'; + +import './style.css'; +import './roboto.css'; +import './material-icons.css'; + + +component(DockerRegistryUI)(document.getElementsByTagName('body').item(0)) From 11692c136ec7ddd2cabcced1a347f0316851b9f0 Mon Sep 17 00:00:00 2001 From: Joxit Date: Tue, 2 Mar 2021 01:15:20 +0100 Subject: [PATCH 02/23] feat(riot-v5): create the base of the new UI --- package.json | 1 + rollup.config.js | 2 ++ src/components/docker-registry-ui.riot | 26 ++++++++++++++++++++++++++ src/index.html | 2 +- src/index.js | 8 +++++++- 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a7e1a42..1fa4412 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@rollup/plugin-babel": "^5.2.2", "@rollup/plugin-commonjs": "^17.0.0", "@rollup/plugin-html": "^0.2.3", + "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^11.0.0", "js-beautify": "^1.13.0", "riot": "^5.3.1", diff --git a/rollup.config.js b/rollup.config.js index 3ab207d..3fb8cbe 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -8,12 +8,14 @@ import scss from 'rollup-plugin-scss'; import serve from 'rollup-plugin-serve'; import html from '@rollup/plugin-html'; import htmlUseref from './rollup/html-useref'; +import json from '@rollup/plugin-json'; const useServe = process.env.ROLLUP_SERVE === 'true'; const output = useServe ? '.serve' : 'dist'; const plugins = [ riot(), + json(), nodeResolve(), commonjs(), scss({ output: `./${output}/docker-registry-ui.css`, outputStyle: 'compressed' }), diff --git a/src/components/docker-registry-ui.riot b/src/components/docker-registry-ui.riot index 2219008..514f9f6 100644 --- a/src/components/docker-registry-ui.riot +++ b/src/components/docker-registry-ui.riot @@ -16,13 +16,39 @@ along with this program. If not, see . -->
+ + +
\ No newline at end of file diff --git a/src/index.html b/src/index.html index d94c4a2..e265a20 100644 --- a/src/index.html +++ b/src/index.html @@ -34,7 +34,7 @@ - + diff --git a/src/index.js b/src/index.js index 3429f97..da3db74 100644 --- a/src/index.js +++ b/src/index.js @@ -6,5 +6,11 @@ import './style.css'; import './roboto.css'; import './material-icons.css'; +import 'riot-mui/src/material-elements/material-navbar/material-navbar.scss'; +import 'riot-mui/src/material-elements/material-footer/material-footer.scss'; -component(DockerRegistryUI)(document.getElementsByTagName('body').item(0)) +const createApp = component(DockerRegistryUI); +const tags = document.getElementsByTagName('docker-registry-ui'); +for (let i = 0; i < tags.length; i++) { + createApp(tags.item(i)); +} From fb80283dd9a31336f536bbc018bf89c49071e29c Mon Sep 17 00:00:00 2001 From: Joxit Date: Wed, 3 Mar 2021 00:05:44 +0100 Subject: [PATCH 03/23] feat(riot-v5): upgrade catalog component + Http and fix global style --- package.json | 1 + rollup.config.js | 7 + src/components/catalog/catalog.riot | 107 +++++++++++++ src/components/docker-registry-ui.riot | 16 +- src/index.html | 52 +++++- src/index.js | 7 +- ...material-icons.css => material-icons.scss} | 0 src/{roboto.css => roboto.scss} | 0 src/scripts/http.js | 150 ++++++++++-------- src/{style.css => style.scss} | 7 + src/tags/catalog.riot | 78 --------- 11 files changed, 269 insertions(+), 156 deletions(-) create mode 100644 src/components/catalog/catalog.riot rename src/{material-icons.css => material-icons.scss} (100%) rename src/{roboto.css => roboto.scss} (100%) rename src/{style.css => style.scss} (96%) delete mode 100644 src/tags/catalog.riot diff --git a/package.json b/package.json index 1fa4412..775b7dd 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "rollup": "^2.34.2", "rollup-plugin-app-utils": "^1.0.6", "rollup-plugin-commonjs": "^10.1.0", + "rollup-plugin-copy": "^3.4.0", "rollup-plugin-riot": "^5.0.0", "rollup-plugin-scss": "^2.6.1", "rollup-plugin-serve": "^1.1.0", diff --git a/rollup.config.js b/rollup.config.js index 3fb8cbe..674c216 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -9,6 +9,7 @@ import serve from 'rollup-plugin-serve'; import html from '@rollup/plugin-html'; import htmlUseref from './rollup/html-useref'; import json from '@rollup/plugin-json'; +import copy from 'rollup-plugin-copy' const useServe = process.env.ROLLUP_SERVE === 'true'; const output = useServe ? '.serve' : 'dist'; @@ -21,6 +22,12 @@ const plugins = [ scss({ output: `./${output}/docker-registry-ui.css`, outputStyle: 'compressed' }), babel({ babelHelpers: 'bundled', presets: ['@babel/env'] }), html({ template: () => htmlUseref('./src/index.html') }), + copy({ + targets: [ + { src: 'src/fonts', dest: `${output}` }, + { src: 'src/images', dest: `${output}` }, + ] + }) ]; if (useServe) { diff --git a/src/components/catalog/catalog.riot b/src/components/catalog/catalog.riot new file mode 100644 index 0000000..550eb81 --- /dev/null +++ b/src/components/catalog/catalog.riot @@ -0,0 +1,107 @@ + + + +
+

+ Repositories of { state.name } +
{ state.length } images
+

+
+
+
+ +
+ + +
\ No newline at end of file diff --git a/src/components/docker-registry-ui.riot b/src/components/docker-registry-ui.riot index 514f9f6..ecbf074 100644 --- a/src/components/docker-registry-ui.riot +++ b/src/components/docker-registry-ui.riot @@ -21,6 +21,8 @@ along with this program. If not, see .
+