-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 527e6bd
Showing
22 changed files
with
1,397 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Deploy Docs | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | ||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
deploy: | ||
name: deploy docs | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Pages | ||
uses: actions/configure-pages@v5 | ||
- name: Setup Doco | ||
run: > | ||
wget https://github.com/paganotoni/doco/releases/latest/download/doco_Linux_x86_64.tar.gz && | ||
tar -xvf doco_Linux_x86_64.tar.gz | ||
- run: ./doco build | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: "public" | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
name: Leapkit | ||
description: "LeapKit a collection of tools to help you build your next application with Go" | ||
keywords: "golange,tooling,kit,leapkit,leap,go" | ||
|
||
# Index defines where the pages in the root will be positioned. | ||
index: -1 | ||
favicon: "/assets/favicon.png" | ||
logo: | ||
src: "/assets/logo.svg" | ||
link: "/" | ||
|
||
# announcement: | ||
# text: "Check our Github repository" | ||
# link: "https://github.com/leapkit/leapkit/template" | ||
|
||
github: "https://github.com/leapkit/leapkit" | ||
external_links: | ||
text: "Documentation" | ||
link: "/" | ||
|
||
# QuickLinks go on top of the left navigation bar and | ||
|
||
# show on the quick search modal by default. | ||
|
||
quick_links: | ||
- text: "Documentation" | ||
link: "/" | ||
icon: "menu_book" | ||
- text: "Repo" | ||
link: "https://github.com/leapkit/leapkit" | ||
icon: "developer_guide" | ||
|
||
# CTA button shows on the top right of the site. | ||
# cta: | ||
# text: "Star on Github" | ||
# link: "https://github.com/paganotoni/doco" | ||
|
||
# Shows on each of the documentation pages | ||
# $YEAR is replaced with the current year. | ||
copy: "© $YEAR LeapKit" | ||
--- |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
index: 2 | ||
title: "CLI" | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
index: 2 | ||
title: "Database" | ||
--- | ||
|
||
The kit CLI provides several commands for managing the database. | ||
|
||
```bash | ||
$ kit [database|db] <commands> | ||
``` | ||
|
||
## Creating a new database | ||
|
||
To create your database, you need to run the `kit [database|db] create` command. This command creates a new database using the value from the `DATABASE_URL` environment variable. The type of database engine will depend on the type of database URL set. Currently, Leapkit supports the creation of `SQLite3` and `PostgreSQL` databases. | ||
```toml | ||
# .env | ||
DATABASE_URL=postgres://user:password@host:5432/database | ||
``` | ||
|
||
```bash | ||
$ kit [database|db] create | ||
✅ Database created successfully | ||
``` | ||
|
||
|
||
## Running migrations | ||
|
||
To migrate the database to the latest version, you need to run the `kit db migrate`. This command applies any pending migrations to the database, ensuring it is up-to-date with the latest changes | ||
|
||
```bash | ||
$ kit [database|db] migrate | ||
✅ Migrations ran successfully | ||
``` | ||
|
||
## Deleting database | ||
|
||
To delete the existing database, you need to run the `kit db drop` command. This command permanently deletes the database, **so use with caution**. | ||
|
||
```bash | ||
$ kit [database|db] drop | ||
✅ Database dropped successfully | ||
``` | ||
|
||
## Resetting database | ||
|
||
The `kit db reset` command drops the existing database, creates a new one, and runs pending migrations. This command is useful for quickly resetting the database to a clean state. | ||
|
||
```bash | ||
$ kit db reset | ||
✅ Database reset successfully | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
index: 3 | ||
title: "Generators" | ||
--- | ||
|
||
The Leapkit CLI also provides generator that helps you to create different components such as migrations, handlers or actions. | ||
|
||
|
||
```bash | ||
$ kit [generate|g] commands | ||
``` | ||
|
||
## Generating migrations | ||
|
||
To generate a new migration, you need to run the `kit g migration <migration_name>`. It will generate a `.sql` file where you can place the change that wou will apply to the database. | ||
|
||
```bash | ||
$ kit g migration create_users_table | ||
✅ Migration file `create_users_table` generated | ||
``` | ||
|
||
```text | ||
├── internal/ | ||
│ └── migrations/ | ||
│ └── 20060102030405_create_users_table.sql | ||
``` | ||
|
||
The new migration file will follow the naming convention `yyyyMMddhhmmss_migration_name.sql`, and will be placed in the `internal/migrations` folder by default. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
index: 0 | ||
title: "Installing" | ||
--- | ||
|
||
To install the kit CLI you can use the following command: | ||
|
||
```sh | ||
go install github.com/leapkit/leapkit/kit@latest | ||
``` | ||
|
||
This will install the latest version of the kit CLI in your `$GOPATH/bin` directory. Make sure your `$GOPATH/bin` directory is in your PATH. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
index: 1 | ||
title: "Creating new app" | ||
--- | ||
|
||
To start a new Leapkit app, you need to run the following command: | ||
|
||
```bash | ||
$ kit new <app_name> | ||
``` | ||
|
||
This will create a new directory with the name of your app into the current path. | ||
|
||
## Folder structure | ||
|
||
The Leapkit directory will contain the following structure: | ||
|
||
```text | ||
├── bin/ | ||
├── cmd/ | ||
│ ├── app/ | ||
│ │ └── main.go | ||
│ ├── migrate/ | ||
│ │ └── migrate.go | ||
│ └── setup/ | ||
│ └── main.go | ||
├── internal/ | ||
│ ├── assets/ | ||
│ │ ├── application.css | ||
│ │ └── application.js | ||
│ ├── home/ | ||
│ │ ├── index.go | ||
│ │ └── index.html | ||
│ ├── migrations/ | ||
│ │ ├── 0_pragmas.sql | ||
│ │ └── migrations.go | ||
│ ├── app.go | ||
│ └── layout.html | ||
├── public/ | ||
│ └── public.go | ||
├── .dockerignore | ||
├── database.db | ||
├── .Dockerfile | ||
├── go.mod | ||
├── go.sum | ||
├── LICENSE | ||
├── README.md | ||
└── tailwind.config.js | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
index: 4 | ||
title: "Serving your app" | ||
--- | ||
|
||
To run your Leapkit app you need to run the `kit dev` command. This command will run the app in `development` mode, automatically detecting changes in your `.go`, `.css`, and `.js` files. | ||
|
||
```bash | ||
$ kit dev | ||
Tailwind CSS CLI binary already exists. | ||
[tailo] Running: bin/tailwindcss --config tailwind.config.js --input internal/assets/application.css --output public/application.css | ||
[tailo] Rebuilding... | ||
[tailo] Done in 95ms. | ||
[info] Restarting the server | ||
[error] signal: killed | ||
Server started at 0.0.0.0:3000 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
index: 4 | ||
title: "Assets" | ||
--- | ||
|
||
The assets package provides a way to manage web assets in your web application. It receives a folder where your assets are on the disk and returns an http.Handler that serves these files. | ||
|
||
This handler is capable of a few things that are useful for web development: | ||
- Asset fingerprinting (to avoid caching issues) | ||
- Hot code reloading (when the assets change on disk) | ||
|
||
## Usage | ||
|
||
To set our assets into our Leapkit app, we need to use the `WithAssets` server option. It receives an FS parameter that will help locate template files to be served. | ||
|
||
```go | ||
|
||
//go:embed templates/**/*.html | ||
var templatesFS embed.FS | ||
|
||
s := server.New( | ||
server.WithAssets(templatesFS), | ||
) | ||
``` | ||
|
||
## Fingerprinting Helper | ||
The `server.WithAssets` option also setus the `assetsPath` helper that can be used in your templates to use the fingerprinted version of an asset. | ||
|
||
```html | ||
<link rel="stylesheet" href="<%= assetPath(`/css/app.css`) %>"> | ||
// will output something like | ||
<link rel="stylesheet" href="/css/app-cafe123ff22112eedd.css"> | ||
``` | ||
|
||
## Hotcode Reloading | ||
The assets managers provides a handler function capable of serving the files in the assets filesystem. This handler considers the `GO_ENV` variable to look in for files in disk before looking into the embedded filesystem passed. |
Oops, something went wrong.