Skip to content

Commit

Permalink
Merge pull request #814 from KuJoe/master
Browse files Browse the repository at this point in the history
RSS Description config option added by @KuJoe
  • Loading branch information
danpros authored Sep 13, 2024
2 parents 651027b + 32388b2 commit cbd8227
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
5 changes: 4 additions & 1 deletion lang/en_US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,7 @@ msg_error_field_req_video = "Video field is required."
msg_error_field_req_link = "Link field is required."
msg_error_field_req_quote = "Quote field is required."
msg_error_field_req_audio = "Audio field is required."
msg_error_field_req_feedurl = "You need to specify the feed url."
msg_error_field_req_feedurl = "You need to specify the feed url."
rss_feeds_description_select = "RSS Description"
rss_description_body = "Post Body"
rss_description_meta = "Post Meta Description"
21 changes: 20 additions & 1 deletion system/admin/views/config-reading.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-static.frontpage" id="static.frontpage1" value="true" <?php if (config('static.frontpage') === 'true'):?>checked<?php endif;?>>
<input class="form-check-input" type="radio" name="-config-static.frontpage" id="static.frontpage2" value="true" <?php if (config('static.frontpage') === 'true'):?>checked<?php endif;?>>
<label class="form-check-label" for="static.frontpage2">
<?php echo i18n('Static_page');?>
</label>
Expand Down Expand Up @@ -134,6 +134,25 @@
<br>
<h4><?php echo i18n('RSS_settings');?></h4>
<hr>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><?php echo i18n('RSS_feeds_description_select');?></label>
<div class="col-sm-10">
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-rss.description" id="rss.description1" value="body" <?php if (config('rss.description') === 'body'):?>checked<?php endif;?>>
<label class="form-check-label" for="rss.description1">
<?php echo i18n('RSS_description_body');?>
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="-config-rss.description" id="rss.description2" value="meta" <?php if (config('rss.description') === 'meta'):?>checked<?php endif;?>>
<label class="form-check-label" for="rss.description2">
<?php echo i18n('RSS_description_meta');?>
</label>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label for="rss.count" class="col-sm-2 col-form-label"><?php echo i18n('RSS_feeds_show_the_most_recent');?></label>
<div class="col-sm-10">
Expand Down
3 changes: 2 additions & 1 deletion system/configList.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@
"autosave.enable",
"mfa.state",
"show.version",
"thumbnail.width"
"thumbnail.width",
"rss.description"
]
16 changes: 12 additions & 4 deletions system/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2992,6 +2992,7 @@ function generate_rss($posts, $data = null)
$channel = new Channel();
$rssLength = config('rss.char');
$data = $data;
$rssDesc = config('rss.description');

if (is_null($data)) {
$channel
Expand All @@ -3009,12 +3010,19 @@ function generate_rss($posts, $data = null)
if ($posts) {
foreach ($posts as $p) {
$img = get_image($p->body);
if (!empty($rssLength)) {
$body = shorten($p->body, $rssLength);
if ($rssDesc == "meta") {
if (!empty($rssLength)) {
$body = shorten($p->description, $rssLength);
} else {
$body = $p->description;
}
} else {
$body = $p->body;
if (!empty($rssLength)) {
$body = shorten($p->body, $rssLength);
} else {
$body = $p->body;
}
}

$item = new Item();
$item
->category(strip_tags($p->category));
Expand Down

0 comments on commit cbd8227

Please sign in to comment.