The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Slovo::Controller::Role::Stranica - common methods for Stranici and Celini

METHODS

In this role are implemented the following shared methods.

around execute

Wrapper around methods "execute" in Slovo::Controller::Stranici and "execute" in Slovo::Controller::Celini. Most of the work for constructing the page is done here so for Slovo::Controller::Stranici is left only to render everything put by this wrapper into stash. Slovo::Controller::Celini in addition has to find the specific celina to render.

To the wrapped methods are passed the parameters $page, $user, $language, $preview. $page is the current page with the заглавѥ celina in the current $ѩꙁыкъ. $user is the current user. $language is the current $ѩꙁыкъ. $preview is a boolean value - true if the current request is just a preview. In preview mode permissions and c<published> columns of the records in the database are not respected.

Beside constructing the page, if there is a cached page or celina with the requested url path, it is simply slurped and rendered for non autheticated users.

After the rendering is done by the consuming classes, the constructed response body is cached and saved on disk. On the next request by a guest user it is simply rendered, as mentioned above.

Returns the result of $c->render().

around remove

around update

In case a celina or a stranica is updated or removed, all cached pages on disk are deleted. This may fell like small slowdown if you have thousands of cached pages.

b64_images_to_files

  $c->b64_images_to_files('foo');

Cleans up a parameter from base64 images and updates it with path to extracted images.

Expects that the value of the parameter with name 'foo' is a HTML string. Scans it for img tags wich contain base64 encoded image in their src attribute. Decodes the encoded values and saves them in files in the specific domain public directory. The files are named after the alias of the record + count. Example (Second image in the body of a celina record with alias 'hello'): hello1.png. Puts the URL path to the newly created file into the src attribute (e.g. /img/hello01.png). The <src> attributes of the images are replaced with the paths to the newly created files.

SEE ALSO

Slovo::Controller::Celini, Slovo::Controller::Stranici