Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build resma docs #20

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
description = ""
authors = ["Thiago Campos <commit@thigcampos.com>", "Ivan Santiago <ivansantiago.junior@gmail.com>"]
readme = "README.md"
packages = [{include = "resma"}]

[tool.poetry.scripts]
resma = "resma.main:app"
Expand Down
2 changes: 2 additions & 0 deletions resma.dev/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[resma]
name = "resma.dev"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about renaming this folder as docs or www?

7 changes: 7 additions & 0 deletions resma.dev/content/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
+++
title = 'resma'
template = 'index.html'
+++

Resma is an easy to use SSG (Static Site Generator).
A <a href="https://brasilis.club/" target="_blank">Brasilis Club</a> project.
Comment on lines +6 to +7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be a Portuguese version of it? We might need to think about adding support to internationalization.

7 changes: 7 additions & 0 deletions resma.dev/content/docs/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
+++
title = 'resma docs'
template = 'index.html'
+++

# Docs initial page
Docs will be here
46 changes: 46 additions & 0 deletions resma.dev/public/docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="https://copan.brasilis.club/colors.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/form.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/media.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/layout.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/text.css" crossorigin="anonymous" />

<title>resma docs</title>
<link rel="stylesheet" href="/styles/homepage.css" />

</head>
<body>

<main>
<section class="space-between">
<header>
<nav>
<a href="/">Resma</a>
</nav>
<nav>
<a href="/docs">Documentation</a>
</nav>
</header>
<div><h1>Docs initial page</h1>
<p>Docs will be here</p></div>
<footer>
<nav>
<a href="https://github.com/brasilisclub/resma" target="_blank">
Built with <b>Resma</b>
</a>
<a href="https://github.com/brasilisclub/resma" target="_blank">
From <b>Brazil</b> with Love
</a>
</nav>
</footer>
</section>
</main>

</body>
</html>
46 changes: 46 additions & 0 deletions resma.dev/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="https://copan.brasilis.club/colors.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/form.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/media.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/layout.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/text.css" crossorigin="anonymous" />

<title>resma</title>
<link rel="stylesheet" href="/styles/homepage.css" />

</head>
<body>

<main>
<section class="space-between">
<header>
<nav>
<a href="/">Resma</a>
</nav>
<nav>
<a href="/docs">Documentation</a>
</nav>
</header>
<div><p>Resma is an easy to use SSG (Static Site Generator).
A <a href="https://brasilis.club/" target="_blank">Brasilis Club</a> project.</p></div>
<footer>
<nav>
<a href="https://github.com/brasilisclub/resma" target="_blank">
Built with <b>Resma</b>
</a>
<a href="https://github.com/brasilisclub/resma" target="_blank">
From <b>Brazil</b> with Love
</a>
</nav>
</footer>
</section>
</main>

</body>
</html>
12 changes: 12 additions & 0 deletions resma.dev/public/styles/homepage.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.space-between {
display: flex;
flex-direction: column;
justify-content: space-between;
}

header,
footer {
display: flex;
width: 100%;
justify-content: space-between;
}
12 changes: 12 additions & 0 deletions resma.dev/styles/homepage.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.space-between {
display: flex;
flex-direction: column;
justify-content: space-between;
}

header,
footer {
display: flex;
width: 100%;
justify-content: space-between;
}
18 changes: 18 additions & 0 deletions resma.dev/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="https://copan.brasilis.club/colors.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/form.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/media.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/layout.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://copan.brasilis.club/text.css" crossorigin="anonymous" />
{% block header %}{% endblock header %}
</head>
<body>
{% block content %}{% endblock content %}
</body>
</html>
28 changes: 28 additions & 0 deletions resma.dev/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% extends "base.html" %} {% block header %}
<title>{{ page.title }}</title>
<link rel="stylesheet" href="/styles/homepage.css" />
{% endblock header %} {% block content %}
<main>
<section class="space-between">
<header>
<nav>
<a href="/">Resma</a>
</nav>
<nav>
<a href="/docs">Documentation</a>
</nav>
</header>
<div>{{ page.content }}</div>
<footer>
<nav>
<a href="https://github.com/brasilisclub/resma" target="_blank">
Built with <b>Resma</b>
</a>
<a href="https://github.com/brasilisclub/resma" target="_blank">
From <b>Brazil</b> with Love
</a>
</nav>
</footer>
</section>
</main>
{% endblock content %}
19 changes: 14 additions & 5 deletions resma/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import typer
from jinja2 import Environment, FileSystemLoader
from typer import Typer
from typer import Context, Typer

from resma import __version__

Expand Down Expand Up @@ -43,18 +43,22 @@ def validate_resma_project():
raise typer.Abort()


def get_version(flag):
def get_version(flag: bool):
if flag:
print(__version__)
raise typer.Exit()


@app.callback(invoke_without_command=True)
def main(
ctx: Context,
version: Annotated[
bool, typer.Option(callback=get_version, is_flag=True)
bool, typer.Option(callback=get_version, is_flag=True, is_eager=True)
] = False,
):
"""Resma CLI Static Site Generator"""
if ctx.invoked_subcommand:
return
resma_command = typer.style('resma --help', fg=typer.colors.GREEN)
print(f'Use {resma_command} to see the available commands')

Expand Down Expand Up @@ -198,8 +202,13 @@ def do_GET(self):
def serve(port: int = 8080):
"""Run a http server from public folder"""
Handler = CustomHTTPRequestHandler

os.chdir('public')
try:
os.chdir('public')
except FileNotFoundError as e:
typer.secho('public folder not found', fg=typer.colors.RED)
resma_build = typer.style('resma build', fg=typer.colors.GREEN)
typer.secho(f'Run {resma_build} before running "resma serve" again')
raise typer.Abort() from e

with socketserver.TCPServer(('', port), Handler) as httpd:
typer.secho(
Expand Down
Loading