forked from GNUsocial/gnu-social
Merge branch 'testing' of gitorious.org:statusnet/mainline into testing
* 'testing' of gitorious.org:statusnet/mainline: OStatus: save file records for enclosures Changed the geo location cookie Expire to Session.
This commit is contained in:
commit
9520c0996d
@ -286,5 +286,12 @@ class File extends Memcached_DataObject
|
||||
}
|
||||
return $enclosure;
|
||||
}
|
||||
|
||||
// quick back-compat hack, since there's still code using this
|
||||
function isEnclosure()
|
||||
{
|
||||
$enclosure = $this->getEnclosure();
|
||||
return !empty($enclosure);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,6 +211,8 @@ class Notice extends Memcached_DataObject
|
||||
* extracting ! tags from content
|
||||
* array 'tags' list of hashtag strings to save with the notice
|
||||
* in place of extracting # tags from content
|
||||
* array 'urls' list of attached/referred URLs to save with the
|
||||
* notice in place of extracting links from content
|
||||
* @fixme tag override
|
||||
*
|
||||
* @return Notice
|
||||
@ -380,8 +382,11 @@ class Notice extends Memcached_DataObject
|
||||
$notice->saveTags();
|
||||
}
|
||||
|
||||
// @fixme pass in data for URLs too?
|
||||
if (isset($urls)) {
|
||||
$notice->saveKnownUrls($urls);
|
||||
} else {
|
||||
$notice->saveUrls();
|
||||
}
|
||||
|
||||
// Prepare inbox delivery, may be queued to background.
|
||||
$notice->distribute();
|
||||
@ -427,6 +432,25 @@ class Notice extends Memcached_DataObject
|
||||
common_replace_urls_callback($this->content, array($this, 'saveUrl'), $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the given URLs as related links/attachments to the db
|
||||
*
|
||||
* follow redirects and save all available file information
|
||||
* (mimetype, date, size, oembed, etc.)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function saveKnownUrls($urls)
|
||||
{
|
||||
// @fixme validation?
|
||||
foreach ($urls as $url) {
|
||||
File::processNew($url, $this->id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private callback
|
||||
*/
|
||||
function saveUrl($data) {
|
||||
list($url, $notice_id) = $data;
|
||||
File::processNew($url, $notice_id);
|
||||
|
11
js/util.js
11
js/util.js
@ -53,7 +53,7 @@ var SN = { // StatusNet
|
||||
NoticeLocationNs: 'notice_data-location_ns',
|
||||
NoticeGeoName: 'notice_data-geo_name',
|
||||
NoticeDataGeo: 'notice_data-geo',
|
||||
NoticeDataGeoCookie: 'notice_data-geo_cookie',
|
||||
NoticeDataGeoCookie: 'NoticeDataGeo',
|
||||
NoticeDataGeoSelected: 'notice_data-geo_selected',
|
||||
StatusNetInstance:'StatusNetInstance'
|
||||
}
|
||||
@ -423,8 +423,11 @@ var SN = { // StatusNet
|
||||
};
|
||||
|
||||
notice.find('a.attachment').click(function() {
|
||||
$().jOverlay({url: $('address .url')[0].href+'attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'});
|
||||
var attachId = ($(this).attr('id').substring('attachment'.length + 1));
|
||||
if (attachId) {
|
||||
$().jOverlay({url: $('address .url')[0].href+'attachment/' + attachId + '/ajax'});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if ($('#shownotice').length == 0) {
|
||||
@ -494,7 +497,7 @@ var SN = { // StatusNet
|
||||
$('#'+SN.C.S.NoticeLocationId).val('');
|
||||
$('#'+SN.C.S.NoticeDataGeo).attr('checked', false);
|
||||
|
||||
$.cookie(SN.C.S.NoticeDataGeoCookie, 'disabled', { path: '/', expires: SN.U.GetFullYear(2029, 0, 1) });
|
||||
$.cookie(SN.C.S.NoticeDataGeoCookie, 'disabled', { path: '/' });
|
||||
}
|
||||
|
||||
function getJSONgeocodeURL(geocodeURL, data) {
|
||||
@ -537,7 +540,7 @@ var SN = { // StatusNet
|
||||
NDG: true
|
||||
};
|
||||
|
||||
$.cookie(SN.C.S.NoticeDataGeoCookie, JSON.stringify(cookieValue), { path: '/', expires: SN.U.GetFullYear(2029, 0, 1) });
|
||||
$.cookie(SN.C.S.NoticeDataGeoCookie, JSON.stringify(cookieValue), { path: '/' });
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1044,6 +1044,7 @@ class Activity
|
||||
public $id; // ID of the activity
|
||||
public $title; // title of the activity
|
||||
public $categories = array(); // list of AtomCategory objects
|
||||
public $enclosures = array(); // list of enclosure URL references
|
||||
|
||||
/**
|
||||
* Turns a regular old Atom <entry> into a magical activity
|
||||
@ -1140,6 +1141,10 @@ class Activity
|
||||
$this->categories[] = new AtomCategory($catEl);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ActivityUtils::getLinks($entry, 'enclosure') as $link) {
|
||||
$this->enclosures[] = $link->getAttribute('href');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -550,7 +550,8 @@ class Ostatus_profile extends Memcached_DataObject
|
||||
'rendered' => $rendered,
|
||||
'replies' => array(),
|
||||
'groups' => array(),
|
||||
'tags' => array());
|
||||
'tags' => array(),
|
||||
'urls' => array());
|
||||
|
||||
// Check for optional attributes...
|
||||
|
||||
@ -595,6 +596,12 @@ class Ostatus_profile extends Memcached_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
// Atom enclosures -> attachment URLs
|
||||
foreach ($activity->enclosures as $href) {
|
||||
// @fixme save these locally or....?
|
||||
$options['urls'][] = $href;
|
||||
}
|
||||
|
||||
try {
|
||||
$saved = Notice::saveNew($oprofile->profile_id,
|
||||
$content,
|
||||
@ -620,7 +627,8 @@ class Ostatus_profile extends Memcached_DataObject
|
||||
protected function purify($html)
|
||||
{
|
||||
require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
|
||||
$config = array('safe' => 1);
|
||||
$config = array('safe' => 1,
|
||||
'deny_attribute' => 'id,style,on*');
|
||||
return htmLawed($html, $config);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user