Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
Boop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Marien Fressinaud
Boop
Commits
5d7de713
Commit
5d7de713
authored
Dec 12, 2018
by
Marien Fressinaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require index.html to be at the root folder
parent
99c8bd31
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
30 deletions
+34
-30
README.md
README.md
+19
-24
boop.py
boop.py
+15
-6
No files found.
README.md
View file @
5d7de713
...
...
@@ -32,51 +32,44 @@ $ source ~/.bashrc
## Usage
First, create a project
directory
:
First, create a project
and execute the Boop! command
:
```
console
$
mkdir
my-website
&&
cd
my-website
```
Create a
`./content`
folder and execute the Boop! command:
```
console
$
mkdir
content
$
echo
'<h1>Welcome!</h1>'
>
content/index.html
$
echo
'<h1>Welcome!</h1>'
>
index.html
$
boop.py
Boop!
```
Now, you should have your "production-ready" website under a
`./site`
folder.
For example, if your website consists in a single
`index.html`
page, you should
obtain the following structure:
Now, you should have your "production-ready" website under a
`./site`
folder
that you can upload on your server.
```
console
$
tree
.
├── content
│ └── index.html
├── index.html
└── site
└── index.html
```
Boop! basically just copied
`content`
files under a
`site`
directory. But it
can convert Markdown files in HTML too. For that, you'll need a template file
for articles:
Well OK, Boop! basically just copied the
`index.html`
file under the
`site`
directory. Let's write an article then.
For that, you'll need a template file:
```
console
$
mkdir
theme
$
echo
'<html><body>{{ ARTICLE_CONTENT }}</body></html'
>
theme/article.html
```
Then, you can create
your Markdown file as you did with the HTML one
:
Then, you can create
a Markdown file under a
`./content`
folder
:
```
console
$
echo
'# Welcome!'
>
content/markdown-index.md
$
mkdir
content
$
echo
'# My first article'
>
content/my-article.md
$
boop.py
$
echo
site/m
arkdown-index
.html
<html>
<body><h1>
Welcome!
</h1></body></html>
$
echo
site/m
y-article
.html
<html>
<body><h1>
My first article
</h1></body></html>
```
You can define meta variables in the Markdown file which will be accessible
...
...
@@ -85,7 +78,7 @@ example, for the following Markdown file:
```
markdown
---
title:
Welcome!
title:
An article
author: Marien
---
...
...
@@ -113,10 +106,10 @@ It will produce the following file:
```
html
<html>
<head>
<title>
Welcome!
</title>
<title>
An article
</title>
</head>
<body>
<h1>
Welcome!
</h1>
<h1>
An article
</h1>
<p>
By Marien
</p>
<p>
This is my article.
</p>
...
...
@@ -128,6 +121,8 @@ For now, you can use any valid Python expression between `{{ }}`, you have
access to the variables defined in the meta header, the Python builtin
functions and the
`datetime`
module.
Other files under
`./content`
are copied to the
`./site`
folder.
## Tests
There are some tests (i.e. doctests) that can be run to check that everything
...
...
boop.py
View file @
5d7de713
...
...
@@ -62,12 +62,7 @@ def convert_meta_to_article_vars(meta):
def
main
():
# Check that content directory exists on the filesystem
content_path
=
os
.
path
.
join
(
os
.
curdir
,
"content"
)
if
not
os
.
path
.
isdir
(
content_path
):
raise
ProgramError
(
"./content directory does not exist"
)
# Make sure output dir doesn't exist
# Make sure ./site folder is empty
output_path
=
os
.
path
.
join
(
os
.
curdir
,
"site"
)
if
os
.
path
.
isdir
(
output_path
):
# it should be a directory...
...
...
@@ -75,6 +70,20 @@ def main():
elif
os
.
path
.
exists
(
output_path
):
# ... but it also can be a simple file if user created it manually!
os
.
remove
(
output_path
)
os
.
makedirs
(
output_path
,
exist_ok
=
True
)
# Check that index file exists and copy it under the ./site folder
index_filepath
=
os
.
path
.
join
(
os
.
curdir
,
"index.html"
)
if
not
os
.
path
.
exists
(
index_filepath
):
raise
ProgramError
(
"./index.html file does not exist"
)
index_output_filepath
=
os
.
path
.
join
(
output_path
,
"index.html"
)
shutil
.
copyfile
(
index_filepath
,
index_output_filepath
)
# Check that content directory exists on the filesystem
content_path
=
os
.
path
.
join
(
os
.
curdir
,
"content"
)
if
not
os
.
path
.
isdir
(
content_path
):
# If not, just stop here
return
md
=
markdown
.
Markdown
(
extensions
=
[
"meta"
,
"fenced_code"
,
"attr_list"
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment