change login method to native gnu social
this required an edit of lib/apiauthaction.php to accept the normal login session as authentication. i'm not sure if this might cause any problems or security risks, but i don't think so..
This commit is contained in:
parent
640d69c49c
commit
d95f08096b
10
README.md
10
README.md
|
@ -26,16 +26,16 @@ Setup
|
|||
|
||||
2. Put all files in /plugins/Qvitter
|
||||
|
||||
3. Add `addPlugin('Qvitter');` to your /config.php file.
|
||||
3. Replace your lib/apiauthaction.php file with the one supplied in edited-gnu-social-files/lib/apiauthaction.php
|
||||
|
||||
4. There are a few settings in /plugins/Qvitter/QvitterPlugin.php. By default Qvitter is
|
||||
4. Add `addPlugin('Qvitter');` to your /config.php file.
|
||||
|
||||
5. There are a few settings in /plugins/Qvitter/QvitterPlugin.php. By default Qvitter is
|
||||
opt-out for users. If you set `$settings['enabledbydefault'] = false;` Qvitter will
|
||||
be opt-in instead.
|
||||
|
||||
5. Users can go to ://{instance}/settings/qvitter and enable or disable Qvitter.
|
||||
6. Users can go to ://{instance}/settings/qvitter and enable or disable Qvitter.
|
||||
|
||||
NOTE: Qvitter is now a plugin for GNU Social. There will probably be bugs because of
|
||||
this change.
|
||||
|
||||
|
||||
TODO
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
· Contact h@nnesmannerhe.im if you have any questions. ·
|
||||
· ·
|
||||
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
||||
class QvitterAction extends Action
|
||||
class QvitterAction extends ApiAction
|
||||
{
|
||||
|
||||
function isReadOnly($args)
|
||||
|
@ -63,11 +63,18 @@ class QvitterAction extends Action
|
|||
|
||||
|
||||
$logged_in_user_nickname = '';
|
||||
$logged_in_user_obj = false;
|
||||
$logged_in_user = common_current_user();
|
||||
if($logged_in_user) {
|
||||
$logged_in_user_nickname = $logged_in_user->nickname;
|
||||
$logged_in_user_obj = ApiAction::twitterUserArray($logged_in_user->getProfile());
|
||||
}
|
||||
|
||||
|
||||
$registrationsclosed = false;
|
||||
if(common_config('site','closed') == 1 || common_config('site','inviteonly') == 1) {
|
||||
$registrationsclosed = true;
|
||||
}
|
||||
|
||||
$sitetitle = common_config('site','name');
|
||||
$siterootdomain = common_config('site','server');
|
||||
$qvitterpath = Plugin::staticPath('Qvitter', '');
|
||||
|
@ -139,13 +146,17 @@ class QvitterAction extends Action
|
|||
print ' <link rel="meta" href="'.$instanceurl.'group/'.$group_name.'/foaf" type="application/rdf+xml" title="FOAF for '.$group_id_or_name.' group"/>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<script>
|
||||
window.textLimit = <?php print json_encode((int)common_config('site','textlimit')) ?>;
|
||||
window.registrationsClosed = <?php print json_encode($registrationsclosed) ?>;
|
||||
window.siteTitle = <?php print json_encode($sitetitle) ?>;
|
||||
window.isLoggedIn = <?php if($logged_in_user) { print 'true'; } else { print 'false'; } ?>;
|
||||
window.loggedIn = <?php print json_encode($logged_in_user_obj) ?>;
|
||||
window.timeBetweenPolling = <?php print QvitterPlugin::settings("timebetweenpolling"); ?>;
|
||||
window.qvitterApiRoot = '<?php print common_path("api/qvitter.json", true); ?>';
|
||||
window.apiRoot = '<?php print common_path("api/", true); ?>';
|
||||
window.fullUrlToThisQvitterApp = '<?php print $qvitterpath; ?>';
|
||||
window.siteRootDomain = '<?php print $siterootdomain; ?>';
|
||||
window.siteInstanceURL = '<?php print $instanceurl; ?>';
|
||||
|
@ -277,14 +288,16 @@ class QvitterAction extends Action
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="front-signup">
|
||||
<?php
|
||||
if($registrationsclosed === false) {
|
||||
?><div class="front-signup">
|
||||
<h2></h2>
|
||||
<div class="signup-input-container"><input placeholder="" type="text" name="user[name]" autocomplete="off" class="text-input" id="signup-user-name"></div>
|
||||
<div class="signup-input-container"><input placeholder="" type="text" name="user[email]" autocomplete="off" id="signup-user-email"></div>
|
||||
<div class="signup-input-container"><input placeholder="" type="password" name="user[user_password]" class="text-input" id="signup-user-password"></div>
|
||||
<button id="signup-btn-step1" class="signup-btn" type="submit"></button>
|
||||
<div id="other-servers-link"></div>
|
||||
</div>
|
||||
</div><?php } ?>
|
||||
<div id="user-header">
|
||||
<img id="user-avatar" src="" />
|
||||
<div id="user-name"></div>
|
||||
|
@ -314,7 +327,7 @@ class QvitterAction extends Action
|
|||
<a class="stream-selection my-timeline" data-stream-header="@statuses/user_timeline.json" data-stream-name="statuses/user_timeline.json"><i class="chev-right"></i></a>
|
||||
<a class="stream-selection favorites" data-stream-header="" data-stream-name="favorites.json"><i class="chev-right"></i></a>
|
||||
<a href="<?php print $instanceurl ?>" class="stream-selection public-timeline" data-stream-header="" data-stream-name="statuses/public_timeline.json"><i class="chev-right"></i></a>
|
||||
<a href="<?php print $instanceurl ?>main/all" class="stream-selection public-and-external-timeline" data-stream-header="" data-stream-name="statuses/public_and_external_timeline.json?since_id=1"><i class="chev-right"></i></a>
|
||||
<a href="<?php print $instanceurl ?>main/all" class="stream-selection public-and-external-timeline" data-stream-header="" data-stream-name="statuses/public_and_external_timeline.json"><i class="chev-right"></i></a>
|
||||
</div>
|
||||
<div class="menu-container" id="history-container"></div>
|
||||
</div>
|
||||
|
@ -348,3 +361,4 @@ class QvitterAction extends Action
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
<?php
|
||||
|
||||
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
||||
· ·
|
||||
· ·
|
||||
· Q V I T T E R ·
|
||||
· ·
|
||||
· http://github.com/hannesmannerheim/qvitter ·
|
||||
· ·
|
||||
· ·
|
||||
· <o) ·
|
||||
· /_//// ·
|
||||
· (____/ ·
|
||||
· (o< ·
|
||||
· o> \\\\_\ ·
|
||||
· \\) \____) ·
|
||||
· ·
|
||||
· ·
|
||||
· ·
|
||||
· Qvitter is free software: you can redistribute it and / or modify it ·
|
||||
· under the terms of the GNU Affero General Public License as published by ·
|
||||
· the Free Software Foundation, either version three of the License or (at ·
|
||||
· your option) any later version. ·
|
||||
· ·
|
||||
· Qvitter is distributed in hope that it will be useful but WITHOUT ANY ·
|
||||
· WARRANTY; without even the implied warranty of MERCHANTABILTY or FITNESS ·
|
||||
· FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for ·
|
||||
· more details. ·
|
||||
· ·
|
||||
· You should have received a copy of the GNU Affero General Public License ·
|
||||
· along with Qvitter. If not, see <http://www.gnu.org/licenses/>. ·
|
||||
· ·
|
||||
· Contact h@nnesmannerhe.im if you have any questions. ·
|
||||
· ·
|
||||
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
||||
|
||||
class QvitterApiAction extends ApiAction
|
||||
{
|
||||
|
||||
protected $needPost = true;
|
||||
|
||||
protected function prepare(array $args=array())
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function handle()
|
||||
{
|
||||
parent::handle();
|
||||
|
||||
$apiroot = common_path('api/', true);
|
||||
|
||||
header("Content-type: application/json; charset=utf-8");
|
||||
|
||||
// post requests
|
||||
if(isset($_POST['postRequest'])) {
|
||||
$query = http_build_query($_POST, '', '&');
|
||||
$ch=curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $apiroot.urldecode($_POST['postRequest']));
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $_POST['username'].":".$_POST['password']);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
|
||||
session_write_close(); // fix problem with curling to local
|
||||
$reply=curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
// get requests
|
||||
} elseif(isset($_POST['getRequest'])) {
|
||||
$ch=curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $apiroot.$_POST['getRequest']);
|
||||
|
||||
if(isset($_POST['username'])) {
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $_POST['username'].":".$_POST['password']);
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
session_write_close();
|
||||
$reply=curl_exec($ch);
|
||||
curl_close($ch);
|
||||
} else {
|
||||
// 400 Bad request, since neither postRequest or getRequest were included
|
||||
http_response_code(400);
|
||||
exit;
|
||||
}
|
||||
|
||||
session_start();
|
||||
|
||||
echo $reply;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
||||
· ·
|
||||
· (o> >o) ·
|
||||
· \\\\_\ /_//// .
|
||||
· \____) (____/ ·
|
||||
· ·
|
||||
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */?>
|
385
edited-gnu-social-files/lib/apiauthaction.php
Normal file
385
edited-gnu-social-files/lib/apiauthaction.php
Normal file
|
@ -0,0 +1,385 @@
|
|||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* Base class for API actions that require authentication
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENCE: This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category API
|
||||
* @package StatusNet
|
||||
* @author Adrian Lang <mail@adrianlang.de>
|
||||
* @author Brenda Wallace <shiny@cpan.org>
|
||||
* @author Craig Andrews <candrews@integralblue.com>
|
||||
* @author Dan Moore <dan@moore.cx>
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author mEDI <medi@milaro.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009-2010 StatusNet, Inc.
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
/* External API usage documentation. Please update when you change how this method works. */
|
||||
|
||||
/*! @page authentication Authentication
|
||||
|
||||
StatusNet supports HTTP Basic Authentication and OAuth for API calls.
|
||||
|
||||
@warning Currently, users who have created accounts without setting a
|
||||
password via OpenID, Facebook Connect, etc., cannot use the API until
|
||||
they set a password with their account settings panel.
|
||||
|
||||
@section HTTP Basic Auth
|
||||
|
||||
|
||||
|
||||
@section OAuth
|
||||
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Actions extending this class will require auth
|
||||
*
|
||||
* @category API
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
class ApiAuthAction extends ApiAction
|
||||
{
|
||||
var $auth_user_nickname = null;
|
||||
var $auth_user_password = null;
|
||||
|
||||
/**
|
||||
* Take arguments for running, looks for an OAuth request,
|
||||
* and outputs basic auth header if needed
|
||||
*
|
||||
* @param array $args $_REQUEST args
|
||||
*
|
||||
* @return boolean success flag
|
||||
*
|
||||
*/
|
||||
protected function prepare(array $args=array())
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
// NOTE: $this->auth_user has to get set in prepare(), not handle(),
|
||||
// because subclasses do stuff with it in their prepares.
|
||||
|
||||
// qvitterfix
|
||||
if (common_current_user()) {
|
||||
$this->auth_user = common_current_user();
|
||||
$this->access = self::READ_WRITE;
|
||||
}
|
||||
|
||||
else {
|
||||
$oauthReq = $this->getOAuthRequest();
|
||||
|
||||
if (!$oauthReq) {
|
||||
if ($this->requiresAuth()) {
|
||||
$this->checkBasicAuthUser(true);
|
||||
} else {
|
||||
// Check to see if a basic auth user is there even
|
||||
// if one's not required
|
||||
$this->checkBasicAuthUser(false);
|
||||
}
|
||||
} else {
|
||||
$this->checkOAuthRequest($oauthReq);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// NOTE: Make sure we're scoped properly based on the auths!
|
||||
if (isset($this->auth_user) && !empty($this->auth_user)) {
|
||||
$this->scoped = $this->auth_user->getProfile();
|
||||
} else {
|
||||
$this->scoped = null;
|
||||
}
|
||||
|
||||
// legacy user transferral
|
||||
// TODO: remove when sure no extended classes need it
|
||||
$this->user = $this->auth_user;
|
||||
|
||||
// Reject API calls with the wrong access level
|
||||
|
||||
if ($this->isReadOnly($args) == false) {
|
||||
if ($this->access != self::READ_WRITE) {
|
||||
// TRANS: Client error 401.
|
||||
$msg = _('API resource requires read-write access, ' .
|
||||
'but you only have read access.');
|
||||
$this->clientError($msg, 401);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the request is an OAuth request.
|
||||
* This is to avoid doign any unnecessary DB lookups.
|
||||
*
|
||||
* @return mixed the OAuthRequest or false
|
||||
*/
|
||||
function getOAuthRequest()
|
||||
{
|
||||
ApiOAuthAction::cleanRequest();
|
||||
|
||||
$req = OAuthRequest::from_request();
|
||||
|
||||
$consumer = $req->get_parameter('oauth_consumer_key');
|
||||
$accessToken = $req->get_parameter('oauth_token');
|
||||
|
||||
// XXX: Is it good enough to assume it's not meant to be an
|
||||
// OAuth request if there is no consumer or token? --Z
|
||||
|
||||
if (empty($consumer) || empty($accessToken)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $req;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies the OAuth request signature, sets the auth user
|
||||
* and access type (read-only or read-write)
|
||||
*
|
||||
* @param OAuthRequest $request the OAuth Request
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function checkOAuthRequest($request)
|
||||
{
|
||||
$datastore = new ApiGNUsocialOAuthDataStore();
|
||||
$server = new OAuthServer($datastore);
|
||||
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
|
||||
|
||||
$server->add_signature_method($hmac_method);
|
||||
|
||||
try {
|
||||
$server->verify_request($request);
|
||||
|
||||
$consumer = $request->get_parameter('oauth_consumer_key');
|
||||
$access_token = $request->get_parameter('oauth_token');
|
||||
|
||||
$app = Oauth_application::getByConsumerKey($consumer);
|
||||
|
||||
if (empty($app)) {
|
||||
common_log(
|
||||
LOG_WARNING,
|
||||
'API OAuth - Couldn\'t find the OAuth app for consumer key: ' .
|
||||
$consumer
|
||||
);
|
||||
// TRANS: OAuth exception thrown when no application is found for a given consumer key.
|
||||
throw new OAuthException(_('No application for that consumer key.'));
|
||||
}
|
||||
|
||||
// set the source attr
|
||||
if ($app->name != 'anonymous') {
|
||||
$this->source = $app->name;
|
||||
}
|
||||
|
||||
|
||||
$appUser = Oauth_application_user::getKV('token', $access_token);
|
||||
|
||||
if (!empty($appUser)) {
|
||||
// If access_type == 0 we have either a request token
|
||||
// or a bad / revoked access token
|
||||
|
||||
if ($appUser->access_type != 0) {
|
||||
// Set the access level for the api call
|
||||
$this->access = ($appUser->access_type & Oauth_application::$writeAccess)
|
||||
? self::READ_WRITE : self::READ_ONLY;
|
||||
|
||||
// Set the auth user
|
||||
if (Event::handle('StartSetApiUser', array(&$user))) {
|
||||
$user = User::getKV('id', $appUser->profile_id);
|
||||
if (!empty($user)) {
|
||||
if (!$user->hasRight(Right::API)) {
|
||||
// TRANS: Authorization exception thrown when a user without API access tries to access the API.
|
||||
throw new AuthorizationException(_('Not allowed to use API.'));
|
||||
}
|
||||
}
|
||||
$this->auth_user = $user;
|
||||
// FIXME: setting the value returned by common_current_user()
|
||||
// There should probably be a better method for this. common_set_user()
|
||||
// does lots of session stuff.
|
||||
global $_cur;
|
||||
$_cur = $this->auth_user;
|
||||
Event::handle('EndSetApiUser', array($user));
|
||||
}
|
||||
|
||||
$msg = "API OAuth authentication for user '%s' (id: %d) on behalf of " .
|
||||
"application '%s' (id: %d) with %s access.";
|
||||
|
||||
common_log(
|
||||
LOG_INFO,
|
||||
sprintf(
|
||||
$msg,
|
||||
$this->auth_user->nickname,
|
||||
$this->auth_user->id,
|
||||
$app->name,
|
||||
$app->id,
|
||||
($this->access = self::READ_WRITE) ? 'read-write' : 'read-only'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// TRANS: OAuth exception given when an incorrect access token was given for a user.
|
||||
throw new OAuthException(_('Bad access token.'));
|
||||
}
|
||||
} else {
|
||||
// Also should not happen.
|
||||
// TRANS: OAuth exception given when no user was found for a given token (no token was found).
|
||||
throw new OAuthException(_('No user for that token.'));
|
||||
}
|
||||
|
||||
} catch (OAuthException $e) {
|
||||
$this->logAuthFailure($e->getMessage());
|
||||
common_log(LOG_WARNING, 'API OAuthException - ' . $e->getMessage());
|
||||
$this->clientError($e->getMessage(), 401);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this API resource require authentication?
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
public function requiresAuth()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for a user specified via HTTP basic auth. If there isn't
|
||||
* one, try to get one by outputting the basic auth header.
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
function checkBasicAuthUser($required = true)
|
||||
{
|
||||
$this->basicAuthProcessHeader();
|
||||
|
||||
$realm = common_config('api', 'realm');
|
||||
|
||||
if (empty($realm)) {
|
||||
$realm = common_config('site', 'name') . ' API';
|
||||
}
|
||||
|
||||
if (empty($this->auth_user_nickname) && $required) {
|
||||
header('WWW-Authenticate: Basic realm="' . $realm . '"');
|
||||
|
||||
// show error if the user clicks 'cancel'
|
||||
// TRANS: Client error thrown when authentication fails becaus a user clicked "Cancel".
|
||||
$this->clientError(_('Could not authenticate you.'), 401);
|
||||
|
||||
} else {
|
||||
|
||||
$user = common_check_user($this->auth_user_nickname,
|
||||
$this->auth_user_password);
|
||||
|
||||
if (Event::handle('StartSetApiUser', array(&$user))) {
|
||||
|
||||
if (!empty($user)) {
|
||||
if (!$user->hasRight(Right::API)) {
|
||||
// TRANS: Authorization exception thrown when a user without API access tries to access the API.
|
||||
throw new AuthorizationException(_('Not allowed to use API.'));
|
||||
}
|
||||
$this->auth_user = $user;
|
||||
}
|
||||
|
||||
Event::handle('EndSetApiUser', array($user));
|
||||
}
|
||||
|
||||
// By default, basic auth users have rw access
|
||||
$this->access = self::READ_WRITE;
|
||||
|
||||
if (empty($this->auth_user) && ($required || isset($_SERVER['PHP_AUTH_USER']))) {
|
||||
$msg = sprintf(
|
||||
"basic auth nickname = %s",
|
||||
$this->auth_user_nickname
|
||||
);
|
||||
$this->logAuthFailure($msg);
|
||||
// TRANS: Client error thrown when authentication fails.
|
||||
$this->clientError(_('Could not authenticate you.'), 401);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the HTTP headers and set the auth user. Decodes HTTP_AUTHORIZATION
|
||||
* param to support basic auth when PHP is running in CGI mode.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function basicAuthProcessHeader()
|
||||
{
|
||||
$authHeaders = array('AUTHORIZATION',
|
||||
'HTTP_AUTHORIZATION',
|
||||
'REDIRECT_HTTP_AUTHORIZATION'); // rewrite for CGI
|
||||
$authorization_header = null;
|
||||
foreach ($authHeaders as $header) {
|
||||
if (isset($_SERVER[$header])) {
|
||||
$authorization_header = $_SERVER[$header];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SERVER['PHP_AUTH_USER'])) {
|
||||
$this->auth_user_nickname = $_SERVER['PHP_AUTH_USER'];
|
||||
$this->auth_user_password = $_SERVER['PHP_AUTH_PW'];
|
||||
} elseif (isset($authorization_header)
|
||||
&& strstr(substr($authorization_header, 0, 5), 'Basic')) {
|
||||
|
||||
// Decode the HTTP_AUTHORIZATION header on php-cgi server self
|
||||
// on fcgid server the header name is AUTHORIZATION
|
||||
$auth_hash = base64_decode(substr($authorization_header, 6));
|
||||
list($this->auth_user_nickname,
|
||||
$this->auth_user_password) = explode(':', $auth_hash);
|
||||
|
||||
// Set all to null on a empty basic auth request
|
||||
|
||||
if (empty($this->auth_user_nickname)) {
|
||||
$this->auth_user_nickname = null;
|
||||
$this->auth_password = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an API authentication failure. Collect the proxy and IP
|
||||
* and log them
|
||||
*
|
||||
* @param string $logMsg additional log message
|
||||
*/
|
||||
function logAuthFailure($logMsg)
|
||||
{
|
||||
list($proxy, $ip) = common_client_ip();
|
||||
|
||||
$msg = sprintf(
|
||||
'API auth failure (proxy = %1$s, ip = %2$s) - ',
|
||||
$proxy,
|
||||
$ip
|
||||
);
|
||||
|
||||
common_log(LOG_WARNING, $msg . $logMsg);
|
||||
}
|
||||
}
|
|
@ -33,6 +33,18 @@
|
|||
· ·
|
||||
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
||||
|
||||
/* ·
|
||||
·
|
||||
· Current time in milliseconds, to send with each request to make sure
|
||||
· we're not getting 304 responses.
|
||||
·
|
||||
·
|
||||
· · · · · · · · · · · · · */
|
||||
|
||||
function timeNow() {
|
||||
return new Date().getTime();
|
||||
}
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
|
@ -45,42 +57,24 @@
|
|||
· · · · · · · · · */
|
||||
|
||||
function checkLogin(username,password,actionOnSuccess) {
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
type: 'POST',
|
||||
data: {
|
||||
getRequest: "account/verify_credentials.json",
|
||||
username: username,
|
||||
password: password
|
||||
},
|
||||
$.ajax({ url: 'http://' + username + ':' + password + '@qvitter.dev/api/account/verify_credentials.json',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
error: function() {
|
||||
logoutWithoutReload(true);
|
||||
},
|
||||
success: function(data) {
|
||||
|
||||
success: function(data) {
|
||||
if(typeof data.error == 'undefined') {
|
||||
actionOnSuccess(data);
|
||||
}
|
||||
else {
|
||||
// if no stream is set, get the one from the url
|
||||
if(typeof window.currentStream == 'undefined' || window.currentStream == '') {
|
||||
setNewCurrentStream(getStreamFromUrl(),function(){
|
||||
logoutWithoutReload(true);
|
||||
remove_spinner();
|
||||
},true);
|
||||
}
|
||||
// if we have a strem, just just do logout and shake...
|
||||
else {
|
||||
logoutWithoutReload(true);
|
||||
remove_spinner();
|
||||
}
|
||||
logoutWithoutReload(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
· Generic API GET request
|
||||
|
@ -91,45 +85,18 @@ function checkLogin(username,password,actionOnSuccess) {
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
function getFromAPI(stream, actionOnSuccess) {
|
||||
|
||||
// request without username/password
|
||||
if(typeof window.loginUsername == 'undefined') {
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
type: "POST",
|
||||
data: {
|
||||
getRequest: stream
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
actionOnSuccess(data);
|
||||
},
|
||||
error: function(data) {
|
||||
actionOnSuccess(false);
|
||||
console.log(data);
|
||||
remove_spinner();
|
||||
}
|
||||
});
|
||||
}
|
||||
// with username/password if set
|
||||
else {
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
type: "POST",
|
||||
data: {
|
||||
getRequest: stream,
|
||||
username: window.loginUsername,
|
||||
password: window.loginPassword
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
actionOnSuccess(data);
|
||||
},
|
||||
error: function(data) {
|
||||
actionOnSuccess(false);
|
||||
console.log(data);
|
||||
remove_spinner();
|
||||
}
|
||||
});
|
||||
}
|
||||
$.ajax({ url: window.apiRoot + stream + qOrAmp(stream) + 't=' + timeNow(),
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
actionOnSuccess(data);
|
||||
},
|
||||
error: function(data) {
|
||||
actionOnSuccess(false);
|
||||
console.log(data);
|
||||
remove_spinner();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -144,14 +111,11 @@ function getFromAPI(stream, actionOnSuccess) {
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
function postQueetToAPI(queetText_txt, actionOnSuccess) {
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
$.ajax({ url: window.apiRoot + 'statuses/update.json?t=' + timeNow(),
|
||||
type: "POST",
|
||||
data: {
|
||||
postRequest: 'statuses/update.json',
|
||||
status: queetText_txt,
|
||||
source: 'Qvitter',
|
||||
username: window.loginUsername,
|
||||
password: window.loginPassword
|
||||
source: 'Qvitter'
|
||||
},
|
||||
dataType: "json",
|
||||
error: function(data){ actionOnSuccess(false); console.log(data); },
|
||||
|
@ -169,13 +133,10 @@ function postQueetToAPI(queetText_txt, actionOnSuccess) {
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
function postNewLinkColor(newLinkColor) {
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
$.ajax({ url: window.apiRoot + 'qvitter/update_link_color.json?t=' + timeNow(),
|
||||
type: "POST",
|
||||
data: {
|
||||
postRequest: 'qvitter/update_link_color.json',
|
||||
linkcolor: newLinkColor,
|
||||
username: window.loginUsername,
|
||||
password: window.loginPassword
|
||||
linkcolor: newLinkColor
|
||||
},
|
||||
dataType:"json",
|
||||
error: function(data){ console.log(data); },
|
||||
|
@ -196,13 +157,10 @@ function postNewLinkColor(newLinkColor) {
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
function postNewBackgroundColor(newBackgroundColor) {
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
$.ajax({ url: window.apiRoot + 'qvitter/update_background_color.json?t=' + timeNow(),
|
||||
type: "POST",
|
||||
data: {
|
||||
postRequest: 'qvitter/update_background_color.json',
|
||||
backgroundcolor: newBackgroundColor,
|
||||
username: window.loginUsername,
|
||||
password: window.loginPassword
|
||||
backgroundcolor: newBackgroundColor
|
||||
},
|
||||
dataType:"json",
|
||||
error: function(data){ console.log(data); },
|
||||
|
@ -227,19 +185,16 @@ function postNewBackgroundColor(newBackgroundColor) {
|
|||
function APIFollowOrUnfollowUser(followOrUnfollow,user_id,this_element,actionOnSuccess) {
|
||||
|
||||
if(followOrUnfollow == 'follow') {
|
||||
var postRequest = 'friendships/create.json';
|
||||
var postRequest = 'friendships/create.json?t=' + timeNow();
|
||||
}
|
||||
else if (followOrUnfollow == 'unfollow') {
|
||||
var postRequest = 'friendships/destroy.json';
|
||||
var postRequest = 'friendships/destroy.json?t=' + timeNow();
|
||||
}
|
||||
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
$.ajax({ url: window.apiRoot + postRequest,
|
||||
type: "POST",
|
||||
data: {
|
||||
postRequest: postRequest,
|
||||
user_id: user_id,
|
||||
username: window.loginUsername,
|
||||
password: window.loginPassword
|
||||
user_id: user_id
|
||||
},
|
||||
dataType:"json",
|
||||
error: function(data){ actionOnSuccess(false,this_element); console.log(data); },
|
||||
|
@ -259,13 +214,10 @@ function APIFollowOrUnfollowUser(followOrUnfollow,user_id,this_element,actionOnS
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
function APIJoinOrLeaveGroup(joinOrLeave,group_id,this_element,actionOnSuccess) {
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
$.ajax({ url: window.apiRoot + 'statusnet/groups/' + joinOrLeave + '.json?t=' + timeNow(),
|
||||
type: "POST",
|
||||
data: {
|
||||
postRequest: 'statusnet/groups/' + joinOrLeave + '.json',
|
||||
id: group_id,
|
||||
username: window.loginUsername,
|
||||
password: window.loginPassword
|
||||
id: group_id
|
||||
},
|
||||
dataType:"json",
|
||||
error: function(data){ actionOnSuccess(false,this_element); console.log(data); },
|
||||
|
@ -285,14 +237,11 @@ function APIJoinOrLeaveGroup(joinOrLeave,group_id,this_element,actionOnSuccess)
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
function postReplyToAPI(queetText_txt, in_reply_to_status_id, actionOnSuccess) {
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
$.ajax({ url: window.apiRoot + 'statuses/update.json?t=' + timeNow(),
|
||||
type: "POST",
|
||||
data: {
|
||||
postRequest: 'statuses/update.json',
|
||||
status: queetText_txt,
|
||||
source: 'Qvitter',
|
||||
username: window.loginUsername,
|
||||
password: window.loginPassword,
|
||||
in_reply_to_status_id: in_reply_to_status_id
|
||||
},
|
||||
dataType:"json",
|
||||
|
@ -314,13 +263,10 @@ function postReplyToAPI(queetText_txt, in_reply_to_status_id, actionOnSuccess) {
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
function postActionToAPI(action, actionOnSuccess) {
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
$.ajax({ url: window.apiRoot + action + qOrAmp(action) + 't=' + timeNow(),
|
||||
type: "POST",
|
||||
data: {
|
||||
postRequest: action,
|
||||
source: 'Qvitter',
|
||||
username: window.loginUsername,
|
||||
password: window.loginPassword
|
||||
source: 'Qvitter'
|
||||
},
|
||||
dataType:"json",
|
||||
error: function(data){ actionOnSuccess(false); console.log(data); },
|
||||
|
@ -373,13 +319,8 @@ function unRequeet(this_stream_item, this_action, my_rq_id) {
|
|||
|
||||
function getFavsOrRequeetsForQueet(apiaction,qid,actionOnSuccess) {
|
||||
if(apiaction=="requeets") { apiaction="retweets"; } // we might mix this up...
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
type: "POST",
|
||||
data: {
|
||||
getRequest: "statuses/" + apiaction + "/" + qid + ".json",
|
||||
username: window.loginUsername,
|
||||
password: window.loginPassword
|
||||
},
|
||||
$.ajax({ url: window.apiRoot + "statuses/" + apiaction + "/" + qid + ".json?t=" + timeNow(),
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if(data.length > 0) {
|
||||
|
|
|
@ -174,12 +174,12 @@ function profileCardFromFirstObject(data,screen_name) {
|
|||
followingClass = 'following';
|
||||
}
|
||||
var followButton = '';
|
||||
if(typeof window.loginUsername != 'undefined' && window.myUserID != first.user.id) {
|
||||
if(typeof window.loggedIn.screen_name != 'undefined' && window.myUserID != first.user.id) {
|
||||
var followButton = '<div class="user-actions"><button data-follow-user-id="' + first.user.id + '" data-follow-user="' + first.user.statusnet_profile_url + '" type="button" class="follow-button ' + followingClass + '"><span class="button-text follow-text"><i class="follow"></i>' + window.sL.userFollow + '</span><span class="button-text following-text">' + window.sL.userFollowing + '</span><span class="button-text unfollow-text">' + window.sL.userUnfollow + '</span></button></div>';
|
||||
}
|
||||
|
||||
// follow from external instance if logged out
|
||||
if(typeof window.loginUsername == 'undefined') {
|
||||
if(typeof window.loggedIn.screen_name == 'undefined') {
|
||||
var followButton = '<div class="user-actions"><button type="button" class="external-follow-button ' + followingClass + '"><span class="button-text follow-text"><i class="follow"></i>' + window.sL.userExternalFollow + '</span></button></div>';
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ function profileCardFromFirstObject(data,screen_name) {
|
|||
followingClass = 'following';
|
||||
}
|
||||
var followButton = '';
|
||||
if(typeof window.loginUsername != 'undefined' && window.myUserID != data.id) {
|
||||
if(typeof window.loggedIn.screen_name != 'undefined' && window.myUserID != data.id) {
|
||||
var followButton = '<div class="user-actions"><button data-follow-user-id="' + data.id + '" data-follow-user="' + data.statusnet_profile_url + '" type="button" class="follow-button ' + followingClass + '"><span class="button-text follow-text"><i class="follow"></i>' + window.sL.userFollow + '</span><span class="button-text following-text">' + window.sL.userFollowing + '</span><span class="button-text unfollow-text">' + window.sL.userUnfollow + '</span></button></div>';
|
||||
}
|
||||
|
||||
|
@ -262,12 +262,12 @@ function groupProfileCard(groupAlias) {
|
|||
memberClass = 'member';
|
||||
}
|
||||
var memberButton = '';
|
||||
if(typeof window.loginUsername != 'undefined') {
|
||||
if(typeof window.loggedIn.screen_name != 'undefined') {
|
||||
var memberButton = '<div class="user-actions"><button data-group-id="' + data.id + '" type="button" class="member-button ' + memberClass + '"><span class="button-text join-text"><i class="join"></i>' + window.sL.joinGroup + '</span><span class="button-text ismember-text">' + window.sL.isMemberOfGroup + '</span><span class="button-text leave-text">' + window.sL.leaveGroup + '</span></button></div>';
|
||||
}
|
||||
|
||||
// follow from external instance if logged out
|
||||
if(typeof window.loginUsername == 'undefined') {
|
||||
if(typeof window.loggedIn.screen_name == 'undefined') {
|
||||
var memberButton = '<div class="user-actions"><button type="button" class="external-member-button"><span class="button-text join-text"><i class="join"></i>' + window.sL.joinExternalGroup + '</span></button></div>';
|
||||
}
|
||||
|
||||
|
@ -334,14 +334,14 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
|
|||
|| stream == 'statuses/friends.json?count=20'
|
||||
|| stream == 'statusnet/groups/list.json?count=10') {
|
||||
var defaultStreamName = stream;
|
||||
var streamHeader = '@' + window.loginUsername;
|
||||
var streamHeader = '@' + window.loggedIn.screen_name;
|
||||
}
|
||||
// if this is one of the default streams, get header from DOM
|
||||
else if(stream == 'statuses/friends_timeline.json'
|
||||
|| stream == 'statuses/mentions.json'
|
||||
|| stream == 'favorites.json'
|
||||
|| stream == 'statuses/public_timeline.json'
|
||||
|| stream == 'statuses/public_and_external_timeline.json?since_id=1') {
|
||||
|| stream == 'statuses/public_and_external_timeline.json') {
|
||||
var defaultStreamName = stream;
|
||||
var streamHeader = $('.stream-selection[data-stream-name="' + stream + '"]').attr('data-stream-header');
|
||||
}
|
||||
|
@ -420,8 +420,8 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
|
|||
|
||||
// add this stream to history menu if it doesn't exist there (but not if this is me or if we're not logged in)
|
||||
if($('.stream-selection[data-stream-header="' + streamHeader + '"]').length==0
|
||||
&& streamHeader != '@' + window.loginUsername
|
||||
&& typeof window.loginUsername != 'undefined') {
|
||||
&& streamHeader != '@' + window.loggedIn.screen_name
|
||||
&& typeof window.loggedIn.screen_name != 'undefined') {
|
||||
$('#history-container').append('<a class="stream-selection" data-stream-header="' + streamHeader + '" href="' + $('.stream-selection.public-timeline').attr('href') + convertStreamToPath(defaultStreamName) + '">' + streamHeader + '<i class="chev-right"></i></a>');
|
||||
updateHistoryLocalStorage();
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
|
|||
var thisUsersScreenName = stream.substring(stream.indexOf('screen_name=')+12);
|
||||
}
|
||||
else {
|
||||
var thisUsersScreenName = window.loginUsername;
|
||||
var thisUsersScreenName = window.loggedIn.screen_name;
|
||||
}
|
||||
|
||||
profileCardFromFirstObject(profile_data,thisUsersScreenName); // show profile card
|
||||
|
@ -541,38 +541,38 @@ function convertStreamToPath(stream) {
|
|||
return screenName + '/groups';
|
||||
}
|
||||
else if(stream == 'statuses/followers.json?count=20') {
|
||||
return window.loginUsername + '/subscribers';
|
||||
return window.loggedIn.screen_name + '/subscribers';
|
||||
}
|
||||
else if(stream == 'statuses/friends.json?count=20') {
|
||||
return window.loginUsername + '/subscriptions';
|
||||
return window.loggedIn.screen_name + '/subscriptions';
|
||||
}
|
||||
else if(stream == 'statuses/mentions.json') {
|
||||
return window.loginUsername + '/replies';
|
||||
return window.loggedIn.screen_name + '/replies';
|
||||
}
|
||||
else if(stream == 'favorites.json') {
|
||||
return window.loginUsername + '/favorites';
|
||||
return window.loggedIn.screen_name + '/favorites';
|
||||
}
|
||||
else if(stream == 'statusnet/groups/list.json?count=10') {
|
||||
return window.loginUsername + '/groups';
|
||||
return window.loggedIn.screen_name + '/groups';
|
||||
}
|
||||
else if (stream.substring(0,27) == 'statuses/user_timeline.json') {
|
||||
var screenName = stream.substring(stream.indexOf('=')+1);
|
||||
return screenName;
|
||||
}
|
||||
else if(stream == 'statuses/friends_timeline.json') {
|
||||
return window.loginUsername + '/all';
|
||||
return window.loggedIn.screen_name + '/all';
|
||||
}
|
||||
else if(stream.substring(0,43) == 'statuses/friends_timeline.json?screen_name=') {
|
||||
var screenName = stream.substring(stream.indexOf('=')+1);
|
||||
return screenName + '/all';
|
||||
}
|
||||
else if (stream == 'statuses/mentions.json') {
|
||||
return window.loginUsername + '/replies';
|
||||
return window.loggedIn.screen_name + '/replies';
|
||||
}
|
||||
else if(stream == 'statuses/public_timeline.json') {
|
||||
return '';
|
||||
}
|
||||
else if(stream == 'statuses/public_and_external_timeline.json?since_id=1') {
|
||||
else if(stream == 'statuses/public_and_external_timeline.json') {
|
||||
return 'main/all';
|
||||
}
|
||||
else if(stream.substring(0,26) == 'statusnet/groups/timeline/') {
|
||||
|
@ -628,7 +628,7 @@ function getStreamFromUrl() {
|
|||
|
||||
// main/all, i.e. full network
|
||||
if (loc == '/main/all') {
|
||||
streamToSet = 'statuses/public_and_external_timeline.json?since_id=1';
|
||||
streamToSet = 'statuses/public_and_external_timeline.json';
|
||||
}
|
||||
|
||||
// {domain}/{screen_name} or {domain}/{screen_name}/
|
||||
|
@ -643,7 +643,7 @@ function getStreamFromUrl() {
|
|||
else if ((/^[a-zA-Z0-9]+$/.test(loc.replace('/','').replace('/all','')))) {
|
||||
var userToStream = loc.replace('/','').replace('/all','');
|
||||
if(userToStream.length>0) {
|
||||
if(window.loginUsername == userToStream) {
|
||||
if(window.loggedIn.screen_name == userToStream) {
|
||||
streamToSet = 'statuses/friends_timeline.json';
|
||||
}
|
||||
else {
|
||||
|
@ -656,7 +656,7 @@ function getStreamFromUrl() {
|
|||
else if ((/^[a-zA-Z0-9]+$/.test(loc.replace('/','').replace('/replies','')))) {
|
||||
var userToStream = loc.replace('/','').replace('/replies','');
|
||||
if(userToStream.length>0) {
|
||||
if(window.loginUsername == userToStream) {
|
||||
if(window.loggedIn.screen_name == userToStream) {
|
||||
streamToSet = 'statuses/mentions.json';
|
||||
}
|
||||
else {
|
||||
|
@ -669,7 +669,7 @@ function getStreamFromUrl() {
|
|||
else if ((/^[a-zA-Z0-9]+$/.test(loc.replace('/','').replace('/favorites','')))) {
|
||||
var userToStream = loc.replace('/','').replace('/favorites','');
|
||||
if(userToStream.length>0) {
|
||||
if(window.loginUsername == userToStream) {
|
||||
if(window.loggedIn.screen_name == userToStream) {
|
||||
streamToSet = 'favorites.json';
|
||||
}
|
||||
else {
|
||||
|
@ -682,7 +682,7 @@ function getStreamFromUrl() {
|
|||
else if ((/^[a-zA-Z0-9]+$/.test(loc.replace('/','').replace('/subscribers','')))) {
|
||||
var userToStream = loc.replace('/','').replace('/subscribers','');
|
||||
if(userToStream.length>0) {
|
||||
if(window.loginUsername == userToStream) {
|
||||
if(window.loggedIn.screen_name == userToStream) {
|
||||
streamToSet = 'statuses/followers.json?count=20';
|
||||
}
|
||||
else {
|
||||
|
@ -695,7 +695,7 @@ function getStreamFromUrl() {
|
|||
else if ((/^[a-zA-Z0-9]+$/.test(loc.replace('/','').replace('/subscriptions','')))) {
|
||||
var userToStream = loc.replace('/','').replace('/subscriptions','');
|
||||
if(userToStream.length>0) {
|
||||
if(window.loginUsername == userToStream) {
|
||||
if(window.loggedIn.screen_name == userToStream) {
|
||||
streamToSet = 'statuses/friends.json?count=20';
|
||||
}
|
||||
else {
|
||||
|
@ -708,7 +708,7 @@ function getStreamFromUrl() {
|
|||
else if ((/^[a-zA-Z0-9]+$/.test(loc.replace('/','').replace('/groups','')))) {
|
||||
var userToStream = loc.replace('/','').replace('/groups','');
|
||||
if(userToStream.length>0) {
|
||||
if(window.loginUsername == userToStream) {
|
||||
if(window.loggedIn.screen_name == userToStream) {
|
||||
streamToSet = 'statusnet/groups/list.json?count=10';
|
||||
}
|
||||
else {
|
||||
|
@ -905,8 +905,8 @@ function expand_queet(q,doScrolling) {
|
|||
}
|
||||
});
|
||||
|
||||
// get favs and rq:s (not if external)
|
||||
if(!q.hasClass('external-conversation')) {
|
||||
// get favs and rq:s (not if external) (and only if logged in because API demands that)
|
||||
if(!q.hasClass('external-conversation') && window.loggedIn) {
|
||||
|
||||
// get and show favs
|
||||
getFavsOrRequeetsForQueet('favs',qid,function(favs){
|
||||
|
@ -934,7 +934,7 @@ function expand_queet(q,doScrolling) {
|
|||
showConversation(qid);
|
||||
|
||||
// show inline reply form if logged in
|
||||
if(typeof window.loginUsername != 'undefined') {
|
||||
if(typeof window.loggedIn.screen_name != 'undefined') {
|
||||
q.find('#q-' + qid).append(replyFormHtml(q,qid));
|
||||
}
|
||||
|
||||
|
@ -1155,7 +1155,7 @@ function showConversation(qid) {
|
|||
|
||||
// actions only for logged in users
|
||||
var queetActions = '';
|
||||
if(typeof window.loginUsername != 'undefined') {
|
||||
if(typeof window.loggedIn.screen_name != 'undefined') {
|
||||
queetActions = '<ul class="queet-actions"><li class="action-reply-container"><a class="with-icn"><span class="icon sm-reply"></span> <b>' + window.sL.replyVerb + '</b></a></li>' + requeetHtml + '<li class="action-fav-container">' + favoriteHtml + '</li></ul>';
|
||||
}
|
||||
|
||||
|
@ -1380,7 +1380,7 @@ function addToFeed(feed, after, extraClasses) {
|
|||
followingClass = 'following';
|
||||
}
|
||||
var followButton = '';
|
||||
if(typeof window.loginUsername != 'undefined' // if logged in
|
||||
if(typeof window.loggedIn.screen_name != 'undefined' // if logged in
|
||||
&& window.myUserID != obj.id) { // not if this is me
|
||||
if(!(obj.statusnet_profile_url.indexOf('/twitter.com/')>-1 && obj.following === false)) { // only unfollow twitter users
|
||||
var followButton = '<div class="user-actions"><button data-follow-user-id="' + obj.id + '" data-follow-user="' + obj.statusnet_profile_url + '" type="button" class="follow-button ' + followingClass + '"><span class="button-text follow-text"><i class="follow"></i>' + window.sL.userFollow + '</span><span class="button-text following-text">' + window.sL.userFollowing + '</span><span class="button-text unfollow-text">' + window.sL.userUnfollow + '</span></button></div>';
|
||||
|
@ -1413,7 +1413,7 @@ function addToFeed(feed, after, extraClasses) {
|
|||
memberClass = 'member';
|
||||
}
|
||||
var memberButton = '';
|
||||
if(typeof window.loginUsername != 'undefined') {
|
||||
if(typeof window.loggedIn.screen_name != 'undefined') {
|
||||
console.log(obj);
|
||||
var memberButton = '<div class="user-actions"><button data-group-id="' + obj.id + '" type="button" class="member-button ' + memberClass + '"><span class="button-text join-text"><i class="join"></i>' + window.sL.joinGroup + '</span><span class="button-text ismember-text">' + window.sL.isMemberOfGroup + '</span><span class="button-text leave-text">' + window.sL.leaveGroup + '</span></button></div>';
|
||||
}
|
||||
|
@ -1486,7 +1486,7 @@ function addToFeed(feed, after, extraClasses) {
|
|||
|
||||
// actions only for logged in users
|
||||
var queetActions = '';
|
||||
if(typeof window.loginUsername != 'undefined') {
|
||||
if(typeof window.loggedIn.screen_name != 'undefined') {
|
||||
queetActions = '<ul class="queet-actions"><li class="action-reply-container"><a class="with-icn"><span class="icon sm-reply"></span> <b>' + window.sL.replyVerb + '</b></a></li>' + requeetHtml + '<li class="action-fav-container">' + favoriteHtml + '</li></ul>';
|
||||
}
|
||||
|
||||
|
@ -1610,7 +1610,7 @@ function addToFeed(feed, after, extraClasses) {
|
|||
|
||||
// actions only for logged in users
|
||||
var queetActions = '';
|
||||
if(typeof window.loginUsername != 'undefined') {
|
||||
if(typeof window.loggedIn.screen_name != 'undefined') {
|
||||
queetActions = '<ul class="queet-actions"><li class="action-reply-container"><a class="with-icn"><span class="icon sm-reply"></span> <b>' + window.sL.replyVerb + '</b></a></li>' + requeetHtml + '<li class="action-fav-container">' + favoriteHtml + '</li></ul>';
|
||||
}
|
||||
|
||||
|
|
19
js/lan.js
19
js/lan.js
|
@ -137,7 +137,7 @@ window.l.es.signUpFullName = 'Nombre completo';
|
|||
window.l.es.signUpEmail = 'Correo electrónico';
|
||||
window.l.es.signUpButtonText = 'Regístrate en ' + window.siteTitle;
|
||||
window.l.es.welcomeHeading = 'Bienvenido a ' + window.siteTitle + '.';
|
||||
window.l.es.welcomeText = 'Somos una <span id="federated-tooltip"><div id="what-is-federation">« Federación » significa que no debes tener una cuenta de ' + window.siteTitle + ' para seguir su usuarios, estar seguido por o communicar con ellos. ¡Puedes registrar con cualquier servidor StatusNet o <a href="http://www.gnu.org/software/social/">GNU Social</a>, o cualquier servicio utilizando el protocolo <a href="http://www.w3.org/community/ostatus/wiki/Main_Page">OStatus</a>! También no debes registrarse en cualquier servicio para participar - simplemente instala el software GNU Social en tu propio servidor. (:</div>federación</span> de microblogueros que, como tú, estan motivados por ética y solidaridad y quieren abandonar los servicios centralizados capitalistas. Estamos aquí desde 2010 y siempre vamos a ser no-profit.';
|
||||
window.l.es.welcomeText = 'Somos una <span id="federated-tooltip"><div id="what-is-federation">« Federación » significa que no debes tener una cuenta de ' + window.siteTitle + ' para seguir su usuarios, estar seguido por o communicar con ellos. ¡Puedes registrar con cualquier servidor StatusNet o <a href="http://www.gnu.org/software/social/">GNU Social</a>, o cualquier servicio utilizando el protocolo <a href="http://www.w3.org/community/ostatus/wiki/Main_Page">OStatus</a>! También no debes registrarse en cualquier servicio para participar - simplemente instala el software GNU Social en tu propio servidor. (:</div>federación</span> de microblogueros que, como tú, estan motivados por ética y solidaridad y quieren abandonar los servicios centralizados capitalistas.';
|
||||
window.l.es.registerNickname = 'Nombre de usuario';
|
||||
window.l.es.registerHomepage = 'Sitio web';
|
||||
window.l.es.registerBio = 'Biografía';
|
||||
|
@ -248,7 +248,7 @@ window.l.fr.signUpFullName = 'Nom complet';
|
|||
window.l.fr.signUpEmail = 'Email';
|
||||
window.l.fr.signUpButtonText = 'S\'inscrire sur ' + window.siteTitle;
|
||||
window.l.fr.welcomeHeading = 'Bienvenue sur ' + window.siteTitle + '.';
|
||||
window.l.fr.welcomeText = 'Nous sommes une <span id="federated-tooltip"><div id="what-is-federation">La « fédération » signifie que vous n\'êtes pas obligé d\'avoir un compte ' + window.siteTitle + ' pour pouvoir suivre ses utilisateurs, être suivis par eux ou interagir avec eux. Vous pouvez vous enregistrer sur n\'importe quel serveur StatusNet ou <a href="http://www.gnu.org/software/social/">GNU Social</a>, ou n\'importe quel service utilisant le protocole <a href="http://www.w3.org/community/ostatus/wiki/Main_Page">OStatus</a> ! Vous n\'êtes pas même obligés de vous inscrire où que ce soit, puisque vous pouvez aussi installer le programme GNU Social sur votre propre serveur ! :)</div>fédération</span> de microbloggers qui, comme vous, a le souci de l\'éthique, de la solidarité, et de s\'extraire des services centralisés capitalistes. Nous sommes en ligne depuis 2010 et resterons toujours sans but lucratif.';
|
||||
window.l.fr.welcomeText = 'Nous sommes une <span id="federated-tooltip"><div id="what-is-federation">La « fédération » signifie que vous n\'êtes pas obligé d\'avoir un compte ' + window.siteTitle + ' pour pouvoir suivre ses utilisateurs, être suivis par eux ou interagir avec eux. Vous pouvez vous enregistrer sur n\'importe quel serveur StatusNet ou <a href="http://www.gnu.org/software/social/">GNU Social</a>, ou n\'importe quel service utilisant le protocole <a href="http://www.w3.org/community/ostatus/wiki/Main_Page">OStatus</a> ! Vous n\'êtes pas même obligés de vous inscrire où que ce soit, puisque vous pouvez aussi installer le programme GNU Social sur votre propre serveur ! :)</div>fédération</span> de microbloggers qui, comme vous, a le souci de l\'éthique, de la solidarité, et de s\'extraire des services centralisés capitalistes.';
|
||||
window.l.fr.registerNickname = 'Nom d\'utilisateur';
|
||||
window.l.fr.registerHomepage = 'Site Web';
|
||||
window.l.fr.registerBio = 'Biographie';
|
||||
|
@ -370,7 +370,7 @@ window.l.de.welcomeText = 'Wir sind eine Community von Microbloggern
|
|||
GNU-Social-Server, auch bekannt als StatusNet. Wir sind genau das Richtige für \
|
||||
<strong>Leute wie dich</strong>, denen Ethik und Solidarität etwas bedeuten und \
|
||||
die sich nicht mehr an zentralisierten kommerziellen Diensten beteiligen \
|
||||
wollen. Es gibt uns schon seit 2010, und wir werden immer Non-Profit bleiben.';
|
||||
wollen. ';
|
||||
window.l.de.registerNickname = 'Nutzername';
|
||||
window.l.de.registerHomepage = 'Webseite';
|
||||
window.l.de.registerBio = 'Bio';
|
||||
|
@ -488,8 +488,7 @@ window.l.en.welcomeText = 'We are a <span id="federated-tooltip"><di
|
|||
You don\'t even have to join a service – try installing the lovely \
|
||||
<a href="http://www.gnu.org/software/social/">GNU Social</a> software on your own server! :)\
|
||||
</div>federation</span> of microbloggers who care about ethics and \
|
||||
solidarity and want to quit the centralised capitalist services. We have been around \
|
||||
since 2010 and will always be non-profit.';
|
||||
solidarity and want to quit the centralised capitalist services.';
|
||||
window.l.en.registerNickname = 'Nickname';
|
||||
window.l.en.registerHomepage = 'Homepage';
|
||||
window.l.en.registerBio = 'Bio';
|
||||
|
@ -599,7 +598,7 @@ window.l.sv.signUpFullName = 'Fullständigt namn';
|
|||
window.l.sv.signUpEmail = 'E-post';
|
||||
window.l.sv.signUpButtonText = 'Registrera dig på ' + window.siteTitle + '';
|
||||
window.l.sv.welcomeHeading = 'Välkommen till ' + window.siteTitle + '.';
|
||||
window.l.sv.welcomeText = 'Vi är en <span id="federated-tooltip"><div id="what-is-federation">"Federering" betyder att du inte behöver ha ett ' + window.siteTitle + '-konto för att följa, följas av eller prata med quittrare. Du kan registrera dig på vilken sajt som helst som stödjer protokollet <a href="http://www.w3.org/community/ostatus/wiki/Main_Page">Ostatus</a>, eller mikroblogga på en helt egen server, förslagsvis med den fria programvaran <a href="http://www.gnu.org/software/social/">GNU Social</a> (som ' + window.siteTitle + ' bygger på).</div>federerad</span> allmänning, där du som har hoppat av de centraliserade kapitalistiska tjänsterna kan mikroblogga etiskt och solidariskt. Vi har funnits sedan 2010 och sajten drivs helt ideellt.';
|
||||
window.l.sv.welcomeText = 'Vi är en <span id="federated-tooltip"><div id="what-is-federation">"Federering" betyder att du inte behöver ha ett ' + window.siteTitle + '-konto för att följa, följas av eller prata med quittrare. Du kan registrera dig på vilken sajt som helst som stödjer protokollet <a href="http://www.w3.org/community/ostatus/wiki/Main_Page">Ostatus</a>, eller mikroblogga på en helt egen server, förslagsvis med den fria programvaran <a href="http://www.gnu.org/software/social/">GNU Social</a> (som ' + window.siteTitle + ' bygger på).</div>federerad</span> allmänning, där du som har hoppat av de centraliserade kapitalistiska tjänsterna kan mikroblogga etiskt och solidariskt.';
|
||||
window.l.sv.registerNickname = 'Användarnamn';
|
||||
window.l.sv.registerHomepage = 'Webbplats';
|
||||
window.l.sv.registerBio = 'Biografi';
|
||||
|
@ -939,7 +938,7 @@ window.l.eo.welcomeText = 'Ni estas <span id="federated-tooltip"><di
|
|||
Vi eĉ ne bezonas membriĝi al servaĵo – peni instali la belan\
|
||||
programon GNU Social ĉe via propra servaĵo! :)</div>federaĵon</span> de mikroblogantoj,\
|
||||
kiu ĉagrenas pri etiko kaj solidareco, kaj kiu volas forlasi la centralizantajn\
|
||||
kapitalismajn servaĵojn. Ni ekzistas\ ekde 2010, kaj ĉiam estos senprofitcela.';
|
||||
kapitalismajn servaĵojn.';
|
||||
window.l.eo.registerNickname = 'Nomo de uzanto';
|
||||
window.l.eo.registerHomepage = 'Afiŝinto';
|
||||
window.l.eo.registerBio = 'Biografio';
|
||||
|
@ -1058,7 +1057,7 @@ o qualsiasi altro servizio basato sul protocollo \
|
|||
nemmeno bisogno di far parte di un servizio - provate a installare il meraviglioso \
|
||||
software GNU Social sul vostro server! :-)</div>federazione</span> di microbloggers \
|
||||
che hanno a cuore l\'etica, la solidarietà, e che vogliono uscire dai servizi \
|
||||
centralizzati capitalisti. Esistiamo dal 2010 e saremo sempre non-profit.';
|
||||
centralizzati capitalisti.';
|
||||
window.l.it.registerNickname = 'Nickname';
|
||||
window.l.it.registerHomepage = 'Sito web';
|
||||
window.l.it.registerBio = 'Biografia';
|
||||
|
@ -1126,6 +1125,6 @@ $('.stream-selection[data-stream-name="favorites.json"]').prepend(window.sL.favo
|
|||
$('.stream-selection[data-stream-name="favorites.json"]').attr('data-stream-header',window.sL.favoritesNoun);
|
||||
$('.stream-selection[data-stream-name="statuses/public_timeline.json"]').prepend(window.sL.publicTimeline);
|
||||
$('.stream-selection[data-stream-name="statuses/public_timeline.json"]').attr('data-stream-header',window.sL.publicTimeline);
|
||||
$('.stream-selection[data-stream-name="statuses/public_and_external_timeline.json?since_id=1"]').prepend(window.sL.publicAndExtTimeline);
|
||||
$('.stream-selection[data-stream-name="statuses/public_and_external_timeline.json?since_id=1"]').attr('data-stream-header',window.sL.publicAndExtTimeline);
|
||||
$('.stream-selection[data-stream-name="statuses/public_and_external_timeline.json"]').prepend(window.sL.publicAndExtTimeline);
|
||||
$('.stream-selection[data-stream-name="statuses/public_and_external_timeline.json"]').attr('data-stream-header',window.sL.publicAndExtTimeline);
|
||||
$('#search-query').attr('placeholder',window.sL.searchVerb);
|
||||
|
|
|
@ -381,7 +381,7 @@ function placeCaretAtEnd(el) {
|
|||
function updateHistoryLocalStorage() {
|
||||
if(localStorageIsEnabled()) {
|
||||
var i=0;
|
||||
var localStorageName = window.loginUsername + '-history-container-v2';
|
||||
var localStorageName = window.loggedIn.screen_name + '-history-container-v2';
|
||||
var historyContainer = new Object();
|
||||
$.each($('#history-container .stream-selection'), function(key,obj) {
|
||||
historyContainer[i] = new Object();
|
||||
|
@ -410,7 +410,7 @@ function updateHistoryLocalStorage() {
|
|||
|
||||
function loadHistoryFromLocalStorage() {
|
||||
if(localStorageIsEnabled()) {
|
||||
var localStorageName = window.loginUsername + '-history-container-v2';
|
||||
var localStorageName = window.loggedIn.screen_name + '-history-container-v2';
|
||||
if(typeof localStorage[localStorageName] != "undefined") {
|
||||
$('#history-container').css('display','block');
|
||||
$('#history-container').html('');
|
||||
|
@ -452,35 +452,37 @@ function qOrAmp(stream) {
|
|||
· · · · · · · · · · · · · */
|
||||
|
||||
function countCharsInQueetBox(src,trgt,btn) {
|
||||
var numchars = $.trim(src).length;
|
||||
trgt.html(140 - numchars);
|
||||
if(window.textLimit > 0) {
|
||||
var numchars = $.trim(src).length;
|
||||
trgt.html(window.textLimit - numchars);
|
||||
|
||||
// activate/deactivare button
|
||||
if(numchars > 0 && numchars < 141) {
|
||||
btn.removeClass('disabled');
|
||||
btn.addClass('enabled');
|
||||
// activate/deactivare button
|
||||
if(numchars > 0 && numchars < window.textLimit+1) {
|
||||
btn.removeClass('disabled');
|
||||
btn.addClass('enabled');
|
||||
|
||||
// deactivate button if it's equal to the start text
|
||||
var startText = btn.closest('.inline-reply-queetbox').children('.queet-box-template').attr('data-start-text');
|
||||
if(typeof startText != 'undefined') {
|
||||
if($.trim(startText) == $.trim(src)) {
|
||||
btn.removeClass('enabled');
|
||||
btn.addClass('disabled');
|
||||
// deactivate button if it's equal to the start text
|
||||
var startText = btn.closest('.inline-reply-queetbox').children('.queet-box-template').attr('data-start-text');
|
||||
if(typeof startText != 'undefined') {
|
||||
if($.trim(startText) == $.trim(src)) {
|
||||
btn.removeClass('enabled');
|
||||
btn.addClass('disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
btn.removeClass('enabled');
|
||||
btn.addClass('disabled');
|
||||
}
|
||||
else {
|
||||
btn.removeClass('enabled');
|
||||
btn.addClass('disabled');
|
||||
}
|
||||
|
||||
|
||||
// counter color
|
||||
if((140-numchars) < 0) {
|
||||
trgt.css('color','#D40D12');
|
||||
}
|
||||
else {
|
||||
trgt.removeAttr('style');
|
||||
// counter color
|
||||
if((window.textLimit-numchars) < 0) {
|
||||
trgt.css('color','#D40D12');
|
||||
}
|
||||
else {
|
||||
trgt.removeAttr('style');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
392
js/qvitter.js
392
js/qvitter.js
|
@ -92,133 +92,133 @@ $('#what-is-federation').on('mouseleave',function(){
|
|||
·
|
||||
· · · · · · · · · · · · · */
|
||||
|
||||
$('.front-signup input, .front-signup button').removeAttr('disabled'); // clear this onload
|
||||
$('#signup-btn-step1').click(function(){
|
||||
if(!window.registrationsClosed) {
|
||||
$('.front-signup input, .front-signup button').removeAttr('disabled'); // clear this onload
|
||||
$('#signup-btn-step1').click(function(){
|
||||
|
||||
display_spinner();
|
||||
$('.front-signup input, .front-signup button').addClass('disabled');
|
||||
$('.front-signup input, .front-signup button').attr('disabled','disabled');
|
||||
// 7 s timeout to annoy human spammers
|
||||
setTimeout(function(){
|
||||
remove_spinner();
|
||||
popUpAction('popup-register',window.sL.signUp,'<div id="popup-signup" class="front-signup">' +
|
||||
'<div class="signup-input-container"><div id="atsign">@</div><input placeholder="' + window.sL.registerNickname + '" type="text" autocomplete="off" class="text-input" id="signup-user-nickname-step2"><div class="fieldhelp">a-z0-9</div></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.signUpFullName + '" type="text" autocomplete="off" class="text-input" id="signup-user-name-step2" value="' + $('#signup-user-name').val() + '"></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.signUpEmail + '" type="text" autocomplete="off" id="signup-user-email-step2" value="' + $('#signup-user-email').val() + '"></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.registerHomepage + '" type="text" autocomplete="off" class="text-input" id="signup-user-homepage-step2"></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.registerBio + '" type="text" autocomplete="off" class="text-input" id="signup-user-bio-step2"></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.registerLocation + '" type="text" autocomplete="off" class="text-input" id="signup-user-location-step2"></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.loginPassword + '" type="password" class="text-input" id="signup-user-password1-step2" value="' + $('#signup-user-password').val() + '"><div class="fieldhelp">>5</div></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.registerRepeatPassword + '" type="password" class="text-input" id="signup-user-password2-step2"></div>' +
|
||||
'<button id="signup-btn-step2" class="signup-btn disabled" type="submit">' + window.sL.signUpButtonText + '</button>' +
|
||||
'</div>',false);
|
||||
display_spinner();
|
||||
$('.front-signup input, .front-signup button').addClass('disabled');
|
||||
$('.front-signup input, .front-signup button').attr('disabled','disabled');
|
||||
// 7 s timeout to annoy human spammers
|
||||
setTimeout(function(){
|
||||
remove_spinner();
|
||||
popUpAction('popup-register',window.sL.signUp,'<div id="popup-signup" class="front-signup">' +
|
||||
'<div class="signup-input-container"><div id="atsign">@</div><input placeholder="' + window.sL.registerNickname + '" type="text" autocomplete="off" class="text-input" id="signup-user-nickname-step2"><div class="fieldhelp">a-z0-9</div></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.signUpFullName + '" type="text" autocomplete="off" class="text-input" id="signup-user-name-step2" value="' + $('#signup-user-name').val() + '"></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.signUpEmail + '" type="text" autocomplete="off" id="signup-user-email-step2" value="' + $('#signup-user-email').val() + '"></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.registerHomepage + '" type="text" autocomplete="off" class="text-input" id="signup-user-homepage-step2"></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.registerBio + '" type="text" autocomplete="off" class="text-input" id="signup-user-bio-step2"></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.registerLocation + '" type="text" autocomplete="off" class="text-input" id="signup-user-location-step2"></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.loginPassword + '" type="password" class="text-input" id="signup-user-password1-step2" value="' + $('#signup-user-password').val() + '"><div class="fieldhelp">>5</div></div>' +
|
||||
'<div class="signup-input-container"><input placeholder="' + window.sL.registerRepeatPassword + '" type="password" class="text-input" id="signup-user-password2-step2"></div>' +
|
||||
'<button id="signup-btn-step2" class="signup-btn disabled" type="submit">' + window.sL.signUpButtonText + '</button>' +
|
||||
'</div>',false);
|
||||
|
||||
// ask api if nickname is ok, if no typing for 1 s
|
||||
$('#signup-user-nickname-step2').on('keyup',function(){
|
||||
clearTimeout(window.checkNicknameTimeout);
|
||||
if($('#signup-user-nickname-step2').val().length>1 && /^[a-zA-Z0-9]+$/.test($('#signup-user-nickname-step2').val())) {
|
||||
$('#signup-user-nickname-step2').addClass('nickname-taken');
|
||||
if($('.spinner-wrap').length==0) {
|
||||
$('#signup-user-nickname-step2').after('<div class="spinner-wrap"><div class="spinner"><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i></div></div>');
|
||||
}
|
||||
window.checkNicknameTimeout = setTimeout(function(){
|
||||
getFromAPI('check_nickname.json?nickname=' + encodeURIComponent($('#signup-user-nickname-step2').val()),function(data){
|
||||
$('.spinner-wrap').remove();
|
||||
console.log($('.spinner-wrap').length);
|
||||
if(data==0) {
|
||||
$('#signup-user-password2-step2').trigger('keyup'); // revalidates
|
||||
}
|
||||
else {
|
||||
$('#signup-user-nickname-step2').removeClass('nickname-taken');
|
||||
$('#signup-user-password2-step2').trigger('keyup');
|
||||
}
|
||||
});
|
||||
},1000);
|
||||
}
|
||||
else {
|
||||
$('.spinner-wrap').remove();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// validate on keyup
|
||||
$('#popup-register input').on('keyup',function(){
|
||||
if(validateRegisterForm($('#popup-register'))) {
|
||||
if(!$('#signup-user-nickname-step2').hasClass('nickname-taken')) {
|
||||
$('#signup-btn-step2').removeClass('disabled');
|
||||
// ask api if nickname is ok, if no typing for 1 s
|
||||
$('#signup-user-nickname-step2').on('keyup',function(){
|
||||
clearTimeout(window.checkNicknameTimeout);
|
||||
if($('#signup-user-nickname-step2').val().length>1 && /^[a-zA-Z0-9]+$/.test($('#signup-user-nickname-step2').val())) {
|
||||
$('#signup-user-nickname-step2').addClass('nickname-taken');
|
||||
if($('.spinner-wrap').length==0) {
|
||||
$('#signup-user-nickname-step2').after('<div class="spinner-wrap"><div class="spinner"><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i></div></div>');
|
||||
}
|
||||
window.checkNicknameTimeout = setTimeout(function(){
|
||||
getFromAPI('check_nickname.json?nickname=' + encodeURIComponent($('#signup-user-nickname-step2').val()),function(data){
|
||||
$('.spinner-wrap').remove();
|
||||
console.log($('.spinner-wrap').length);
|
||||
if(data==0) {
|
||||
$('#signup-user-password2-step2').trigger('keyup'); // revalidates
|
||||
}
|
||||
else {
|
||||
$('#signup-user-nickname-step2').removeClass('nickname-taken');
|
||||
$('#signup-user-password2-step2').trigger('keyup');
|
||||
}
|
||||
});
|
||||
},1000);
|
||||
}
|
||||
else {
|
||||
$('#signup-btn-step2').addClass('disabled');
|
||||
$('.spinner-wrap').remove();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#signup-btn-step2').addClass('disabled');
|
||||
}
|
||||
});
|
||||
$('#popup-register input').trigger('keyup');
|
||||
|
||||
// submit on enter
|
||||
$('input#signup-user-name-step2,input#signup-user-email-step2,input#signup-user-password1-step2, input#signup-user-password2-step2').keyup(function(e){
|
||||
if(e.keyCode==13) {
|
||||
$('#signup-btn-step2').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
$('#signup-btn-step2').click(function(){
|
||||
$('#popup-register input,#popup-register button').addClass('disabled');
|
||||
display_spinner();
|
||||
$.ajax({ url: window.qvitterApiRoot,
|
||||
type: "POST",
|
||||
data: {
|
||||
postRequest: 'account/register.json',
|
||||
nickname: $('#signup-user-nickname-step2').val(),
|
||||
email: $('#signup-user-email-step2').val(),
|
||||
fullname: $('#signup-user-name-step2').val(),
|
||||
homepage: $('#signup-user-homepage-step2').val(),
|
||||
bio: $('#signup-user-bio-step2').val(),
|
||||
location: $('#signup-user-location-step2').val(),
|
||||
password: $('#signup-user-password1-step2').val(),
|
||||
confirm: $('#signup-user-password2-step2').val(),
|
||||
cBS: window.cBS,
|
||||
cBSm: window.cBSm,
|
||||
username: 'none',
|
||||
},
|
||||
dataType:"json",
|
||||
error: function(data){ console.log('error'); console.log(data); },
|
||||
success: function(data) {
|
||||
remove_spinner();
|
||||
if(typeof data.error == 'undefined') {
|
||||
$('input#nickname').val($('#signup-user-nickname-step2').val());
|
||||
$('input#password').val($('#signup-user-password1-step2').val());
|
||||
$('input#rememberme').prop('checked', true);
|
||||
$('#submit-login').trigger('click');
|
||||
$('#popup-register').remove();
|
||||
}
|
||||
else {
|
||||
alert('Try again! ' + data.error);
|
||||
$('#popup-register input,#popup-register button').removeClass('disabled');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// validate on keyup
|
||||
$('#popup-register input').on('keyup',function(){
|
||||
if(validateRegisterForm($('#popup-register'))) {
|
||||
if(!$('#signup-user-nickname-step2').hasClass('nickname-taken')) {
|
||||
$('#signup-btn-step2').removeClass('disabled');
|
||||
}
|
||||
else {
|
||||
$('#signup-btn-step2').addClass('disabled');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#signup-btn-step2').addClass('disabled');
|
||||
}
|
||||
});
|
||||
$('#popup-register input').trigger('keyup');
|
||||
|
||||
// submit on enter
|
||||
$('input#signup-user-name-step2,input#signup-user-email-step2,input#signup-user-password1-step2, input#signup-user-password2-step2').keyup(function(e){
|
||||
if(e.keyCode==13) {
|
||||
$('#signup-btn-step2').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
// reactivate register form on popup close
|
||||
$('#popup-register').on('remove',function(){
|
||||
$('.front-signup input, .front-signup button').removeAttr('disabled');
|
||||
$('.front-signup input, .front-signup button').removeClass('disabled');
|
||||
});
|
||||
},7000);
|
||||
});
|
||||
// submit on enter
|
||||
$('input#signup-user-name,input#signup-user-email,input#signup-user-password').keyup(function(e){
|
||||
if(e.keyCode==13) {
|
||||
$('#signup-btn-step1').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
$('#signup-btn-step2').click(function(){
|
||||
$('#popup-register input,#popup-register button').addClass('disabled');
|
||||
display_spinner();
|
||||
$.ajax({ url: window.apiRoot + 'account/register.json',
|
||||
type: "POST",
|
||||
data: {
|
||||
nickname: $('#signup-user-nickname-step2').val(),
|
||||
email: $('#signup-user-email-step2').val(),
|
||||
fullname: $('#signup-user-name-step2').val(),
|
||||
homepage: $('#signup-user-homepage-step2').val(),
|
||||
bio: $('#signup-user-bio-step2').val(),
|
||||
location: $('#signup-user-location-step2').val(),
|
||||
password: $('#signup-user-password1-step2').val(),
|
||||
confirm: $('#signup-user-password2-step2').val(),
|
||||
cBS: window.cBS,
|
||||
cBSm: window.cBSm,
|
||||
username: 'none',
|
||||
},
|
||||
dataType:"json",
|
||||
error: function(data){ console.log('error'); console.log(data); },
|
||||
success: function(data) {
|
||||
remove_spinner();
|
||||
if(typeof data.error == 'undefined') {
|
||||
$('input#nickname').val($('#signup-user-nickname-step2').val());
|
||||
$('input#password').val($('#signup-user-password1-step2').val());
|
||||
$('input#rememberme').prop('checked', true);
|
||||
$('#submit-login').trigger('click');
|
||||
$('#popup-register').remove();
|
||||
}
|
||||
else {
|
||||
alert('Try again! ' + data.error);
|
||||
$('#popup-register input,#popup-register button').removeClass('disabled');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// reactivate register form on popup close
|
||||
$('#popup-register').on('remove',function(){
|
||||
$('.front-signup input, .front-signup button').removeAttr('disabled');
|
||||
$('.front-signup input, .front-signup button').removeClass('disabled');
|
||||
});
|
||||
},7000);
|
||||
});
|
||||
// submit on enter
|
||||
$('input#signup-user-name,input#signup-user-email,input#signup-user-password').keyup(function(e){
|
||||
if(e.keyCode==13) {
|
||||
$('#signup-btn-step1').trigger('click');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -235,32 +235,10 @@ $(window).load(function() {
|
|||
$('#user-container').css('display','block');
|
||||
$('#feed').css('display','block');
|
||||
|
||||
// check for localstorage, if none, we remove possibility to remember login
|
||||
var userInLocalStorage = false;
|
||||
if(localStorageIsEnabled()) {
|
||||
if(typeof localStorage.autologinPassword != 'undefined') {
|
||||
userInLocalStorage = true;
|
||||
}
|
||||
}
|
||||
|
||||
// if we have a user logged in to localStorage, but not to gnusocial, delete
|
||||
// and send them to front page and tell it to shake loginbox
|
||||
if(!window.isLoggedIn && userInLocalStorage) {
|
||||
localStorage.doShake = true;
|
||||
delete localStorage.autologinUsername;
|
||||
delete localStorage.autologinPassword;
|
||||
window.location.href =window.siteInstanceURL;
|
||||
}
|
||||
|
||||
// if login credentials in localstorage got lost somewhere, logout
|
||||
if(window.isLoggedIn && !userInLocalStorage) {
|
||||
window.location.href =window.siteInstanceURL + 'main/logout';
|
||||
}
|
||||
// autologin
|
||||
else if(window.isLoggedIn && userInLocalStorage) {
|
||||
$('input#nickname').val(localStorage.autologinUsername);
|
||||
$('input#password').val(localStorage.autologinPassword);
|
||||
doLogin("get stream from url");
|
||||
// login or not
|
||||
if(window.loggedIn) {
|
||||
console.log('logged in user: ' + window.loggedIn.screen_name);
|
||||
doLogin(getStreamFromUrl());
|
||||
}
|
||||
else {
|
||||
display_spinner();
|
||||
|
@ -272,51 +250,34 @@ $(window).load(function() {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
· Login action
|
||||
·
|
||||
· · · · · · · · · · · · · */
|
||||
|
||||
$('#form_login').submit(function(e) {
|
||||
|
||||
// store username and password in localstorage before submitting
|
||||
if(typeof localStorage.autologinPassword == 'undefined') {
|
||||
|
||||
$('#form_login').submit(function(e) {
|
||||
if(typeof window.loginCheckSuccessful == 'undefined') {
|
||||
e.preventDefault();
|
||||
localStorage.autologinPassword = $('input#password').val();
|
||||
localStorage.autologinUsername = $('input#nickname').val();
|
||||
$(this).submit();
|
||||
}
|
||||
});
|
||||
checkLogin($('input#nickname').val(),$('input#password').val(),function(data){
|
||||
window.loginCheckSuccessful = true;
|
||||
$('#form_login').submit();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function doLogin(streamToSet) {
|
||||
$('#submit-login').attr('disabled','disabled');
|
||||
$('#submit-login').focus(); // prevents submit on enter to close alert-popup on wrong credentials
|
||||
display_spinner();
|
||||
|
||||
// login with ajax
|
||||
checkLogin($('input#nickname').val(),$('input#password').val(),function(user){
|
||||
|
||||
console.log(user);
|
||||
|
||||
// store credentials in global var
|
||||
window.loginUsername = user.screen_name;
|
||||
window.loginPassword = $('input#password').val();
|
||||
|
||||
// maybe get stream from url (UGLY SORRRRRY)
|
||||
if(streamToSet == "get stream from url") {
|
||||
streamToSet = getStreamFromUrl(); // called now becuase we want window.loginUsername to be set first...
|
||||
}
|
||||
|
||||
// set colors if the api supports it
|
||||
if(typeof user.linkcolor != 'undefined' &&
|
||||
typeof user.backgroundcolor != 'undefined') {
|
||||
user.linkcolor = user.linkcolor || ''; // no null value
|
||||
user.backgroundcolor = user.backgroundcolor || ''; // no null value
|
||||
window.userLinkColor = user.linkcolor;
|
||||
window.userBackgroundColor = user.backgroundcolor;
|
||||
if(typeof window.loggedIn.linkcolor != 'undefined' &&
|
||||
typeof window.loggedIn.backgroundcolor != 'undefined') {
|
||||
window.loggedIn.linkcolor = window.loggedIn.linkcolor || ''; // no null value
|
||||
window.loggedIn.backgroundcolor = window.loggedIn.backgroundcolor || ''; // no null value
|
||||
window.userLinkColor = window.loggedIn.linkcolor;
|
||||
window.userBackgroundColor = window.loggedIn.backgroundcolor;
|
||||
if(window.userLinkColor.length != 6) {
|
||||
window.userLinkColor = window.defaultLinkColor;
|
||||
}
|
||||
|
@ -328,27 +289,19 @@ function doLogin(streamToSet) {
|
|||
// add user data to DOM, show search form, remeber user id, show the feed
|
||||
$('#user-container').css('z-index','1000');
|
||||
$('#top-compose').removeClass('hidden');
|
||||
$('#user-avatar').attr('src', user.profile_image_url_profile_size);
|
||||
$('#user-name').append(user.name);
|
||||
$('#user-screen-name').append(user.screen_name);
|
||||
$('#user-profile-link').append('<a href="' + user.statusnet_profile_url + '">' + window.sL.viewMyProfilePage + '</a>');
|
||||
$('#user-queets strong').html(user.statuses_count);
|
||||
$('#user-following strong').html(user.friends_count);
|
||||
$('#user-followers strong').html(user.followers_count);
|
||||
$('#user-groups strong').html(user.groups_count);
|
||||
$('.stream-selection.friends-timeline').attr('href', user.statusnet_profile_url + '/all');
|
||||
$('.stream-selection.mentions').attr('href', user.statusnet_profile_url + '/replies');
|
||||
$('.stream-selection.my-timeline').attr('href', user.statusnet_profile_url);
|
||||
$('.stream-selection.favorites').attr('href', user.statusnet_profile_url + '/favorites');
|
||||
window.myUserID = user.id;
|
||||
|
||||
// if remeber me is checked, save credentials in local storage
|
||||
if($('#rememberme').is(':checked')) {
|
||||
if(localStorageIsEnabled()) {
|
||||
localStorage.autologinPassword = $('input#password').val();
|
||||
localStorage.autologinUsername = $('input#nickname').val();
|
||||
}
|
||||
}
|
||||
$('#user-avatar').attr('src', window.loggedIn.profile_image_url_profile_size);
|
||||
$('#user-name').append(window.loggedIn.name);
|
||||
$('#user-screen-name').append(window.loggedIn.screen_name);
|
||||
$('#user-profile-link').append('<a href="' + window.loggedIn.statusnet_profile_url + '">' + window.sL.viewMyProfilePage + '</a>');
|
||||
$('#user-queets strong').html(window.loggedIn.statuses_count);
|
||||
$('#user-following strong').html(window.loggedIn.friends_count);
|
||||
$('#user-followers strong').html(window.loggedIn.followers_count);
|
||||
$('#user-groups strong').html(window.loggedIn.groups_count);
|
||||
$('.stream-selection.friends-timeline').attr('href', window.loggedIn.statusnet_profile_url + '/all');
|
||||
$('.stream-selection.mentions').attr('href', window.loggedIn.statusnet_profile_url + '/replies');
|
||||
$('.stream-selection.my-timeline').attr('href', window.loggedIn.statusnet_profile_url);
|
||||
$('.stream-selection.favorites').attr('href', window.loggedIn.statusnet_profile_url + '/favorites');
|
||||
window.myUserID = window.loggedIn.id;
|
||||
|
||||
// load history
|
||||
loadHistoryFromLocalStorage();
|
||||
|
@ -371,7 +324,6 @@ function doLogin(streamToSet) {
|
|||
remove_spinner();
|
||||
},true);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -396,15 +348,11 @@ $('#rememberme_label').disableSelection();
|
|||
|
||||
/* ·
|
||||
·
|
||||
· Logout by deleting local storage credentials (if there are any) and reload
|
||||
· Logout
|
||||
·
|
||||
· · · · · · · · · · · · · */
|
||||
|
||||
$('#logout').click(function(){
|
||||
if(localStorageIsEnabled()) {
|
||||
delete localStorage.autologinUsername;
|
||||
delete localStorage.autologinPassword;
|
||||
}
|
||||
window.location.href =window.siteInstanceURL + 'main/logout';
|
||||
});
|
||||
|
||||
|
@ -486,23 +434,7 @@ function logoutWithoutReload(doShake) {
|
|||
if(window.currentStream == 'statuses/public_timeline.json') {
|
||||
$('body').css('background-image', 'url(' + window.fullUrlToThisQvitterApp + 'img/mela.jpg)');
|
||||
}
|
||||
|
||||
$('#submit-login').removeAttr('disabled');
|
||||
|
||||
// delete any locally stored credentials
|
||||
if(localStorageIsEnabled()) {
|
||||
delete localStorage.autologinUsername;
|
||||
delete localStorage.autologinPassword;
|
||||
}
|
||||
|
||||
$('#user-header').animate({opacity:'0'},200);
|
||||
$('#user-body').animate({opacity:'0'},200);
|
||||
$('#user-footer').animate({opacity:'0'},200);
|
||||
$('.menu-container').animate({opacity:'0'},200);
|
||||
$('.language-dropdown').css('display','block');
|
||||
$('.dropdown-menu.quitter-settings li.language').css('display','none');
|
||||
$('#settingslink').fadeOut('slow');
|
||||
$('#search').fadeOut('slow');
|
||||
|
||||
$('input#nickname').focus();
|
||||
$('.front-signup').animate({opacity:'1'},200);
|
||||
if(doShake || localStorage.doShake) {
|
||||
|
@ -679,7 +611,7 @@ $('body').on('click','.member-button',function(event){
|
|||
|
||||
$('#user-header, #user-queets, #user-following, #user-followers, #user-groups').on('click',function(){
|
||||
if($(this).attr('id') == 'user-header' || $(this).attr('id') == 'user-queets') {
|
||||
setNewCurrentStream('statuses/user_timeline.json?screen_name=' + window.loginUsername,function(){},true);
|
||||
setNewCurrentStream('statuses/user_timeline.json?screen_name=' + window.loggedIn.screen_name,function(){},true);
|
||||
}
|
||||
else if($(this).attr('id') == 'user-following') {
|
||||
setNewCurrentStream('statuses/friends.json?count=20',function(){},true);
|
||||
|
@ -780,22 +712,22 @@ $(document).on('click','a', function(e) {
|
|||
// whole network feed
|
||||
else if($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain,'') == '/main/all') {
|
||||
e.preventDefault();
|
||||
setNewCurrentStream('statuses/public_and_external_timeline.json?since_id=1',function(){},true);
|
||||
setNewCurrentStream('statuses/public_and_external_timeline.json',function(){},true);
|
||||
}
|
||||
// logged in users streams
|
||||
else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/' + window.loginUsername,'') == '/all') {
|
||||
else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/' + window.loggedIn.screen_name,'') == '/all') {
|
||||
e.preventDefault();
|
||||
setNewCurrentStream('statuses/friends_timeline.json',function(){},true);
|
||||
}
|
||||
else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/' + window.loginUsername,'') == '/replies') {
|
||||
else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/' + window.loggedIn.screen_name,'') == '/replies') {
|
||||
e.preventDefault();
|
||||
setNewCurrentStream('statuses/mentions.json',function(){},true);
|
||||
}
|
||||
// else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/','') == window.loginUsername) {
|
||||
// else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/','') == window.loggedIn.screen_name) {
|
||||
// e.preventDefault();
|
||||
// setNewCurrentStream('statuses/user_timeline.json',function(){},true);
|
||||
// }
|
||||
else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/' + window.loginUsername,'') == '/favorites') {
|
||||
else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/' + window.loggedIn.screen_name,'') == '/favorites') {
|
||||
e.preventDefault();
|
||||
setNewCurrentStream('favorites.json',function(){},true);
|
||||
}
|
||||
|
@ -803,7 +735,7 @@ $(document).on('click','a', function(e) {
|
|||
else if ((/^[a-zA-Z0-9]+$/.test($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/','')))) {
|
||||
e.preventDefault();
|
||||
if($(this).parent().attr('id') == 'user-profile-link') { // logged in user
|
||||
setNewCurrentStream('statuses/user_timeline.json?screen_name=' + window.loginUsername,function(){},true);
|
||||
setNewCurrentStream('statuses/user_timeline.json?screen_name=' + window.loggedIn.screen_name,function(){},true);
|
||||
}
|
||||
else if($(this).hasClass('account-group')) { // any user
|
||||
setNewCurrentStream('statuses/user_timeline.json?screen_name=' + $(this).find('.screen-name').text().substring(1).toLowerCase(),function(){},true);
|
||||
|
@ -853,7 +785,7 @@ $(document).on('click','a', function(e) {
|
|||
else if (($(this).children('span.mention').length>0 // if it's a mention
|
||||
|| ($(this).hasClass('account-group') && $(this).attr('href').indexOf('/group/')==-1) // or if this is queet stream item header but not a group
|
||||
|| ($(this).closest('.stream-item').hasClass('activity') && $(this).attr('href').indexOf('/group/')==-1)) // or if it's a activity notice but not a group link
|
||||
&& typeof window.loginUsername != 'undefined') { // if logged in
|
||||
&& typeof window.loggedIn.screen_name != 'undefined') { // if logged in
|
||||
e.preventDefault();
|
||||
display_spinner();
|
||||
getFromAPI('externalprofile/show.json?profileurl=' + encodeURIComponent($(this).attr('href')),function(data){
|
||||
|
@ -920,7 +852,7 @@ $(document).on('click','a', function(e) {
|
|||
else if (($(this).children('span.group').length>0 // if it's a group mention
|
||||
|| ($(this).hasClass('account-group') && $(this).attr('href').indexOf('/group/')>-1) // or if this is group stream item header
|
||||
|| ($(this).closest('.stream-item').hasClass('activity') && $(this).attr('href').indexOf('/group/')>-1)) // or if it's a activity notice
|
||||
&& typeof window.loginUsername != 'undefined') { // if logged in
|
||||
&& typeof window.loggedIn.screen_name != 'undefined') { // if logged in
|
||||
e.preventDefault();
|
||||
display_spinner();
|
||||
getFromAPI('statusnet/groups/show.json?id=foo&uri=' + encodeURIComponent($(this).attr('href')), function(data){ if(data){
|
||||
|
|
Loading…
Reference in New Issue
Block a user