Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
content
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ok1kvk.cz
content
Commits
47bdda02
Unverified
Commit
47bdda02
authored
5 years ago
by
Isabella Skořepová
Browse files
Options
Downloads
Patches
Plain Diff
Run eslint fix
parent
8664d3ae
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
index.js
+148
-123
148 additions, 123 deletions
index.js
package.json
+2
-1
2 additions, 1 deletion
package.json
sitegin/image.js
+3
-2
3 additions, 2 deletions
sitegin/image.js
sitegin/imageResizer.js
+2
-2
2 additions, 2 deletions
sitegin/imageResizer.js
sitegin/nunjucks.js
+6
-4
6 additions, 4 deletions
sitegin/nunjucks.js
with
161 additions
and
132 deletions
index.js
+
148
−
123
View file @
47bdda02
#!/usr/bin/env node
#!/usr/bin/env node
var
moment
=
require
(
'
moment
'
)
;
const
moment
=
require
(
'
moment
'
)
var
cli
=
require
(
'
cli
'
)
;
const
cli
=
require
(
'
cli
'
)
var
config
=
require
(
'
./sitegin/config
'
)
;
const
path
=
require
(
'
path
'
)
var
path
=
require
(
'
path
'
)
;
const
config
=
require
(
'
./sitegin/config
'
)
cli
.
main
(
function
(
args
,
options
)
{
cli
.
main
(
function
(
args
,
options
)
{
console
.
log
(
options
)
;
console
.
log
(
options
)
config
()
config
()
.
then
(
function
(
obj
)
{
.
then
(
function
(
obj
)
{
sitegin
(
obj
.
config
)
;
sitegin
(
obj
.
config
)
})
})
.
catch
(
function
(
e
)
{
.
catch
(
function
(
e
)
{
console
.
log
(
e
.
stack
)
;
console
.
log
(
e
.
stack
)
process
.
exit
()
;
process
.
exit
()
})
;
})
})
;
})
var
sitegin
=
function
(
config
)
{
var
sitegin
=
function
(
config
)
{
var
options
=
config
.
options
;
const
options
=
config
.
options
require
(
'
./sitegin/sitegin
'
)({
require
(
'
./sitegin/sitegin
'
)({
watch
:
!
options
.
noserver
&&
!
options
.
nowatch
watch
:
!
options
.
noserver
&&
!
options
.
nowatch
,
})
})
.
then
(
function
onLoad
(
jobs
)
{
.
then
(
function
onLoad
(
jobs
)
{
var
sass
=
require
(
'
node-sass
'
)
;
const
sass
=
require
(
'
node-sass
'
)
var
fs
=
require
(
'
fs
'
)
;
const
fs
=
require
(
'
fs
'
)
// Main builder function
// Main builder function
// If builder is not running - run it
// If builder is not running - run it
// If it is running - schedule rerun after it finishes
// If it is running - schedule rerun after it finishes
var
isRunning
=
false
;
let
isRunning
=
false
var
runAgain
=
false
;
let
runAgain
=
false
var
first
=
false
;
let
first
=
false
var
doSync
=
function
(){}
let
doSync
=
function
()
{}
function
run
()
{
function
run
()
{
var
startTime
=
moment
();
const
startTime
=
moment
()
runAgain
=
false
;
runAgain
=
false
if
(
isRunning
)
{
if
(
isRunning
)
{
console
.
log
(
'
Generator is still running. Queing another run after it finishes.
'
)
console
.
log
(
runAgain
=
true
;
'
Generator is still running. Queing another run after it finishes.
'
,
return
;
)
}
runAgain
=
true
console
.
log
(
'
================================================================================
'
)
return
console
.
log
(
'
Running generator
'
)
isRunning
=
true
;
jobs
.
run
(
'
pipeline
'
,
jobs
)
.
then
(
function
()
{
isRunning
=
false
;
console
.
log
(
'
Generator finished in
'
,
moment
().
diff
(
startTime
,
'
seconds
'
),
'
seconds
'
)
doSync
();
if
(
!
first
)
{
first
=
true
;
copyStaticFiles
(
config
.
builddir
,
config
.
staticDir
,
config
.
themeDir
);
}
}
if
(
runAgain
)
run
();
console
.
log
(
})
'
================================================================================
'
,
.
catch
(
function
(
e
)
{
)
isRunning
=
false
;
console
.
log
(
'
Running generator
'
)
console
.
log
(
'
Generator crashed in
'
,
moment
().
diff
(
startTime
,
'
seconds
'
),
'
seconds
'
)
isRunning
=
true
if
(
runAgain
)
run
();
jobs
if
(
e
.
stack
)
.
run
(
'
pipeline
'
,
jobs
)
console
.
log
(
e
.
stack
)
.
then
(
function
()
{
else
isRunning
=
false
console
.
log
(
e
)
console
.
log
(
if
(
config
.
options
.
noserver
)
process
.
exit
(
13
);
'
Generator finished in
'
,
});
moment
().
diff
(
startTime
,
'
seconds
'
),
}
'
seconds
'
,
)
doSync
()
if
(
!
first
)
{
first
=
true
copyStaticFiles
(
config
.
builddir
,
config
.
staticDir
,
config
.
themeDir
,
)
}
if
(
runAgain
)
run
()
})
.
catch
(
function
(
e
)
{
isRunning
=
false
console
.
log
(
'
Generator crashed in
'
,
moment
().
diff
(
startTime
,
'
seconds
'
),
'
seconds
'
,
)
if
(
runAgain
)
run
()
if
(
e
.
stack
)
console
.
log
(
e
.
stack
)
else
console
.
log
(
e
)
if
(
config
.
options
.
noserver
)
process
.
exit
(
13
)
})
}
console
.
log
(
'
Sitegin successfully loaded
'
);
console
.
log
(
'
Sitegin successfully loaded
'
)
run
();
run
()
rendersass
(
config
.
builddir
,
config
.
themeDir
);
if
(
!
options
.
noserver
)
{
rendersass
(
config
.
builddir
,
config
.
themeDir
)
var
sync
=
require
(
'
browser-sync
'
).
create
();
doSync
=
function
()
{
sync
.
reload
(
'
*
'
)
}
sync
.
init
({
server
:
{
baseDir
:
config
.
builddir
},
ui
:
{
port
:
options
.
port
+
1
},
port
:
options
.
port
});
var
chokidar
=
require
(
'
chokidar
'
);
if
(
!
options
.
noserver
)
{
// article or theme reload
const
sync
=
require
(
'
browser-sync
'
).
create
()
if
(
!
options
.
nowatch
)
{
doSync
=
function
()
{
var
watches
=
[
path
.
join
(
config
.
sourceDir
,
'
articles
'
),
config
.
themeDir
];
sync
.
reload
(
'
*
'
)
console
.
log
(
'
Watching
'
,
watches
,
'
for changes
'
);
}
chokidar
.
watch
(
watches
,
{
ignoreInitial
:
true
})
sync
.
init
({
.
on
(
'
all
'
,
function
(
event
,
path
)
{
server
:
{
console
.
log
(
'
Content or theme changed. Rebuilding...
'
);
baseDir
:
config
.
builddir
,
console
.
log
(
'
Change event:
'
,
event
,
'
on path:
'
,
path
);
},
run
();
ui
:
{
port
:
options
.
port
+
1
,
},
port
:
options
.
port
,
})
})
}
// sitegin reload
const
chokidar
=
require
(
'
chokidar
'
)
jobs
.
onReload
(
function
()
{
// article or theme reload
console
.
log
(
'
Sitegin reloaded
'
);
if
(
!
options
.
nowatch
)
{
run
();
const
watches
=
[
})
path
.
join
(
config
.
sourceDir
,
'
articles
'
),
}
config
.
themeDir
,
})
]
.
catch
(
function
(
e
)
{
console
.
log
(
'
Watching
'
,
watches
,
'
for changes
'
)
console
.
log
(
e
.
stack
);
chokidar
process
.
exit
();
.
watch
(
watches
,
{
ignoreInitial
:
true
})
});
.
on
(
'
all
'
,
function
(
event
,
path
)
{
console
.
log
(
'
Content or theme changed. Rebuilding...
'
)
console
.
log
(
'
Change event:
'
,
event
,
'
on path:
'
,
path
)
run
()
})
}
// sitegin reload
jobs
.
onReload
(
function
()
{
console
.
log
(
'
Sitegin reloaded
'
)
run
()
})
}
})
.
catch
(
function
(
e
)
{
console
.
log
(
e
.
stack
)
process
.
exit
()
})
}
}
var
copyStaticFiles
=
function
(
builddir
,
staticdir
,
themedir
)
{
var
copyStaticFiles
=
function
(
builddir
,
staticdir
,
themedir
)
{
// STATIC FILES
// STATIC FILES
var
fsextra
=
require
(
'
node-fs-extra
'
);
const
fsextra
=
require
(
'
node-fs-extra
'
)
fsextra
.
copy
(
staticdir
,
builddir
,
function
(
file
){
return
!
(
file
.
match
(
'
\\
.git
'
)
||
file
.
match
(
'
static/articles
'
));
},
function
(){
console
.
log
(
'
copy static done
'
);}
);
fsextra
.
copy
(
fsextra
.
copy
(
staticdir
+
'
/articles
'
,
staticdir
,
builddir
+
'
/clanek
'
,
builddir
,
function
(){
console
.
log
(
'
copy static/articles done
'
);}
function
(
file
)
{
);
return
!
(
file
.
match
(
'
\\
.git
'
)
||
file
.
match
(
'
static/articles
'
))
},
function
()
{
console
.
log
(
'
copy static done
'
)
},
)
fsextra
.
copy
(
`
${
staticdir
}
/articles`
,
`
${
builddir
}
/clanek`
,
function
()
{
console
.
log
(
'
copy static/articles done
'
)
})
fsextra
.
copy
(
fsextra
.
copy
(
themedir
+
'
/static
'
,
`
${
themedir
}
/static`
,
builddir
,
builddir
,
function
(
file
){
return
!
file
.
match
(
'
\\
.git
'
)
},
function
(
file
)
{
function
(){
console
.
log
(
'
copy
'
+
themedir
+
'
/static done
'
);}
return
!
file
.
match
(
'
\\
.git
'
)
);
},
function
()
{
console
.
log
(
`copy
${
themedir
}
/static done`
)
},
)
}
}
var
rendersass
=
function
(
builddir
,
themedir
)
{
var
rendersass
=
function
(
builddir
,
themedir
)
{
// SASS
// SASS
var
sass
=
require
(
'
node-sass
'
)
;
const
sass
=
require
(
'
node-sass
'
)
var
fs
=
require
(
'
filendir
'
)
;
const
fs
=
require
(
'
filendir
'
)
sass
.
render
({
file
:
themedir
+
'
/sass/style.scss
'
},
function
(
err
,
result
)
{
sass
.
render
({
file
:
`
${
themedir
}
/sass/style.scss
`
},
function
(
err
,
result
)
{
if
(
err
===
null
)
{
if
(
err
===
null
)
{
console
.
log
(
'
compiled sass
'
)
;
console
.
log
(
'
compiled sass
'
)
fs
.
writeFile
(
builddir
+
'
/theme/style.css
'
,
result
.
css
)
;
fs
.
writeFile
(
`
${
builddir
}
/theme/style.css
`
,
result
.
css
)
}
else
console
.
log
(
'
error
'
,
err
)
;
}
else
console
.
log
(
'
error
'
,
err
)
})
;
})
}
;
}
This diff is collapsed.
Click to expand it.
package.json
+
2
−
1
View file @
47bdda02
...
@@ -4,7 +4,8 @@
...
@@ -4,7 +4,8 @@
"description"
:
""
,
"description"
:
""
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"scripts"
:
{
"scripts"
:
{
"test"
:
"./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- sitegin/tests/ --recursive -R spec -u exports -t 60000"
"test"
:
"./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- sitegin/tests/ --recursive -R spec -u exports -t 60000"
,
"lint"
:
"eslint sitegin index.js"
},
},
"author"
:
""
,
"author"
:
""
,
"license"
:
"UNSPECIFIED"
,
"license"
:
"UNSPECIFIED"
,
...
...
This diff is collapsed.
Click to expand it.
sitegin/image.js
+
3
−
2
View file @
47bdda02
const
youtube
=
require
(
'
./utils/youtube.js
'
)
const
path
=
require
(
'
path
'
)
const
path
=
require
(
'
path
'
)
const
url
=
require
(
'
url
'
)
const
url
=
require
(
'
url
'
)
const
youtube
=
require
(
'
./utils/youtube.js
'
)
const
jobs
=
require
(
'
./jobs
'
)
const
jobs
=
require
(
'
./jobs
'
)
const
{
rewriteURL
}
=
require
(
'
./urls
'
)
const
{
rewriteURL
}
=
require
(
'
./urls
'
)
...
@@ -101,7 +101,8 @@ module.exports = (href_, title, text, curFile_, cfg) => {
...
@@ -101,7 +101,8 @@ module.exports = (href_, title, text, curFile_, cfg) => {
if
(
parsedHref
.
host
)
{
if
(
parsedHref
.
host
)
{
return
genHTML
(
href
,
true
)
return
genHTML
(
href
,
true
)
}
else
if
(
path
.
isAbsolute
(
href
))
{
}
if
(
path
.
isAbsolute
(
href
))
{
return
genHTML
(
href
)
return
genHTML
(
href
)
}
}
curFile
=
curFile
.
replace
(
/
\.
md$/
,
''
)
curFile
=
curFile
.
replace
(
/
\.
md$/
,
''
)
...
...
This diff is collapsed.
Click to expand it.
sitegin/imageResizer.js
+
2
−
2
View file @
47bdda02
...
@@ -48,12 +48,12 @@ module.exports = function imageResizer(file, targetDir, _width, _height) {
...
@@ -48,12 +48,12 @@ module.exports = function imageResizer(file, targetDir, _width, _height) {
doResize
()
doResize
()
}
else
if
(
height
)
{
}
else
if
(
height
)
{
if
(
h
>
height
)
{
if
(
h
>
height
)
{
width
=
Math
.
round
(
height
*
w
/
h
)
width
=
Math
.
round
(
(
height
*
w
)
/
h
)
doResize
()
doResize
()
}
}
}
else
if
(
width
)
{
}
else
if
(
width
)
{
if
(
w
>
width
)
{
if
(
w
>
width
)
{
height
=
Math
.
round
(
width
*
h
/
w
)
height
=
Math
.
round
(
(
width
*
h
)
/
w
)
doResize
()
doResize
()
}
}
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
sitegin/nunjucks.js
+
6
−
4
View file @
47bdda02
...
@@ -111,11 +111,13 @@ module.exports = (data, type_) =>
...
@@ -111,11 +111,13 @@ module.exports = (data, type_) =>
tmpls
.
forEach
(
o
=>
{
tmpls
.
forEach
(
o
=>
{
promises
.
push
(
promises
.
push
(
new
Promise
((
resolve
,
reject
)
=>
{
new
Promise
((
resolve
,
reject
)
=>
{
const
param
=
Object
.
assign
({},
data
,
{
const
param
=
{
config
:
Object
.
assign
({},
data
.
config
,
{
...
data
,
config
:
{
...
data
.
config
,
baseurl
:
config
?
config
.
options
.
baseurl
:
''
,
baseurl
:
config
?
config
.
options
.
baseurl
:
''
,
}
)
,
},
}
)
}
o
.
tmpl
.
render
(
param
,
(
err
,
val
)
=>
{
o
.
tmpl
.
render
(
param
,
(
err
,
val
)
=>
{
if
(
err
)
{
if
(
err
)
{
// reject(new Error('Error rendering template '+o.file));
// reject(new Error('Error rendering template '+o.file));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment