[Rt-commit] rt branch WIP-5.0/add-article-portlet created. rt-5.0.2-282-g0d58279397
BPS Git Server
git at git.bestpractical.com
Wed Jul 13 18:18:30 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, WIP-5.0/add-article-portlet has been created
at 0d58279397f7455248b50db2fd71a902988628c9 (commit)
- Log -----------------------------------------------------------------
commit 0d58279397f7455248b50db2fd71a902988628c9
Author: Brian Conry <bconry at bestpractical.com>
Date: Tue Jul 5 16:15:54 2022 -0500
Add portlet for displaying article content
This commit adds a portlet for displaying article content,
/Articles/Article/Elements/InlineDisplay. This is similar to the one
that prepares an article for inclusion in a reply, but instead of
converting the content to plain/html text, it prepares it for display as
part of the current page.
diff --git a/share/html/Articles/Article/Elements/InlineDisplay b/share/html/Articles/Article/Elements/InlineDisplay
new file mode 100644
index 0000000000..995680f6b3
--- /dev/null
+++ b/share/html/Articles/Article/Elements/InlineDisplay
@@ -0,0 +1,116 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2022 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+
+ <div class="form-row">
+ <div class="label col-3">
+% if ($include{Name}) {
+ #<% $Article->Id %>: <% $Article->Name || loc('(no name)') %>
+% }
+ </div>
+ <div class="label col-9 text-left">
+% if ( $include{Summary} && ($Article->Summary||'') =~ /\S/ ) {
+ <% $Article->Summary %>
+% }
+ </div>
+ </div>
+% while (my $cf = $cfs->Next) {
+% next unless $include{"CF-Title-".$cf->Id} or $include{"CF-Value-".$cf->Id};
+ <div class="form-row">
+% my $values = $Article->CustomFieldValues($cf->Id);
+% if ($values->Count == 0) {
+% }
+% my $first_value = 1;
+% while (my $val = $values->Next) {
+ <div class="label col-3">
+% if ($first_value && $include{"CF-Title-".$cf->Id}) {
+ <% $cf->Name %>:
+% }
+% else {
+% }
+ </div>
+ <div class="value col-9">
+% if ($val && $include{"CF-Value-".$cf->Id}) {
+ <% $get_content->( $val ) |n%>
+% }
+% $first_value = 0;
+ </div>
+% }
+ </div>
+% }
+ <hr class="clear">
+
+<%init>
+my $class = $Article->ClassObj;
+my %include = (Name => 1, Summary => 1, EscapeHTML => 1);
+my $cfs = $class->ArticleCustomFields;
+while ( my $cf = $cfs->Next ) {
+ $include{"CF-Title-" . $cf->Id} = 1;
+ $include{"CF-Value-" . $cf->Id} = 1;
+}
+foreach my $key ( keys %include ) {
+ $include{$key} = not $class->FirstAttribute("Skip-$key");
+}
+
+my $get_content = sub {
+ my $value = shift;
+ return '' unless $value;
+
+ my $content = $value->Content;
+ return '' unless defined $content && length $content;
+
+ if ( $include{'EscapeHTML'} && $content =~ /<.{1,5}>/ ) {
+ $content = $m->interp->apply_escapes( $content, 'h' )
+ }
+
+ return $content;
+};
+
+</%init>
+<%args>
+$Article
+</%args>
diff --git a/share/html/Elements/ArticleContentAsPortlet b/share/html/Elements/ArticleContentAsPortlet
new file mode 100644
index 0000000000..180ab3ec1e
--- /dev/null
+++ b/share/html/Elements/ArticleContentAsPortlet
@@ -0,0 +1,81 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2022 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<&|/Widgets/TitleBox, title => loc($PortletTitle), class => $TitleClass &>
+
+% if ($ContentClass) {
+<div class="<% $ContentClass %>">
+% }
+% if ( $ArticleObj and $ArticleObj->Id ) {
+ <& /Articles/Article/Elements/InlineDisplay, Article => $ArticleObj &>
+% }
+% elsif( $ContentIfEmpty ) {
+ <% $ContentIfEmpty %>
+% }
+% if ($ContentClass) {
+</div>
+% }
+
+</&>
+<%init>
+$ArticleObj ||= RT::Article->new( $session{CurrentUser} );
+
+unless ( $ArticleObj->CurrentUserHasRight('ShowArticle') ) {
+ $ArticleObj->Load(0);
+}
+
+my $ArticleId = $ArticleObj->Id || '';
+$PortletTitle ||= $ArticleObj->ClassObj->Name;
+
+</%init>
+<%ARGS>
+$ArticleObj => undef
+$ContentClass => ''
+$TitleClass => 'article-content'
+$ContentIfEmpty => loc("Article not avialable")
+$PortletTitle => undef
+</%ARGS>
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list