- rfe: Not being limited to single-worded Tags
- Exposed keywords API to all assets through edit screen. Now keywords are searchable and add metatags for all assets.
This commit is contained in:
parent
17d6151832
commit
d744551c31
4 changed files with 69 additions and 4 deletions
|
|
@ -1,4 +1,7 @@
|
|||
7.5.11
|
||||
- rfe: Not being limited to single-worded Tags
|
||||
- Exposed keywords API to all assets through edit screen. Now keywords are
|
||||
searchable and add metatags for all assets.
|
||||
- fix: template variable isUncommitted is not documented in the help
|
||||
- Cleaned the pollution from the forms system.
|
||||
- fix: Event is no longer editable by anyone who can add events
|
||||
|
|
|
|||
|
|
@ -944,7 +944,16 @@ sub getEditForm {
|
|||
}
|
||||
}
|
||||
|
||||
if ($self->session->setting->get("metaDataEnabled")) {
|
||||
# display keywords field
|
||||
$tabform->getTab('meta')->text(
|
||||
name => 'keywords',
|
||||
value => $self->get('keywords'),
|
||||
label => $i18n->get('keywords'),
|
||||
hoverHelp => $i18n->get('keywords help'),
|
||||
);
|
||||
|
||||
# metadata / content profiling
|
||||
if ($self->session->setting->get("metaDataEnabled")) {
|
||||
my $meta = $self->getMetaDataFields();
|
||||
foreach my $field (keys %$meta) {
|
||||
my $fieldType = $meta->{$field}{fieldType} || "text";
|
||||
|
|
@ -1944,7 +1953,15 @@ Executes what is necessary to make the view() method work with content chunking.
|
|||
sub prepareView {
|
||||
my $self = shift;
|
||||
$self->{_toolbar} = $self->getToolbar;
|
||||
$self->session->style->setRawHeadTags($self->getExtraHeadTags);
|
||||
my $style = $self->session->style;
|
||||
my @keywords = $self->get('keywords');
|
||||
if (scalar @keywords) {
|
||||
$style->setMeta( {
|
||||
name => 'keywords',
|
||||
content => join(',', @keywords),
|
||||
});
|
||||
}
|
||||
$style->setRawHeadTags($self->getExtraHeadTags);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ sub getKeywordsForAsset {
|
|||
return \@keywords;
|
||||
}
|
||||
else {
|
||||
return join(" ", @keywords);
|
||||
return wantarray ? @keywords : join(" ", map({ m/\s/ ? '"' . $_ . '"' : $_ } @keywords));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -266,7 +266,7 @@ sub setKeywordsForAsset {
|
|||
$keywords = $options->{keywords};
|
||||
}
|
||||
else {
|
||||
@{$keywords} = split(" ", $options->{keywords});
|
||||
$keywords = string2list($options->{keywords});
|
||||
}
|
||||
|
||||
$self->deleteKeywordsForAsset($options->{asset});
|
||||
|
|
@ -284,6 +284,45 @@ sub setKeywordsForAsset {
|
|||
}
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
=head2 string2list ( string )
|
||||
|
||||
Returns an array reference of phrases.
|
||||
|
||||
=head3 string
|
||||
|
||||
A scalar containing space separated phrases.
|
||||
|
||||
=cut
|
||||
|
||||
sub string2list {
|
||||
my $text = shift;
|
||||
return if (ref $text);
|
||||
my @words = ();
|
||||
my $word = '';
|
||||
my $errorFlag = 0;
|
||||
while ( defined $text and length $text and not $errorFlag) {
|
||||
if ($text =~ s/\A(?: ([^\"\s\\]+) | \\(.) )//mx) {
|
||||
$word .= $1;
|
||||
}
|
||||
elsif ($text =~ s/\A"((?:[^\"\\]|\\.)*)"//mx) {
|
||||
$word .= $1;
|
||||
}
|
||||
elsif ($text =~ s/\A\s+//m){
|
||||
push(@words, $word);
|
||||
$word = '';
|
||||
}
|
||||
elsif ($text =~ s/\A"//) {
|
||||
$errorFlag = 1;
|
||||
}
|
||||
else {
|
||||
$errorFlag = 1;
|
||||
}
|
||||
}
|
||||
push(@words, $word);
|
||||
return \@words;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@ our $I18N = {
|
|||
context => q|A label for the property that relates assets to keywords.|
|
||||
},
|
||||
|
||||
'keywords help' => {
|
||||
message => q|Add some keywords here for this asset. They'll automatically be added to the search index, and as the keywords metatag.|,
|
||||
lastUpdated => 0,
|
||||
context => q|help for the keywords property|
|
||||
},
|
||||
|
||||
'add the missing page' => {
|
||||
message => q|Add the missing page.|,
|
||||
lastUpdated => 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue