clean up the webpage list a bit

This commit is contained in:
friendica 2014-04-29 18:28:05 -07:00
parent 5c8c555461
commit 31fd284b3c
7 changed files with 128 additions and 101 deletions

View File

@ -164,7 +164,7 @@ $(document).ready(function() {
<div style="color:#808080;font-weight:bold;font-size:3.0em; margin-bottom:30px;">Dream it. Do it.</div> <div style="color:#808080;font-weight:bold;font-size:3.0em; margin-bottom:30px;">Dream it. Do it.</div>
<div id="word-flasher" style="font-size: 3.0em; font-weight: bold; margin-bottom: 30px;">RedMatrix</div> <div id="word-flasher" style="font-size: 3.0em; font-weight: bold; margin-bottom: 30px;">RedMatrix</div>
<div class="tr" style="font-size: 1.6em; color: #666; margin-left: 75px; margin-right: 75px;"> <div class="tr" style="font-size: 1.6em; color: #666; margin-left: 75px; margin-right: 75px;">
The RedMatrix (aka "red") is an open source webapp providing a complete <strong>decentralised</strong> publishing, sharing, and communications system. It provides communications (private messaging, chat and social networking), media management (photos, events, files, web pages) and enough other features to make your head spin. The RedMatrix (aka "red") is an open source webapp providing a complete <strong>decentralised</strong> publishing, sharing, and communications system. It provides communications (private messaging, chat and social networking), media management (photos, events, files, web pages) and enough features to make your head spin.
</div> </div>
<br /> <br />
<div class="tr" style="font-size: 1.6em; color: #666; margin-left: 75px; margin-right: 75px;"> <div class="tr" style="font-size: 1.6em; color: #666; margin-left: 75px; margin-right: 75px;">

View File

@ -3,37 +3,47 @@
// A basic toolbar for observers with write_pages permissions // A basic toolbar for observers with write_pages permissions
function writepages_widget ($who,$which){ function writepages_widget ($who,$which){
return replace_macros(get_markup_template('write_pages.tpl'), array( return replace_macros(get_markup_template('write_pages.tpl'), array(
'$new' => t('New Page'), '$new' => t('New Page'),
'$newurl' => "webpages/$who", '$newurl' => "webpages/$who",
'$edit' => t('Edit'), '$edit' => t('Edit'),
'$editurl' => "editwebpage/$who/$which" '$editurl' => "editwebpage/$who/$which"
)); ));
} }
// Chan is channel_id, $who is channel_address - we'll need to pass observer later too. // Chan is channel_id, $which is channel_address - we'll need to pass observer later too.
function pagelist_widget ($chan,$who){ function pagelist_widget ($owner,$which){
$r = q("select * from item_id where uid = %d and service = 'WEBPAGE' order by sid asc",
intval($chan) $r = q("select * from item_id left join item on item_id.iid = item.id where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc",
intval($owner)
); );
$pages = null;
// TODO - only list public pages. Doesn't matter for now, since we don't have ACL anyway.
if($r) { $pages = null;
$pages = array();
foreach($r as $rr) { if($r) {
$pages[$rr['iid']][] = array('url' => $rr['iid'],'title' => $rr['sid']); $pages = array();
} foreach($r as $rr) {
$pages[$rr['iid']][] = array('url' => $rr['iid'],'pagetitle' => $rr['sid'],'title' => $rr['title'],'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']));
} }
}
return replace_macros(get_markup_template('webpagelist.tpl'), array( //Build the base URL for edit links
$url = z_root() . "/editwebpage/" . $which;
// This isn't pretty, but it works. Until I figure out what to do with the UI, it's Good Enough(TM).
return $o . replace_macros(get_markup_template("webpagelist.tpl"), array(
'$baseurl' => $url, '$baseurl' => $url,
'$edit' => '', '$edit' => t('Edit'),
'$pages' => $pages, '$pages' => $pages,
'$channel' => $who, '$channel' => $which,
'$preview' => '', '$view' => t('View'),
'$widget' => 1, '$preview' => t('Preview'),
'$actions_txt' => t('Actions'),
'$pagelink_txt' => t('Page Link'),
'$title_txt' => t('Title'),
'$created_txt' => t('Created'),
'$edited_txt' => t('Edited')
)); ));
} }

View File

@ -15,44 +15,44 @@ function webpages_content(&$a) {
if((local_user()) && (argc() > 2) && (argv(2) === 'view')) { if((local_user()) && (argc() > 2) && (argv(2) === 'view')) {
$which = $channel['channel_address']; $which = $channel['channel_address'];
$profile = argv(1); $profile = argv(1);
} }
profile_load($a,$which,$profile); profile_load($a,$which,$profile);
// Figure out who the page owner is. // Figure out who the page owner is.
$r = q("select channel_id from channel where channel_address = '%s'", $r = q("select channel_id from channel where channel_address = '%s'",
dbesc($which) dbesc($which)
); );
if($r) { if($r) {
$owner = intval($r[0]['channel_id']); $owner = intval($r[0]['channel_id']);
} }
// Get the observer, check their permissions // Get the observer, check their permissions
$observer = $a->get_observer(); $observer = $a->get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : ''); $ob_hash = (($observer) ? $observer['xchan_hash'] : '');
$perms = get_all_perms($owner,$ob_hash); $perms = get_all_perms($owner,$ob_hash);
if(! $perms['write_pages']) { if(! $perms['write_pages']) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
// if(local_user() && local_user() == $owner) { // if(local_user() && local_user() == $owner) {
// $a->set_widget('design',design_tools()); // $a->set_widget('design',design_tools());
// } // }
$mimetype = get_config('system','page_mimetype'); $mimetype = get_config('system','page_mimetype');
if(! $mimetype) if(! $mimetype)
$mimetype = 'choose'; $mimetype = 'choose';
$layout = get_config('system','page_layout'); $layout = get_config('system','page_layout');
if(! $layout) if(! $layout)
$layout = 'choose'; $layout = 'choose';
// Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages // Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages
@ -61,43 +61,43 @@ function webpages_content(&$a) {
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
if(local_user() && local_user() == $a->profile_uid) { if(local_user() && local_user() == $a->profile_uid) {
$channel = $a->get_channel(); $channel = $a->get_channel();
$channel_acl = array( $channel_acl = array(
'allow_cid' => $channel['channel_allow_cid'], 'allow_cid' => $channel['channel_allow_cid'],
'allow_gid' => $channel['channel_allow_gid'], 'allow_gid' => $channel['channel_allow_gid'],
'deny_cid' => $channel['channel_deny_cid'], 'deny_cid' => $channel['channel_deny_cid'],
'deny_gid' => $channel['channel_deny_gid'] 'deny_gid' => $channel['channel_deny_gid']
);
}
else
$channel_acl = array();
require_once('include/conversation.php');
$o = profile_tabs($a,true);
$o .= '<h2>' . t('Webpages') . '</h2>';
$x = array(
'webpage' => ITEM_WEBPAGE,
'is_owner' => true,
'nickname' => $a->profile['channel_address'],
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'bang' => (($group || $cid) ? '!' : ''),
'acl' => ((local_user() && local_user() == $owner) ? populate_acl($channel_acl) : ''),
'visitor' => true,
'profile_uid' => intval($owner),
'mimetype' => $mimetype,
'layout' => $layout,
); );
}
else
$channel_acl = array();
$o .= status_editor($a,$x); require_once('include/conversation.php');
$o = profile_tabs($a,true);
$o .= '<h2>' . t('Webpages') . '</h2>';
$x = array(
'webpage' => ITEM_WEBPAGE,
'is_owner' => true,
'nickname' => $a->profile['channel_address'],
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
'bang' => (($group || $cid) ? '!' : ''),
'acl' => ((local_user() && local_user() == $owner) ? populate_acl($channel_acl) : ''),
'visitor' => true,
'profile_uid' => intval($owner),
'mimetype' => $mimetype,
'layout' => $layout,
);
$o .= status_editor($a,$x);
//Get a list of webpages. We can't display all them because endless scroll makes that unusable, so just list titles and an edit link. // Get a list of webpages. We can't display all them because endless scroll makes that unusable, so just list titles and an edit link.
//TODO - this should be replaced with pagelist_widget //TODO - this should be replaced with pagelist_widget
$r = q("select item_id.* from item_id left join item on item_id.iid = item.id where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc", $r = q("select * from item_id left join item on item_id.iid = item.id where item_id.uid = %d and service = 'WEBPAGE' order by item.created desc",
intval($owner) intval($owner)
); );
@ -106,23 +106,28 @@ function webpages_content(&$a) {
if($r) { if($r) {
$pages = array(); $pages = array();
foreach($r as $rr) { foreach($r as $rr) {
$pages[$rr['iid']][] = array('url' => $rr['iid'],'title' => $rr['sid']); $pages[$rr['iid']][] = array('url' => $rr['iid'],'pagetitle' => $rr['sid'],'title' => $rr['title'],'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']));
} }
} }
//Build the base URL for edit links //Build the base URL for edit links
$url = z_root() . "/editwebpage/" . $which; $url = z_root() . "/editwebpage/" . $which;
// This isn't pretty, but it works. Until I figure out what to do with the UI, it's Good Enough(TM). // This isn't pretty, but it works. Until I figure out what to do with the UI, it's Good Enough(TM).
return $o . replace_macros(get_markup_template("webpagelist.tpl"), array( return $o . replace_macros(get_markup_template("webpagelist.tpl"), array(
'$baseurl' => $url, '$baseurl' => $url,
'$edit' => t('Edit'), '$edit' => t('Edit'),
'$pages' => $pages, '$pages' => $pages,
'$channel' => $which, '$channel' => $which,
'$view' => t('View'), '$view' => t('View'),
'$preview' => t('Preview'), '$preview' => t('Preview'),
'$actions_txt' => t('Actions'),
)); '$pagelink_txt' => t('Page Link'),
'$title_txt' => t('Title'),
'$created_txt' => t('Created'),
'$edited_txt' => t('Edited')
));
} }

View File

@ -1 +1 @@
2014-04-28.659 2014-04-29.660

View File

@ -0,0 +1,6 @@
.webpage-list-table tr {
height: 20px;
}
.webpage-list-table td {
padding: 5px;
}

View File

@ -1715,19 +1715,6 @@ header {
.profile-thing-list { .profile-thing-list {
list-style-type: none; list-style-type: none;
} }
/*
.profile-thing-list li {
float: left;
margin-right: 25px;
}
*/
div#pagelist-content-wrapper {
width: 80%;
margin-left: auto;
margin-right: auto;
}
div.page-list-item { div.page-list-item {
margin: 20px; margin: 20px;

View File

@ -1,16 +1,35 @@
{{if $pages}} {{if $pages}}
<div id="pagelist-content-wrapper" class="generic-content-wrapper"> <div id="pagelist-content-wrapper" class="generic-content-wrapper">
<table class="webpage-list-table">
<tr><td>{{$actions_txt}}</td><td>{{$pagelink_txt}}</td><td>{{$title_txt}}</td><td>{{$created_txt}}</td><td>{{$edited_txt}}</td></tr>
{{foreach $pages as $key => $items}} {{foreach $pages as $key => $items}}
{{foreach $items as $item}} {{foreach $items as $item}}
<div class="page-list-item"> <tr>
{{if $edit}}<a href="{{$baseurl}}/{{$item.url}}" title="{{$edit}}"><i class="icon-pencil design-icons design-edit-icon"></i></a> {{/if}} <td>
{{if $view}}<a href="page/{{$channel}}/{{$item.title}}" title="{{$view}}"><i class="icon-external-link design-icons design-view-icon"></i></a> {{/if}} {{if $edit}}<a href="{{$baseurl}}/{{$item.url}}" title="{{$edit}}"><i class="icon-pencil design-icons design-edit-icon btn btn-default"></i></a> {{/if}}
{{if $preview}}<a href="page/{{$channel}}/{{$item.title}}?iframe=true&width=80%&height=80%" title="{{$preview}}" class="webpage-preview" ><i class="icon-eye-open design-icons design-preview-icon"></i></a> {{/if}} {{if $view}}<a href="page/{{$channel}}/{{$item.pagetitle}}" title="{{$view}}"><i class="icon-external-link design-icons design-view-icon btn btn-default"></i></a> {{/if}}
{{if $preview}}<a href="page/{{$channel}}/{{$item.pagetitle}}?iframe=true&width=80%&height=80%" title="{{$preview}}" class="webpage-preview" ><i class="icon-eye-open design-icons design-preview-icon btn btn-default"></i></a> {{/if}}
</td>
<td>
{{if $view}}<a href="page/{{$channel}}/{{$item.pagetitle}}" title="{{$view}}">{{$item.pagetitle}}</a>
{{else}}{{$item.pagetitle}}
{{/if}}
</td>
<td>
{{$item.title}} {{$item.title}}
</div> </td>
<td>
{{$item.created}}
</td>
<td>
{{$item.edited}}
</td>
</tr>
{{/foreach}} {{/foreach}}
{{/foreach}} {{/foreach}}
</table>
</div> </div>
<div class="clear"></div> <div class="clear"></div>