Yukki
view release on metacpan or search on metacpan
lib/Yukki/Model/File.pm view on Meta::CPAN
sub title {
my $self = shift;
if ($self->filetype eq 'yukki') {
LINE: for my $line ($self->fetch) {
if ($line =~ /^#\s*(.*)$/) {
return $1;
}
elsif ($line =~ /:/) {
my ($name, $value) = split m{\s*:\s*}, $line, 2;
return $value if lc($name) eq 'title';
}
else {
last LINE;
}
}
}
my $title = $self->file_name;
$title =~ s/\.(\w+)$//g;
lib/Yukki/Model/File.pm view on Meta::CPAN
sub media_type {
my $self = shift;
return guess_media_type($self->full_path);
}
sub store {
my ($self, $params) = @_;
my $path = $self->full_path;
my (@parts) = split m{/}, $path;
my $blob_name = $parts[-1];
my $object_id;
if ($params->{content}) {
$object_id = $self->make_blob($blob_name, $params->{content});
}
elsif ($params->{filename}) {
$object_id = $self->make_blob_from_file($blob_name, $params->{filename});
}
http_throw("unable to create blob for $path") unless $object_id;
lib/Yukki/Model/File.pm view on Meta::CPAN
unless $commit_id;
$self->update_root($old_tree_id, $commit_id);
}
sub rename {
my ($self, $params) = @_;
my $old_path = $self->full_path;
my (@new_parts) = split m{/}, $params->{full_path};
my (@old_parts) = split m{/}, $old_path;
my $blob_name = $old_parts[-1];
my $object_id = $self->object_id;
my $old_tree_id = $self->find_root;
http_throw("unable to locate original tree ID for ".$self->branch)
unless $old_tree_id;
my $new_tree_id = $self->make_tree(
$old_tree_id, \@old_parts, \@new_parts, $object_id);
lib/Yukki/Model/File.pm view on Meta::CPAN
repository => $self->repository,
full_path => $params->{full_path},
);
}
sub remove {
my ($self, $params) = @_;
my $old_path = $self->full_path;
my (@old_parts) = split m{/}, $old_path;
my $old_tree_id = $self->find_root;
http_throw("unable to locate original tree ID for ".$self->branch)
unless $old_tree_id;
my $new_tree_id = $self->make_tree($old_tree_id, \@old_parts);
http_throw("unable to create the new tree removing $old_path\n")
unless $new_tree_id;
my $commit_id = $self->commit_tree($old_tree_id, $new_tree_id, $params->{comment});
lib/Yukki/Model/File.pm view on Meta::CPAN
sub list_files {
my ($self) = @_;
return $self->repository->list_files($self->path);
}
sub parent {
my $self = shift;
my @parts = split m{/}, $self->path;
return if @parts == 1;
pop @parts;
return Yukki::Model::File->new(
app => $self->app,
repository => $self->repository,
path => join('/', @parts),
);
}
lib/Yukki/Web/Controller/Page.pm view on Meta::CPAN
my $repo_name = $ctx->request->path_parameters->{repository};
my $path = $ctx->request->path_parameters->{page};
if (not defined $path) {
my $repo_config
= $self->app->settings->repositories->{$repo_name};
my $path_str = $repo_config->default_page;
$path = [ split m{/}, $path_str ];
}
return ($repo_name, $path);
}
sub lookup_page {
my ($self, $repo_name, $page) = @_;
my $repository = $self->model('Repository', { name => $repo_name });
lib/Yukki/Web/Controller/Page.pm view on Meta::CPAN
sub upload_attachment {
my ($self, $ctx) = @_;
my $repo_name = $ctx->request->path_parameters->{repository};
my $path = delete $ctx->request->path_parameters->{page};
my $page = $self->lookup_page($repo_name, $path);
my @file = split m{/}, $page->path;
push @file, $ctx->request->uploads->{file}->filename;
$ctx->request->path_parameters->{action} = 'upload';
$ctx->request->path_parameters->{file} = \@file;
$self->controller('Attachment')->fire($ctx);
}
sub breadcrumb {
lib/Yukki/Web/Plugin/Attachment.pm view on Meta::CPAN
}x) {
my $repository = $1 // $file->repository_name;
my $page = $file->full_path;
my $link = $2;
$link =~ s/^\s+//; $link =~ s/\s+$//;
$page =~ s{\.yukki$}{};
$link = join "/", map { uri_escape($_) } split m{/}, $link;
if ($link =~ m{^/}) {
return $ctx->rebae_url("attachment/view/$repository$link");
}
else {
return $ctx->rebase_url("attachment/view/$repository/$page/$link");
}
}
return;
( run in 0.890 second using v1.01-cache-2.11-cpan-71847e10f99 )