Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Added ability to manually set a summary with ---
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Dec 3, 2010
1 parent db8c439 commit dc75099
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
52 changes: 50 additions & 2 deletions components/journal/controllers/entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private function _Prep ( ) {
$row = $this->View->Copy ( '[class=journal-entries]' )->Find ( 'li', 0 );

$this->View->Find ( '.add', 0 )->href = '/profile/' . $this->_Focus->Username . '/journal/add/';
$this->View->Find ( '.rss', 0 )->href = '/profile/' . $this->_Focus->Username . '/journal/rss/';

$rowOriginal = $row->outertext;

Expand All @@ -73,9 +74,13 @@ private function _Prep ( ) {
$row = new cHTML ();
$row->Load ( $rowOriginal );

$url = strtolower ( str_replace ( ' ', '-', $this->Model->Get ( 'Title' ) ) );

$summary = $this->_Summary ( $this->Model->Get ( 'Body' ) );

$row->Find ( '.title-link', 0 )->innertext = $this->Model->Get ( "Title" );
$row->Find ( '.title-link', 0 )->href = '/profile/' . $this->_Focus->Username . '/journal/' . $url;
$row->Find ( '.body', 0 )->innertext = $this->GetSys ( 'Render' )->Format ( $this->Model->Get ( "Body" ) );
$row->Find ( '.body', 0 )->innertext = $summary;

$username = $this->Model->Get ( 'Submitted_Username');
$domain = $this->Model->Get ( 'Submitted_Domain');
Expand All @@ -90,7 +95,6 @@ private function _Prep ( ) {
$row->Find ( '.fullname', 0 )->href = $this->GetSys ( 'Event' )->Trigger ( 'Create', 'User', 'Link', $data );
$row->Find ( '.fullname', 0 )->innertext = $username . '@' . $domain;

$url = strtolower ( str_replace ( ' ', '-', $this->Model->Get ( 'Title' ) ) );
$row->Find ( '.readmore', 0 )->href = '/profile/' . $this->_Focus->Username . '/journal/' . $url;

$row->Find ( '.created', 0 )->innertext = $this->GetSys ( 'Date' )->Format ( $this->Model->Get ( 'Created' ), true );
Expand All @@ -102,6 +106,50 @@ private function _Prep ( ) {
return ( true );
}

private function _Summary ( $pBody ) {

if ( preg_match ( "/---(.+?)---/is", $pBody, $matches ) ) {
$pBody = $matches[1];
}

$summary = $this->GetSys ( 'Render' )->Format ( $pBody );

return ( $summary );

/*
* This code will automatically reduce the summary to 500 characters
*
* Possibly use this for Descriptions for newsfeeds, but not for summaries?
*
*/

$stripped = strip_tags ( $this->GetSys ( 'Render' )->Format ( $pBody ) );

$end = strlen ( $stripped );
if ( strlen ( $stripped ) < 500 ) {
// Return the whole article back.
return ( $this->GetSys ( 'Render' )->Format ( $pBody ) );
} else {
$end = 500;
}

$start = $end - 5;
if ( $start < 0 ) $start = 0;

$split = substr_replace ( $stripped, '##%%&&@@', $start, 5 );

list ( $summary, $null ) = explode ( '##%%&&@@', $split );

//$summary = $summary . $split;

if ( strlen ( $stripped ) > strlen ( $summary ) ) $summary .= '...';

$summary = $this->GetSys ( 'Render' )->Format ( $summary );

return ( $summary );
}


private function _PageCalc ( ) {

$page = $this->GetSys ( 'Request' )->Get ( 'Page');
Expand Down
3 changes: 2 additions & 1 deletion components/journal/languages/en-US/journal.lang
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ PERMALINK="Permalink: "

REMOVE="Delete"

ADD_NEW="New"
ADD_NEW="New"
RSS_FEED="RSS"
1 change: 1 addition & 0 deletions components/journal/views/entries.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<section id="profile-journal">
<a class="add">Add New</a>
<a class="rss">RSS Feed</a>
<nav class="pagination">
</nav>
Expand Down
3 changes: 3 additions & 0 deletions libraries/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public function LiveLinks ( $pString ) {
public function Format ( $pString ) {
eval ( GLOBALS );

// Remove first summary marker pair
$pString = preg_replace ( "/---(.+?)---/is", "$1", $pString, 1 );

$return = ltrim ( rtrim ( $this->TextileThis ( $pString ) ) );

// Add target=__new to all links
Expand Down
4 changes: 2 additions & 2 deletions themes/default/style/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@
/* Journal Entries */
#profile-journal .add { font-size:80%; float:right; padding:1px 5px; -moz-border-radius:5px; -webkit-border-radius:5px; -moz-box-shadow:0px 0px 2px rgba(0,0,0,0.4); -webkit-box-shadow:0px 0px 2px rgba(0,0,0,0.4); color:rgba(0,0,0,0.9); text-shadow:1px 1px 0px rgba(255,255,255,0.8); border:1px solid rgba(0,0,0,0.5); background:-webkit-gradient(linear,0% 0%,0% 100%,from(rgba(255,255,255,1)),to(rgba(185,185,185,1))); background:-moz-linear-gradient(top,rgba(255,255,255,1),rgba(185,185,185,1)); }

#profile-journal .journal-entries .rss { font-size:80%; float:right; padding:1px 5px; -moz-border-radius:5px; -webkit-border-radius:5px; -moz-box-shadow:0px 0px 2px rgba(0,0,0,0.4); -webkit-box-shadow:0px 0px 2px rgba(0,0,0,0.4); color:rgba(0,0,0,0.9); text-shadow:1px 1px 0px rgba(255,255,255,0.8); border:1px solid rgba(0,0,0,0.5); background:-webkit-gradient(linear,0% 0%,0% 100%,from(rgba(255,255,255,1)),to(rgba(185,185,185,1))); background:-moz-linear-gradient(top,rgba(255,255,255,1),rgba(185,185,185,1)); }
#profile-journal .journal-entries .rss:hover { text-decoration:none; }
#profile-journal .rss { font-size:80%; float:left; padding:1px 5px; -moz-border-radius:5px; -webkit-border-radius:5px; -moz-box-shadow:0px 0px 2px rgba(0,0,0,0.4); -webkit-box-shadow:0px 0px 2px rgba(0,0,0,0.4); color:rgba(0,0,0,0.9); text-shadow:1px 1px 0px rgba(255,255,255,0.8); border:1px solid rgba(0,0,0,0.5); background:-webkit-gradient(linear,0% 0%,0% 100%,from(rgba(255,255,255,1)),to(rgba(185,185,185,1))); background:-moz-linear-gradient(top,rgba(255,255,255,1),rgba(185,185,185,1)); }
#profile-journal .rss:hover { text-decoration:none; }

#profile-journal .journal-entries .summary { margin:5px 0; list-style-type:none; float:left; clear:both; width:100%; }
#profile-journal .journal-entries .summary img { float:left; margin: 0px 5px 5px 0; }
Expand Down

0 comments on commit dc75099

Please sign in to comment.