Skip to content

Commit

Permalink
Merge pull request #913 from zirreal/robonomics-wiki-test
Browse files Browse the repository at this point in the history
fixed bugs and added one command for all translations
  • Loading branch information
zirreal authored Nov 5, 2024
2 parents 493e8f5 + 5472d70 commit 13929f7
Show file tree
Hide file tree
Showing 31 changed files with 1,844 additions and 1,442 deletions.
3 changes: 2 additions & 1 deletion config/shortcodes/robo-wiki-video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ export const roboWikiVideo = async (...args) => {

let clss = videos[0].src.includes('static') ? 'robo-wiki-video' : 'robo-wiki-video robo-wiki-video--s hide' ;
let loaderClss = videos[0].src.includes('static') ? 'hide' : 'video-loading';
let defaultGW = 'https://gw.crust-gateway.com/ipfs/'

if(videos.length > 0 ) {
return `<video class="${clss}" controls muted playsinline ${attrs} ${cover ? 'poster="/assets/images/video-covers/' + cover + '"' : ''}>
${videos.map(video => {
return`<source src="${!video.src.includes('static') ? '/' + video.src + '#t=0.001' : video.src + '#t=0.001'}" type="${'video/' + video.type}" />`
return`<source data-source="${video.src}" src="${!video.src.includes('static') ? defaultGW + video.src + '#t=0.001' : video.src + '#t=0.001'}" type="${'video/' + video.type}" />`
}).join("")}</video><div class="${loaderClss}"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><circle fill="#5D9DEB" stroke="#5D9DEB" stroke-width="15" r="15" cx="40" cy="65"><animate attributeName="cy" calcMode="spline" dur="2" values="65;135;65;" keySplines=".5 0 .5 1;.5 0 .5 1" repeatCount="indefinite" begin="-.4"></animate></circle><circle fill="#5D9DEB" stroke="#5D9DEB" stroke-width="15" r="15" cx="100" cy="65"><animate attributeName="cy" calcMode="spline" dur="2" values="65;135;65;" keySplines=".5 0 .5 1;.5 0 .5 1" repeatCount="indefinite" begin="-.2"></animate></circle><circle fill="#5D9DEB" stroke="#5D9DEB" stroke-width="15" r="15" cx="160" cy="65"><animate attributeName="cy" calcMode="spline" dur="2" values="65;135;65;" keySplines=".5 0 .5 1;.5 0 .5 1" repeatCount="indefinite" begin="0"></animate></circle></svg><span>VIDEO LOADING...</span></div>`
}
}
Expand Down
37 changes: 3 additions & 34 deletions eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import yaml from 'js-yaml';
import dotenv from 'dotenv';
dotenv.config();

const NOT_FOUND_PATH = "dist/404.html";

// all translation files
const en = JSON.parse(fs.readFileSync('./translations/pages/en.json'))
const ar = JSON.parse(fs.readFileSync('./translations/pages/ar/ar.json'))
Expand Down Expand Up @@ -94,38 +92,9 @@ import metagen from 'eleventy-plugin-metagen'; // for pages metadata

export default async function(eleventyConfig) {

// to get 404 page
eleventyConfig.setBrowserSyncConfig({
callbacks: {
ready: function (err, bs) {
bs.addMiddleware("*", (req, res) => {
if (!fs.existsSync(NOT_FOUND_PATH)) {
throw new Error(
`Expected a \`${NOT_FOUND_PATH}\` file but could not find one. Did you create a 404.html template?`
);
}

const content_404 = fs.readFileSync(NOT_FOUND_PATH);
// Add 404 http status code in request header.
res.writeHead(404, { "Content-Type": "text/html; charset=UTF-8" });
// Provides the 404 content without redirect.
res.write(content_404);
res.end();
});
},
},
files: './_dist',
rewriteRules: [
{
match: /\/$/,
fn: function(req, res, match) {
if (req.url.endsWith('/')) {
req.url = req.url.slice(0, -1); // Remove trailing slash
}
return req.url;
}
}
]
eleventyConfig.setServerOptions({
// Show local network IP addresses for device testing
showAllHosts: true,
});

// eleventy copy assets
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"build:11ty": "cross-env ELEVENTY_ENV=production eleventy",
"translate-md": "node translations/prompt-md.js",
"translate": "node translations/prompt.js",
"translate-all": "node translations/prompt.js && node translations/prompt-md.js",
"start": "run-p dev:*",
"build": "run-s clean build:*"
},
Expand Down
274 changes: 148 additions & 126 deletions src/ar/docs/edit-wiki.md

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/ar/pages/pages.11tydata.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ export default {
eleventyComputed: {
title: function (data) {
if(data.title) {
return this.t(data.title, {}, 'ar');
try {
return this.t(data.title, {}, 'ar');
} catch(e) {
// console.log(e)
}
}
},
description: function (data) {
if(data.description) {
return this.t(data.description, {}, 'ar');
try {
return this.t(data.description, {}, 'ar');
} catch(e) {
// console.log(e)
}
}
},
}
Expand Down
2 changes: 2 additions & 0 deletions src/assets/css/components/code.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ pre{

.code-helper {
margin: calc(var(--space)* 0.6) 0;
margin-bottom: var(--space);
}


.code__additionalLine {
position: relative;
width: 100%;
Expand Down
7 changes: 4 additions & 3 deletions src/assets/js/components/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ document.addEventListener('DOMContentLoaded', async () => {

const changeSource = () => {
videos.forEach((v) => {
if(readyGateway && !v.src.includes(readyGateway)) {
const src = v.src.substring(v.src.lastIndexOf('/') + 1);
v.src = readyGateway + src;
if(readyGateway && !v.getAttribute('data-done')) {
const src = v.getAttribute('data-source');
v.src = readyGateway + src + '#t=0.001';
v.setAttribute('data-done', true);
v.parentElement.classList.remove('hide');
v.parentElement.nextSibling.classList.add('hide');
v.parentElement.load();
Expand Down
Loading

0 comments on commit 13929f7

Please sign in to comment.