Skip to content

Commit

Permalink
Merge pull request #59 from reallyreadit/extension-as-proxy
Browse files Browse the repository at this point in the history
Readup back on the web
  • Loading branch information
jacamera authored Mar 12, 2023
2 parents ac1ae65 + d312827 commit e79ea5f
Show file tree
Hide file tree
Showing 804 changed files with 39,293 additions and 39,203 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"service": "web",
"workspaceFolder": "/web",
"shutdownAction": "none"
}
}
7 changes: 5 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
root = true

[*]
indent_style = tab
# Unconfigurable Rome/Prettier behavior
insert_final_newline = true
charset = utf-8
# Configurable Rome/Prettier behavior
max_line_length = 80
indent_style = tab
trim_trailing_whitespace = true
insert_final_newline = false
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/bin
/node_modules
/pkg
/pub
/pub
**/.DS_Store
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14
14.17
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
bin
pkg
pub
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "es5",
"useTabs": true,
"singleQuote": true
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"editorconfig.editorconfig",
"rome.rome",
"esbenp.prettier-vscode"
]
}
122 changes: 45 additions & 77 deletions build/buildScss.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Copyright (C) 2022 reallyread.it, inc.
//
//
// This file is part of Readup.
//
//
// Readup is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
//
//
// Readup is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License version 3 along with Foobar. If not, see <https://www.gnu.org/licenses/>.

const
{ src, dest } = require('gulp'),
const { src, dest } = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
sass = require('gulp-sass')(require('sass')),
Expand All @@ -19,8 +18,7 @@ const

sass.compiler = require('sass');

const
mapSourceRoot = require('./mapSourceRoot'),
const mapSourceRoot = require('./mapSourceRoot'),
project = require('./project');

function createScssObjectKey(jsObjectKey) {
Expand All @@ -37,114 +35,84 @@ function createScssObjectKey(jsObjectKey) {
function createScssObject(object) {
return (
'(' +
Object
.keys(object)
.map(
key => {
const value = object[key];
return (
createScssObjectKey(key) +
':' +
(
typeof value === 'object' ?
createScssObject(value) :
JSON.stringify(value)
)
);
}
)
Object.keys(object)
.map((key) => {
const value = object[key];
return (
createScssObjectKey(key) +
':' +
(typeof value === 'object'
? createScssObject(value)
: JSON.stringify(value))
);
})
.join(',') +
')'
);
}

function buildScss(params) {
// set up the stream
let stream = src(
params.src,
{
base: params.base
}
);
let stream = src(params.src, {
base: params.base,
});
// append config variable is required
if (params.appConfig) {
const scssConfig = (
const scssConfig =
'$readup-config:' +
createScssObject(
JSON.parse(
fs
.readFileSync(
params.appConfig.path.replace('{env}', params.env)
)
.readFileSync(params.appConfig.path.replace('{env}', params.env))
.toString()
)
) +
';\n\n'
);
';\n\n';
stream = stream.pipe(
insert.transform(
(contents, file) => {
file.path
if (file.extname === '.scss') {
return scssConfig + contents;
}
return contents;
insert.transform((contents, file) => {
file.path;
if (file.extname === '.scss') {
return scssConfig + contents;
}
)
return contents;
})
);
}
// compile and concat into a bundle
stream = stream
.pipe(
sourcemaps.init()
)
.pipe(
sass()
.on('error', sass.logError)
)
.pipe(
concat(params.fileName || 'bundle.css')
);
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(concat(params.fileName || 'bundle.css'));
// retarget theme selectors if targeting shadow dom
if (params.targetShadowDom) {
stream = stream.pipe(
insert.transform(
contents => contents.replace(/:root((:not\()?\[data-com_readup_theme(=(light|dark))?\]\)?)/g, ':host($1)')
insert.transform((contents) =>
contents.replace(
/:root((:not\()?\[data-com_readup_theme(=(light|dark))?\]\)?)/g,
':host($1)'
)
)
);
}
// write sourcemap
if (
(
params.env === project.env.dev &&
params.sourceMaps !== false
) ||
(params.env === project.env.dev && params.sourceMaps !== false) ||
params.sourceMaps === true
) {
stream = stream.pipe(
sourcemaps.write(
'.',
{
sourceRoot: file => mapSourceRoot(file, params.dest)
}
)
sourcemaps.write('.', {
sourceRoot: (file) => mapSourceRoot(file, params.dest),
})
);
}
// minify
if (params.env !== project.env.dev) {
steam = stream.pipe(
clean()
);
steam = stream.pipe(clean());
}
// write output and signal completion
return stream
.pipe(
dest(params.dest)
)
.on(
'end',
params.onComplete || function () { }
);
.pipe(dest(params.dest))
.on('end', params.onComplete || function () {});
}

module.exports = buildScss;
module.exports = buildScss;
12 changes: 6 additions & 6 deletions build/buildStaticAssets.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Copyright (C) 2022 reallyread.it, inc.
//
//
// This file is part of Readup.
//
//
// Readup is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
//
//
// Readup is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License version 3 along with Foobar. If not, see <https://www.gnu.org/licenses/>.

const { src, dest } = require('gulp')
const { src, dest } = require('gulp');

function buildStaticAssets(params) {
return src(params.src, { base: params.base })
.pipe(dest(params.dest))
.on('end', params.onComplete || function () {});
}

module.exports = buildStaticAssets;
module.exports = buildStaticAssets;
40 changes: 14 additions & 26 deletions build/buildTemplates.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,27 @@
// Copyright (C) 2022 reallyread.it, inc.
//
//
// This file is part of Readup.
//
//
// Readup is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
//
//
// Readup is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License version 3 along with Foobar. If not, see <https://www.gnu.org/licenses/>.

const
{ src, dest } = require('gulp'),
const { src, dest } = require('gulp'),
mustache = require('gulp-mustache');

function buildTemplates(params) {
return src(
params.src,
{
base: params.base
}
)
.pipe(
mustache(
params.data(params.env),
{
extension: params.extension
}
)
)
return src(params.src, {
base: params.base,
})
.pipe(
dest(params.dest)
mustache(params.data(params.env), {
extension: params.extension,
})
)
.on(
'end',
params.onComplete || function () { }
);
.pipe(dest(params.dest))
.on('end', params.onComplete || function () {});
}

module.exports = buildTemplates;
module.exports = buildTemplates;
Loading

0 comments on commit e79ea5f

Please sign in to comment.