struct

Wikicr::Page

Inherits Wikicr::Page::InternalLinks / Wikicr::Page::TableOfContent / Struct / Value / Object

A Page is the representation in the wiki of something that can be accessed from an url /pages/*path.

It is used to associate path, url and data. Is is can also jails the path into the OPTIONS.basedir to be sure that there is no attack by writing files outside of the directory where the pages must be stored.

Constants

PAGES_SUB_DIRECTORY = "pages/"

Directory where the pages are stored

URL_PREFIX = "/pages"

Beginning of the url of a page

Constructors

new(url : String, real_url : Bool = false, read_title : Bool = false)
Source

Class methods

read_title(path : String) : String | Nil
Source
sanitize(url : String)
Source
url_to_file(url : String)

translate a name ("/test/title" for example) into a file path ("/srv/data/test/ttle.md)

Source

Instance methods

commit!(user : Wikicr::User, message, other_files : Array(String) = [] of String)

Save the modifications on the file into the git repository TODO: lock before commit TODO: security of jailed_file and self.name ?

Source
delete(user : Wikicr::User)

Deletes the file, and commit

Source
dirname

Get the directory of the file (~/data/test/home becomes ~/data/test)

Source
exists?

Checks if the file exists

Source
jail

verify if the file is in the current dir (avoid ../ etc.) it will raise a Error403 if the file is out of the basedir

Source
path

Path of the file that contains the page

Source
read

Reads the file and returns the content.

Source
read_title!
Source
real_url

Complete Url of the page

Source
real_url_dirname

Real url without the page itself (/test/home becomes /test)

Source
rename(user : Wikicr::User, new_url)

TODO: verify if the new_page already exists Move the current page into another place and commit

Source
title

Title of the page

Source
url

Url of the page (without any prefix)

Source
url_dirname

Url without the page itself (/pages/test/home becomes /pages/test)

Source
write(user : Wikicr::User, body)

Writes into the file, and commit.

Source

Nested types