Skip to the page
Najova

we

webNaja Built in

Websites and APIs in Najova: pages, layout, styles and the back end in the same file. Built into Najova.

By NylonLabs

Official Najova Extension

About webNaja

Readme

webNaja

webNaja is built into Najova: websites and APIs with the front end and the back end in the same file. There is nothing to install, and it can't be removed.

A page is a .wnaj file. Its address comes from where it is in the project: about.wnaj is /about, and guides/[name].wnaj answers any guide name.

$page[Sunrise Bakery]
  $heading[Fresh bread every morning]
  $paragraph[Open from 7 until 2, every day but Monday.]
$endpage
  • naja serve runs the site on your own computer while you work on it.
  • naja build --web writes plain HTML files you can put on any host.
  • Styles, themes, page parts and requests are in the Page parts and Websites and APIs reference, and the Web pages guide.

Packages

webNaja is an extension like any other, so anyone can make packages for it: page parts, styles or helpers that switch on in a project.

Functions (46)

These come with Najova. Each one's full page, with a working example, is in the Functions reference.

$request

$request
$request[part]

In a webNaja page: the request being answered. Parts: method, path, body, ip, query.<name>, form.<name>, header.<name>, cookie.<name>; with nothing, a table of all of them.

$thread

$thread[html] ... $endthread

Writes another language straight into the file: the lines up to $endthread are HTML, with Najova calls inside them ($get[name] and so on; their text is made safe for HTML). On the first line it threads the whole file.

$escapeHtml

$escapeHtml[text]

The text with < > & " and ' written so a browser shows them instead of reading them as HTML.

$rawHtml

$rawHtml[text]

Inside $thread[html]: puts the text in the page as HTML, without making it safe first. Only for HTML you trust.

$status

$status[code]

In a webNaja page: the answer's status code, like $status[404].

$setHeader

$setHeader[name;value]

In a webNaja page: a header of the answer, like $setHeader[Content-Type;application/json].

$setCookie

$setCookie[name;value]
$setCookie[name;value;seconds]

In a webNaja page: keeps a value in the visitor's browser (for the seconds given, or until it closes).

$paths

$paths[list]

In a page whose address has a [value] part (like [group].wnaj): the values it has, like $paths[$list[maths;text]]. naja build --web makes one page for each; naja serve answers 404 for any other. With more than one [value], each is a table: $table[ext;discord;pkg;xp]. Put it near the top.

$redirect

$redirect[path]

In a webNaja page: sends the visitor to another page instead, like $redirect[/login]. The rest of the page does not run.

$sendJson

$sendJson[value]
$sendJson[value;status]

In a webNaja page: answers with the value as JSON instead of a page (for APIs), like $sendJson[$get[user]].

$session

$session
$session[name]

In a webNaja page: a value kept for this visitor between pages (nothing if not set); with nothing, a table of all of them.

$setSession

$setSession[name;value]

In a webNaja page: keeps a value for this visitor between pages, like $setSession[user;$get[name]]; an empty value removes it.

$endSession

$endSession

In a webNaja page: forgets everything kept for this visitor (signing out).

$rateLimit

$rateLimit[times;seconds]

In a webNaja page: lets each visitor load this page at most so many times in so many seconds; after that it answers 429 Too many requests.

$page

$page ... $endpage

In a webNaja page: the whole page: its title, then the parts in it. Settings: lang=, description=; index=no keeps it out of search results.

$heading

$heading[text]
$heading[text;level]

In a webNaja page: a heading (the first is level 1, later ones 2). id= sets its address (#id); tag=Planned puts a small label after it.

$paragraph

$paragraph[text]

In a webNaja page: a paragraph of text, where `code`, **bold**, *italic* and [text](/x) work; marks=no shows the text exactly as written.

$section

$section ... $endsection

In a webNaja page: a part of the page, with an optional title.

$row

$row ... $endrow

In a webNaja page: parts side by side (they wrap on narrow screens). Settings: gap=, align=, justify=.

$column

$column ... $endcolumn

In a webNaja page: parts one under another. Settings: gap=, align=.

$grid

$grid ... $endgrid

In a webNaja page: parts in columns that become one column on phones. Settings: cols=, gap=.

$items

$items ... $enditems

In a webNaja page: a list: each part inside is one item. type=numbered numbers them, for steps in order.

$link[text;where]

In a webNaja page: a link; look=primary makes it a button. new=yes opens a new tab; icon=home puts an icon before it, tag=Planned a small label and count=14 a number after it.

$image

$image[file;what it shows]

In a webNaja page: a picture, with words for people who cannot see it.

$button

$button[text]
$button[text;where]

In a webNaja page: a button; with a name= its click reaches $on[name.Clicked]; look=primary|quiet.

$input

$input[name;label]

In a webNaja page: a field to type in. Settings: type=text|email|password|number|textarea|checkbox, placeholder=, value=, required=yes.

$form

$form ... $endform

In a webNaja page: fields and a button that send to the page (or the path given). Settings: method=post|get, name= for $on[name.Submitted].

$theme

$theme ... $endtheme

In a webNaja page: the theme's named values, one per line: accent = #a690ff, and page = #0f1017 ; dark for the dark look only. webNaja reads page, text, muted, surface, border, accent, on-accent, font, mono, radius, space and code-bg, code-call, code-text, code-num, code-block, code-op; any other name is yours to use as theme.name in a style.

$style

$style[name] ... $endstyle

In a webNaja page: a named style parts take with style=name. Lines are name = value (padding, corner, text, background ... or CSS names like margin), and can end with when they count: ; hover, ; phone, ; below 960, ; dark, ; for link.

$motion

$motion[name] ... $endmotion

In a webNaja page: an animation styles use with animation = name 0.3s ease. Lines say when: opacity = 0 ; from, opacity = 1 ; to (or ; 50%).

$font

$font[name;file]

In a webNaja page: a font file the page uses, like $font[Onest;fonts/onest.woff2;weight=100 900]. Then font = Onest in $theme.

$sidebar

$sidebar[label] ... $endsidebar

In a webNaja page: a side column beside the rest of the page (straight inside $page). On a phone it folds into a Menu button.

$nav

$nav[title] ... $endnav

In a webNaja page: a group of links. With a title it opens and shuts (open=no starts it shut); the link to the page you are on is marked.

$tabs

$tabs ... $endtabs

In a webNaja page: tabs. Each $tab[title] ... $endtab inside is one; the first shows, arrow keys move between them.

$tab

$tab[title] ... $endtab

In a webNaja page: one tab of a $tabs.

$sheet

$sheet[column;column...] ... $endsheet

In a webNaja page: a table with the columns named, and a $cells[...] line for each row.

$cells

$cells[value;value...]

In a webNaja page: one row of a $sheet.

$code

$code[code;file=name]

In a webNaja page: a code panel with Najova code coloured, the file name on top and a Copy button. lang=plain shows other text as it is, lang=output what a script printed; copy=no leaves out the Copy button; tag=not run here puts a small label after the file name.

$search[placeholder;index]

In a webNaja page: a search box over the site's search.json (a list of title, url and text), with arrow keys and / to jump to it. look=button makes it a button that opens a search panel (also with Ctrl K).

$filter

$filter[placeholder;list=id]

In a webNaja page: a box that hides the items of $items[id=...] that do not have the words typed, and says how many show. empty= is what it says when nothing matches; note= follows the count on its line.

$progress

$progress[value;most]

In a webNaja page: a bar filled to value out of most (100 when left out), like $progress[8;29]; label= is what screen readers say instead of 8 of 29.

$themePick

$themePick[light text;dark text]

In a webNaja page: Light and Dark buttons; the pick is remembered, else the computer's look is used. look=button makes it one button that flips between them (its text is what screen readers say).

$icon

$icon[name]

In a webNaja page: one of webNaja's icons (home, box, book, fn, search, sun, moon, menu, down, eye, clock, user, next, back, check, copy, badge, terminal), drawn in the text's colour. Links, nav groups, $search and $sidebar take icon=name too.

$contents

$contents[title]

In a webNaja page: links to the page's headings (On this page when no title is given), the one you are reading marked as you scroll.

$markdown

$markdown[text
file.md]

In a webNaja page: Markdown as page parts: # headings, lists, tables, > quotes and ``` code (Najova coloured). Give the text, or a .md file in the site's folder. level=3 makes a # heading an h3 (2 if not set).

$children

$children

In a $function: where the parts written inside it go. Then $card[Title] ... $endcard holds other parts, like $section does.

Packages (0)

No packages yet. Anyone can make a package for webNaja once the Najova 1.0 registry opens.

Changelog

webNaja changes with Najova itself: see Updates.

Install

Built into Najova. There's nothing to install, and it can't be removed.

Version

Comes with Najova