support markdown in editor
events can be edited in markdown. markup language can be set in series template for newly created events.
This commit is contained in:
@@ -46,7 +46,7 @@ sub setAttributesFromSeriesTemplate($$$) {
|
||||
my $serie = $series->[0];
|
||||
for my $attr (
|
||||
'program', 'series_name', 'title', 'excerpt', 'topic', 'content', 'html_content', 'project',
|
||||
'category', 'location', 'image', 'live', 'archive_url', 'podcast_url'
|
||||
'category', 'location', 'image', 'live', 'archive_url', 'podcast_url', 'content_format'
|
||||
)
|
||||
{
|
||||
$event->{$attr} = $serie->{$attr};
|
||||
@@ -109,7 +109,7 @@ sub setAttributesFromOtherEvent ($$$){
|
||||
for my $attr (
|
||||
'title', 'user_title', 'excerpt', 'user_excerpt', 'content', 'html_content',
|
||||
'topics', 'image', 'series_image', 'live', 'no_event_sync', 'podcast_url',
|
||||
'archive_url', 'image_label', 'series_image_label'
|
||||
'archive_url', 'image_label', 'series_image_label', 'content_format'
|
||||
)
|
||||
{
|
||||
$event->{$attr} = $event2->{$attr};
|
||||
|
||||
@@ -333,16 +333,22 @@ sub modify_results ($$$$) {
|
||||
&& ( $params->{template} =~ /\.html/ ) )
|
||||
{
|
||||
if ( defined $result->{content} ) {
|
||||
$result->{content} =
|
||||
markup::fix_line_ends( $result->{content} );
|
||||
$result->{content} =
|
||||
markup::creole_to_html( $result->{content} );
|
||||
if (($result->{content_format}//'') eq 'markdown'){
|
||||
$result->{content} = markup::markdown_to_html( $result->{content} );
|
||||
}else{
|
||||
$result->{content} = markup::fix_line_ends( $result->{content} );
|
||||
$result->{content} = markup::creole_to_html( $result->{content} );
|
||||
}
|
||||
$result->{html_content} = $result->{content};
|
||||
|
||||
}
|
||||
|
||||
if ( defined $result->{topic} ) {
|
||||
$result->{topic} = markup::fix_line_ends( $result->{topic} );
|
||||
$result->{topic} = markup::creole_to_html( $result->{topic} );
|
||||
if (($result->{content_format}//'') eq 'markdown'){
|
||||
$result->{topic} = markup::markdown_to_html( $result->{topic} );
|
||||
}else{
|
||||
$result->{topic} = markup::fix_line_ends( $result->{topic} );
|
||||
$result->{topic} = markup::creole_to_html( $result->{topic} );
|
||||
}
|
||||
$result->{html_topic} = $result->{topic};
|
||||
}
|
||||
}
|
||||
@@ -1029,13 +1035,14 @@ sub get_query($$$) {
|
||||
unless ( $get eq 'no_content' ) {
|
||||
if ( $template =~ /\.html/ ) {
|
||||
unless ( $template =~ /menu/ || $template =~ /list/ ) {
|
||||
$query .= ', e.content, e.topic, e.html_content, e.html_topic';
|
||||
$query .= ', e.content, e.topic, e.html_content, e.html_topic, e.content_format
|
||||
';
|
||||
|
||||
#$query.=',html_content content, html_topic topic' ;
|
||||
}
|
||||
} else {
|
||||
unless ( $template =~ /menu/ || $template =~ /list/ ) {
|
||||
$query .= ', e.content, e.topic, e.html_content, e.html_topic';
|
||||
$query .= ', e.content, e.topic, e.html_content, e.html_topic, e.content_format';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use HTML::Parse();
|
||||
use HTML::FormatText();
|
||||
use Encode();
|
||||
use HTML::Entities();
|
||||
use Text::Markdown();
|
||||
|
||||
use log();
|
||||
|
||||
@@ -144,6 +145,13 @@ sub creole_to_html ($) {
|
||||
return $s;
|
||||
}
|
||||
|
||||
sub markdown_to_html($){
|
||||
my $text = $_[0] // '';
|
||||
print STDERR "markwon!\n";
|
||||
my $html = Text::Markdown::markdown($text);
|
||||
return $html;
|
||||
}
|
||||
|
||||
sub creole_to_plain($) {
|
||||
my $s = shift;
|
||||
|
||||
|
||||
@@ -54,12 +54,11 @@ sub save_content($$) {
|
||||
}
|
||||
|
||||
for my $attr ( 'content', 'topic' ) {
|
||||
if ( defined $entry->{$attr} ) {
|
||||
next unless defined $entry->{$attr};
|
||||
if (($entry->{content_format}//'') eq 'markdown'){
|
||||
$entry->{ 'html_' . $attr } = markup::markdown_to_html( $entry->{$attr} );
|
||||
}else{
|
||||
$entry->{ 'html_' . $attr } = markup::creole_to_html( $entry->{$attr} );
|
||||
|
||||
#$entry->{'html_'.$attr}=~s/([^\>])\n+([^\<])/$1<br\/><br\/>$2/g;
|
||||
#$entry->{'html_'.$attr}=~s/^\s*(<p>)?//g;
|
||||
#$entry->{'html_'.$attr}=~s/(<\/p>)?\s*$//g;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +73,8 @@ sub save_content($$) {
|
||||
'html_topic', 'episode', 'image', 'image_label',
|
||||
'series_image', 'series_image_label', 'podcast_url', 'archive_url',
|
||||
'live', 'published', 'playout', 'archived',
|
||||
'rerun', 'draft', 'disable_event_sync', 'modified_by'
|
||||
'rerun', 'draft', 'disable_event_sync', 'modified_by',
|
||||
'content_format'
|
||||
)
|
||||
{
|
||||
push @keys, $key if defined $entry->{$key};
|
||||
@@ -467,8 +467,14 @@ sub insert_event ($$) {
|
||||
{
|
||||
$event->{$attr} = $params->{$attr} if defined $params->{$attr};
|
||||
}
|
||||
$event->{'html_content'} = markup::creole_to_html( $event->{'content'} ) if defined $event->{'content'};
|
||||
$event->{'html_topic'} = markup::creole_to_html( $event->{'topic'} ) if defined $event->{'topic'};
|
||||
|
||||
if (($event->{'content_format'}//'') eq 'markdown'){
|
||||
$event->{'html_content'} = markup::markdown_to_html( $event->{'content'} ) if defined $event->{'content'};
|
||||
$event->{'html_topic'} = markup::markdown_to_html( $event->{'topic'} ) if defined $event->{'topic'};
|
||||
}else{
|
||||
$event->{'html_content'} = markup::creole_to_html( $event->{'content'} ) if defined $event->{'content'};
|
||||
$event->{'html_topic'} = markup::creole_to_html( $event->{'topic'} ) if defined $event->{'topic'};
|
||||
}
|
||||
|
||||
#add event status
|
||||
for my $attr ( 'live', 'published', 'playout', 'archived', 'rerun', 'draft', 'disable_event_sync' ) {
|
||||
|
||||
Reference in New Issue
Block a user