81 lines
2.0 KiB
Markdown
Raw Normal View History

2018-06-30 11:45:19 +00:00
# Task for new contributors
2024-03-12 10:34:38 +00:00
This task assumes that you have [installed](https://git.akyoto.dev/web/notify.moe#installation) notify.moe already, started the server with the `run` tool and have the code open in Visual Studio Code. It will teach you the basics by creating an entirely empty page within notify.moe.
2018-06-30 11:45:19 +00:00
# Step 1: Create a new page
Let's call it `foobar`. Create a new directory under `pages`, called `foobar`. Then create the following files inside it:
* foobar.go (controller)
```go
package foobar
import (
"github.com/aerogo/aero"
)
2018-06-30 11:51:08 +00:00
// Get returns the contents of our amazing page.
2019-06-01 04:55:49 +00:00
func Get(ctx aero.Context) error {
2018-06-30 11:45:19 +00:00
return ctx.HTML("Hey it's me, foobar!")
}
```
* foobar.pixy (template)
```pixy
component FooBar
h1 Hi!
```
* foobar.scarlet (styles)
```scarlet
.foobar
// Will be used later!
```
`foobar.pixy` and `foobar.scarlet` are currently not used but we'll deal with that later.
## Step 2: Route your page
Your page needs to become available on the `/foobar` route. Let's add it to `pages/index.go`, inside `Configure`:
```go
2019-06-03 03:20:17 +00:00
page.Get(app, "/foobar", foobar.Get)
2018-06-30 11:45:19 +00:00
```
Your IDE should automatically insert the needed package import upon saving the file.
## Step 3: Add sidebar button
Inside `layout/sidebar/sidebar.pixy`, add a new button inside the `Sidebar` component:
```pixy
SidebarButton("Foobar", "/foobar", "plus")
```
## Step 4: Confirm it's there!
Navigate to `beta.notify.moe` and you should see the button to access your newly made page! Yay!
## Step 5: Play around!
2018-06-30 11:54:39 +00:00
Feel free to play around with the code now. You can utilize pixy components by using the `components` package inside your controller:
```go
package foobar
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
)
// Get returns the contents of our amazing page.
2019-06-01 04:55:49 +00:00
func Get(ctx aero.Context) error {
2018-06-30 11:54:39 +00:00
return ctx.HTML(components.FooBar())
}
```
This would now return the contents of your previously defined pixy component instead of a hard-coded string.