struct Wikicr::Page
- Wikicr::Page
- Struct
- Value
- Object
Overview
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.
Included Modules
Defined in:
lib/page.crlib/page/index.cr
lib/page/index/entry.cr
lib/page/internal_links.cr
lib/page/table_of_content.cr
Constant Summary
-
PAGES_SUB_DIRECTORY =
"pages/"
-
Directory where the pages are stored
-
URL_PREFIX =
"/pages"
-
Beginning of the url of a page
Constructors
Class Method Summary
- .read_title(path : String) : String | Nil
- .sanitize(url : String)
-
.url_to_file(url : String)
translate a name ("/test/title" for example) into a file path ("/srv/data/test/ttle.md)
Instance Method Summary
-
#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 ?
-
#delete(user : Wikicr::User)
Deletes the file, and commit
-
#dirname
Get the directory of the file (~/data/test/home becomes ~/data/test)
-
#exists?
Checks if the file exists
-
#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 -
#path : String
Path of the file that contains the page
-
#read
Reads the file and returns the content.
- #read_title!
-
#real_url : String
Complete Url of the page
-
#real_url_dirname
Real url without the page itself (/test/home becomes /test)
-
#rename(user : Wikicr::User, new_url)
TODO verify if the new_page already exists Move the current page into another place and commit
-
#title : String
Title of the page
-
#url : String
Url of the page (without any prefix)
-
#url_dirname
Url without the page itself (/pages/test/home becomes /pages/test)
-
#write(user : Wikicr::User, body)
Writes into the file, and commit.
Instance methods inherited from module Wikicr::Page::InternalLinks
internal_links(index_context : Wikicr::Page::Index)
internal_links
Class methods inherited from module Wikicr::Page::InternalLinks
get_link(begin_link_text, page_search_text, index, page) : Link
get_link,
links(path : String, index : Wikicr::Page::Index, page : Wikicr::Page)
links,
links_in_content(content : String, index : Wikicr::Page::Index, page : Wikicr::Page)
links_in_content
Instance methods inherited from module Wikicr::Page::TableOfContent
toc : Toc
toc
Class methods inherited from module Wikicr::Page::TableOfContent
get_toc_line(line : String) : TocLine | Nil
get_toc_line,
toc(path : String) : Toc
toc
Constructor Detail
Class Method Detail
translate a name ("/test/title" for example) into a file path ("/srv/data/test/ttle.md)
Instance Method Detail
Save the modifications on the file into the git repository
TODO lock before commit
TODO security of jailed_file and self.name ?
verify if the file is in the current dir (avoid ../ etc.)
it will raise a Error403
if the file is out of the basedir
TODO verify if the new_page already exists Move the current page into another place and commit