Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x

This commit is contained in:
Evan Prodromou 2010-01-04 09:01:23 -10:00
commit b5e0f7d572
11 changed files with 185 additions and 87 deletions

View File

@ -184,7 +184,7 @@ class NewnoticeAction extends Action
$options = array('reply_to' => ($replyto == 'false') ? null : $replyto);
if ($user->shareLocation() && $this->arg('notice_data-location_enabled')) {
if ($user->shareLocation() && $this->arg('notice_data-geo')) {
$locOptions = Notice::locationOptions($this->trimmed('lat'),
$this->trimmed('lon'),

View File

@ -136,7 +136,12 @@ class PublictagcloudAction extends Action
$this->elementStart('dd');
$this->elementStart('ul', 'tags xoxo tag-cloud');
foreach ($tw as $tag => $weight) {
$this->showTag($tag, $weight, $weight/$sum);
if ($sum) {
$weightedSum = $weight/$sum;
} else {
$weightedSum = 1;
}
$this->showTag($tag, $weight, $weightedSum);
}
$this->elementEnd('ul');
$this->elementEnd('dd');

View File

@ -454,7 +454,6 @@ function showForm()
<dd>
<div class="instructions">
<p>Enter your database connection information below to initialize the database.</p>
<p>StatusNet bundles a number of libraries for ease of installation. <a href="?checklibs=true">You can see what bundled libraries you are using, versus what libraries are installed on your server.</a>
</div>
</dd>
</dl>

View File

@ -442,17 +442,25 @@ var SN = { // StatusNet
},
NoticeLocationAttach: function() {
function removeNoticeDataGeo() {
$('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked');
$('#'+SN.C.S.NoticeDataGeoSelected).hide();
$('#'+SN.C.S.NoticeLat).val('');
$('#'+SN.C.S.NoticeLon).val('');
$('#'+SN.C.S.NoticeLocationNs).val('');
$('#'+SN.C.S.NoticeLocationId).val('');
}
var NDG = $('#'+SN.C.S.NoticeDataGeo);
if (NDG.length > 0) {
var NLE = $('#notice_data-location_wrap');
var geocodeURL = NLE.attr('title');
NLE.removeAttr('title');
$('label[for=notice_data-geo]').attr('title', NLE.text());
$('label[for='+SN.C.S.NoticeDataGeo+']').attr('title', jQuery.trim($('label[for='+SN.C.S.NoticeDataGeo+']').text()));
if (navigator.geolocation) {
NDG.change(function() {
NLE.removeAttr('title');
$.cookie(SN.C.S.NoticeLocationCookieName, $('#'+SN.C.S.NoticeDataGeo).attr('checked'));
var NLN = $('#'+SN.C.S.NoticeLocationName);
@ -461,7 +469,7 @@ var SN = { // StatusNet
}
var S = '<div id="'+SN.C.S.NoticeDataGeoSelected+'" class="'+SN.C.S.Success+'"/>';
NDGS = $('#'+SN.C.S.NoticeDataGeoSelected);
var NDGS = $('#'+SN.C.S.NoticeDataGeoSelected);
if (NDGS.length > 0) {
NDGS.replaceWith(S);
}
@ -471,18 +479,18 @@ var SN = { // StatusNet
NDGS = $('#'+SN.C.S.NoticeDataGeoSelected);
NDGS.prepend('<span id="'+SN.C.S.NoticeLocationName+'">Geo</span>');
NLN = $('#'+SN.C.S.NoticeLocationName);
var NLN = $('#'+SN.C.S.NoticeLocationName);
if ($('#'+SN.C.S.NoticeDataGeo).attr('checked') === true) {
NLN.addClass('processing');
$('label[for=notice_data-geo]').addClass('checked');
$('label[for='+SN.C.S.NoticeDataGeo+']').addClass('checked');
NDGS.append('<button class="minimize">&#95;</button> <button class="close">&#215;</button>');
$('#'+SN.C.S.NoticeDataGeoSelected+' button.close').click(function(){
$('#'+SN.C.S.NoticeDataGeoSelected).remove();
$('#'+SN.C.S.NoticeDataGeo).attr('checked', false);
$('label[for=notice_data-geo]').removeClass('checked');
$('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked');
return false;
});
@ -493,7 +501,8 @@ var SN = { // StatusNet
return false;
});
navigator.geolocation.getCurrentPosition(function(position) {
navigator.geolocation.getCurrentPosition(
function(position) {
$('#'+SN.C.S.NoticeLat).val(position.coords.latitude);
$('#'+SN.C.S.NoticeLon).val(position.coords.longitude);
@ -504,6 +513,7 @@ var SN = { // StatusNet
};
$.getJSON(geocodeURL, data, function(location) {
NLN = $('#'+SN.C.S.NoticeLocationName);
NLN.replaceWith('<a id="notice_data-location_name"/>');
NLN = $('#'+SN.C.S.NoticeLocationName);
@ -524,22 +534,28 @@ var SN = { // StatusNet
NLN.attr('href', location.url);
NLN.text(NLN_text);
NLN.click(function() {
window.open(location.url);
return false;
});
});
},
function(error) {
if (error.PERMISSION_DENIED == 1) {
removeNoticeDataGeo();
}
}
);
}
else {
$('label[for=notice_data-geo]').removeClass('checked');
NDGS.hide();
$('#'+SN.C.S.NoticeLat).val('');
$('#'+SN.C.S.NoticeLon).val('');
$('#'+SN.C.S.NoticeLocationNs).val('');
$('#'+SN.C.S.NoticeLocationId).val('');
removeNoticeDataGeo();
}
});
}).change();
var cookieVal = $.cookie(SN.C.S.NoticeLocationCookieName);
NDG.attr('checked', (cookieVal == null || cookieVal == 'true'));
NDG.change();
NDG.attr('checked', (cookieVal === null || cookieVal == 'true'));
}
}
},

View File

@ -74,6 +74,7 @@ class ColumnDef
* @param string $key type of key
* @param value $default default value
* @param value $extra unused
* @param boolean $auto_increment
*/
function __construct($name=null, $type=null, $size=null,

View File

@ -524,6 +524,10 @@ class Schema
$sql .= ($cd->nullable) ? "null " : "not null ";
}
if (!empty($cd->auto_increment)) {
$sql .= " auto_increment ";
}
return $sql;
}
}

View File

@ -99,6 +99,23 @@ abstract class AuthenticationPlugin extends Plugin
}
}
/**
* Internal AutoRegister event handler
* @param nickname
* @param provider_name
* @param user - the newly registered user
*/
function onAutoRegister($nickname, $provider_name, &$user)
{
if($provider_name == $this->provider_name && $this->autoregistration){
$user = $this->autoregister($nickname);
if($user){
User_username::register($user,$nickname,$this->provider_name);
return false;
}
}
}
function onStartCheckPassword($nickname, $password, &$authenticatedUser){
//map the nickname to a username
$user_username = new User_username();
@ -127,13 +144,10 @@ abstract class AuthenticationPlugin extends Plugin
}
}
}else{
if($this->autoregistration){
$authenticated = $this->checkPassword($nickname, $password);
if($authenticated){
$user = $this->autoregister($nickname);
if($user){
$authenticatedUser = $user;
User_username::register($authenticatedUser,$nickname,$this->provider_name);
if(Event::handle('AutoRegister', array($nickname, $this->provider_name, &$authenticatedUser))){
if($authenticatedUser){
return false;
}
}

View File

@ -105,12 +105,11 @@ class FeedSubPlugin extends Plugin
return true;
}
/*
// auto increment seems to be broken
function onCheckSchema() {
// warning: the autoincrement doesn't seem to set.
// alter table feedinfo change column id id int(11) not null auto_increment;
$schema = Schema::get();
$schema->ensureDataObject('Feedinfo');
$schema->ensureTable('feedinfo', Feedinfo::schemaDef());
return true;
}
*/
}

View File

@ -31,7 +31,7 @@ class FeedDBException extends FeedSubException
}
}
class Feedinfo extends Plugin_DataObject
class Feedinfo extends Memcached_DataObject
{
public $__table = 'feedinfo';
@ -56,14 +56,38 @@ class Feedinfo extends Plugin_DataObject
return parent::staticGet(__CLASS__, $k, $v);
}
function tableDef()
/**
* return table definition for DB_DataObject
*
* DB_DataObject needs to know something about the table to manipulate
* instances. This method provides all the DB_DataObject needs to know.
*
* @return array array of column definitions
*/
function table()
{
class_exists('Schema'); // autoload hack
// warning: the autoincrement doesn't seem to set.
// alter table feedinfo change column id id int(11) not null auto_increment;
return new TableDef($this->__table,
array(new ColumnDef('id', 'integer',
null, false, 'PRI', '0', null, true),
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
'feeduri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'homeuri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'huburi' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'verify_token' => DB_DATAOBJECT_STR,
'sub_start' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
'sub_end' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
'lastupdate' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
}
static function schemaDef()
{
return array(new ColumnDef('id', 'integer',
/*size*/ null,
/*nullable*/ false,
/*key*/ 'PRI',
/*default*/ '0',
/*extra*/ null,
/*auto_increment*/ true),
new ColumnDef('profile_id', 'integer',
null, false),
new ColumnDef('feeduri', 'varchar',
@ -81,9 +105,41 @@ class Feedinfo extends Plugin_DataObject
new ColumnDef('created', 'datetime',
null, false),
new ColumnDef('lastupdate', 'datetime',
null, false)));
null, false));
}
/**
* return key definitions for DB_DataObject
*
* DB_DataObject needs to know about keys that the table has; this function
* defines them.
*
* @return array key definitions
*/
function keys()
{
return array('id' => 'P'); //?
}
/**
* return key definitions for Memcached_DataObject
*
* Our caching system uses the same key definitions, but uses a different
* method to get them.
*
* @return array key definitions
*/
function keyTypes()
{
return $this->keys();
}
/**
* Fetch the StatusNet-side profile for this feed
* @return Profile
*/
public function getProfile()
{
return Profile::staticGet('id', $this->profile_id);

View File

@ -156,6 +156,11 @@ class MemcachePlugin extends Plugin
}
$this->_conn->addServer($host, $port);
}
//Compress items stored in the cache if they're over 2k in size
//and the compression would save more than 20%.
//Allows the cache to store objects larger than 1MB (if they
//compress to less than 1MB), and improves cache memory efficiency.
$this->_conn->setCompressThreshold(20000, 0.2);
}
}
}

View File

@ -559,7 +559,6 @@ line-height:1.618;
float:left;
width:80%;
display:block;
line-height:1.8;
overflow:auto;
margin-right:2.5%;
}
@ -571,7 +570,7 @@ font-size:1.1em;
float:right;
font-size:0.8em;
}
,
.form_notice #notice_data-geo_selected button.minimize {
float:left;
}