Yukki::Model::File - the model for loading and saving files in the wiki
version 0.991_003
my $repository = $app->model('Repository', { repository => 'main' }); my $file = $repository->file({ path => 'foobar', filetype => 'yukki', });
Tools for fetching files from the git repository and storing them there.
Yukki::Model
This is the path to the file in the repository, but without the file suffix.
The suffix of the file. Defaults to "yukki".
This is the the Yukki::Model::Repository the file will be fetched from or stored into.
Allows full_path to be given instead of path and filetype.
full_path
path
filetype
This is the complete path to the file in the repository with the "filetype" tacked onto the end.
This is the base name of the file.
This is a SHA-1 of the file name in hex.
This is the git object ID of the file blob.
This is the title for the file. For most files this is the file name. For files with the "yukki" "filetype", the title metadata or first heading found in the file is used.
This is the size of the file in bytes.
This returns a human-readable version of the file size.
This is the MIME type detected for the file.
$file->store({ content => 'text to put in file...', comment => 'comment describing the change', }); # OR $file->store({ filename => 'file.pdf', comment => 'comment describing the change', });
This stores a new version of the file, either from the given content string or a named local file.
my $new_file = $file->rename({ full_path => 'renamed/to/path.yukki', comment => 'renamed the file', });
Renames the file within the repository. When complete, this method returns a reference to the Yukki::Model::File object representing the new path.
$self->remove({ comment => 'removed the file' });
Removes the file from the repostory. The file is not permanently deleted as it still exists in the version history. However, as of this writing, the API here does not provide any means for getting at a deleted file.
Returns true if the file exists in the repository already.
my $content = $self->fetch; my @lines = $self->fetch;
Returns the contents of the file.
my $yes_or_no = $self->has_format($media_type);
Returns true if the named media type has a format plugin.
my $html_content = $self->fetch_formatted($ctx);
Returns the contents of the file. If there are any configured formatter plugins for the media type of the file, those will be used to return the file.
my @revisions = $self->history;
Returns a list of revisions. Each revision is a hash with the following keys:
The object ID of the commit.
The name of the commti author.
The date the commit was made.
A string showing how long ago the edit took place.
The comment the author made about the comment.
Number of lines added.
Number of lines removed.
my @chunks = $self->diff('a939fe...', 'b7763d...');
Given two object IDs, returns a list of chunks showing the difference between two revisions of this path. Each chunk is a two element array. The first element is the type of chunk and the second is any detail for that chunk.
The types are:
"+" This chunk was added to the second revision. "-" This chunk was removed in the second revision. " " This chunk is the same in both revisions.
my $file_preview = $self->file_preview( content => $content, );
Takes this file and returns a Yukki::Model::FilePreview object, with the file contents "replaced" by the given content.
my @files = $self->list_files;
List the files attached to/under this file path.
my $parent = $self->parent;
Return a Yukki::Model::File representing the parent path of the current file within the current repository. For example, if the current path is:
foo/bar/baz.pdf
the parent of it will be:
foo/bar.yukki
This returns undef if the current file is at the root of the repository.
undef
Returns the repository branch to which this file belongs.
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
This software is copyright (c) 2017 by Qubling Software LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Yukki, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Yukki
CPAN shell
perl -MCPAN -e shell install Yukki
For more information on module installation, please visit the detailed CPAN module installation guide.