“StatusNet” 标签页面:

  • StatusNet在Nginx下的rewrite规则

    StatusNet在Nginx下的rewrite规则。假设StatusNet装在abc.creke.net的sn目录下,访问地址为abc.creke.net/sn/,则其在Nginx下的rewrite规则如下:

    #StatusNet
    location /sn
    {
            try_files $uri $uri/ @statusnet;
    }
    location @statusnet
    {
            rewrite ^/sn/(.*)$ /sn/index.php?p=$1 last;
    }

    将其放在“server{}”块中靠前位置即可。

    如果不启用fancy url,这时会发现登录页面404,因为类似“abc.creke.net/sn/index.php/main/login”这类地址nginx不认为是需要交到php处理的地址。这时有两种解决方法。

    第一种,最简单的就是在config.php中加上开启fancy url的语句,同时按照上面说的配好rewrite:

    $config['site']['fancy'] = true;

    第二种,就是将上面的rewrite中的rewrite规则换成:

    rewrite ^/sn/index\.php\(.*)$ /sn/index.php?p=$1 last;

    好吧,除了我,谁那么无聊用第二种啊……用第一种呗。

    2011.08.16 / 暂无评论 / 778 次点击 / 分类: 所谓技术

  • 解决IE6/IE7浏览器不能浏览Statusnet的问题

    Jaylin的全力研究下,终于解决的IE6/IE7浏览器浏览“StatusNet”时不能载入CSS样式的问题,非常感谢Jaylin!研究该问题的过程非常曲折,耗了一个近两个星期时间(虽然不是每天在研究),解决办法倒是异常简单。

    问题就出在“@import url() screen, projection, tv, print;”,

    IE浏览器不支持后面的“screen, projection, tv, print”。

    所以,我把default theme里面的display.css中的

    “@import url(../../base/css/display.css) screen, projection, tv, print;”

    改成“@import url(../../base/css/display.css) ;”,

    IE浏览就能正常浏览“StatusNet”了。

    目前还存在一个问题:部分IE6浏览器浏览“StatusNet”时会提示IE无法打开站点,终止操作,但实际上已经打开了,希望高手能指点一下怎么解决该问题。

    原文出处

    2010.09.09 / 4 条评论 / 1,038 次点击 / 分类: 借此鉴彼

  • StatusNet配置文件config.php(安装参考)

    StatusNet安装配置。

    以下是config.php刷屏,O(∩_∩)O~

    //使用URL Rewrite
    $config['site']['fancy'] = true;
    //对手机浏览友好
    $config['site']['mobile'] = true;
    
    //Settings
    $config ['location']['share'] = false; // 设置是否显示“地理共享”选择框(checkbox);
    $config ['location']['sharedefault'] = false; //设置用户地理共享默认选择,设置为false,则所有新注册的用户均关闭地理位置
    $config['attachments']['uploads'] = false; //关闭上传
    
    //卸载不需要的插件
    unset($config['plugins']['default']['Mapstraction']);//关闭地理信息分享
    unset($config['plugins']['default']['OStatus']);//关闭Ostatus
    unset($config['plugins']['default']['OpenID']);//关闭OpenID
    unset($config['plugins']['default']['WikiHashtags']);//关闭WikiHashtags
    unset($config['plugins']['default']['Geonames']);//关闭Geonames
    
    // Twitter 设置
    $config['admin']['panels'][] = 'twitter';//将twitter选项加到管理员菜单中
    $config['twitter']['signin'] = false;
    
    // Twitter integration source attribute. Note: default is StatusNet
    $config['integration']['source'] = 'StatusNet';
    
    // Enable bidirectional Twitter bridge
    //
    // NOTE: if you enable this you must also set $config['avatar']['path']
    //
    $config['twitterimport']['enabled'] = true;
    
    // Twitter OAuth settings. Documentation is at http://apiwiki.twitter.com/OAuth-FAQ
    //下面设置在twitter中注册的API
    $config['twitter']['consumer_key']    = '';
    $config['twitter']['consumer_secret'] = '';
    
    //打开twitter连接插件
    addPlugin('TwitterBridge');
    
    //打开MobileProfile插件,为手机浏览行方便
    addPlugin('MobileProfile');

    其中,“$config['integration']['source']”是你注册twitter api时的API名字。如果有中文,记得把config.php保存为“UTF 无BOM”编码格式。

    2010.06.05 / 暂无评论 / 920 次点击 / 分类: 所谓技术

  • StatusNet在IIS下的Rewrite规则

    StatusNet在IIS下的Rewrite规则,其实跟WordPress的大致相同,大家也可以在IIS下转换.htaccess。不过这个StatusNet在IIS下有个问题,就是不能使用API。

    Rewrite规则如下:

    <configuration>   
      <system.webServer>   
        <rewrite>   
          <rules>  
            <rule name="StatusNet" patternSyntax="Wildcard">   
              <match url="*" />   
                <conditions>   
                  <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />   
                  <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />   
                </conditions>   
              <action type="Rewrite" url="index.php?p={R:1}" />   
            </rule>        
          </rules>   
        </rewrite>   
      </system.webServer>   
    </configuration>

    2010.06.05 / 暂无评论 / 598 次点击 / 分类: 所谓技术

  • 转换WordPress博客(P2)主题数据库到StatusNet

    前几天,某微博需要更新。原来用的是Wordpress系统,要转换到StatusNet。前者很成熟,相关插件很多,但方向是CMS,不是微博;后者发展潜力很大,但开发程度不够,就是个Microblog程序。

    转就转吧。我研究了一下WP和SN的数据库,还是有收获的。我已经在SN建立好用户,来对应WP的用户,虽然用户ID不同,但是系统只有两个用户,还是很方便映射的。

    WP需要提取数据的表:wp_posts、wp_comments。

    SN需要插入数据的表:notice、conversation、reply。

    好吧,详情查看代码。贴在这里

    2010.05.23 / 1 条评论 / 930 次点击 / 分类: 所谓技术

  • Convert WordPress (P2) Microblog Database to StatusNet

    A few days ago , I tried to convert our WordPress blog , which was used to be our microblog with P2 theme , to StatusNet . StatusNet is a good microblog system , though it needs more developing .

    I wrote a PHP script to convert the WordPress database to StatusNet . There're posts and comments in WP that needs to be converted . Firstly , I said that I had no idea how to convert the replies . And I got a pretty answer "There is alway blood in every revolution" . But finally , I found a  way to convert .

    I had ONLY 2 users in WP , so it got a little simplier to do the converting job . If you have many users , you have to make a right users map about WP and SN , both in user IDs and reply "@"s .

    The "wp_posts" tables in WP needs to be converted , and the usernames in it is easy to convert . However , we need to convert "wp_comments" tables as replies into StatusNet , and the names has no relationship with WP users . So I wrote a function called "getID" to map the commenters in WP to user IDs in SN . And the "getID" function has another funtion , which is to map the WP user IDs to SN user IDs .

    I also import both WP db and SN db into one database to simplify the script .

    Here are the codes :

    <?php
    /*
    By Creke
    http://blog.creke.net
    */
    
    header('Content-Type: text/plain'); 
    
    function getID($i)
    {
    	if($i == 2 || strtolower($i) == 'user1')
    	{
    		return 4;
    	}
    	else if($i == 3 || strtolower($i) == 'user2')
    	{
    		return 3;
    	}
    	else
    	{
    		return 1;
    	}
    }
    
    	$mysql_a='dbhost';
    	$mysql_u='dbuser';
    	$mysql_p='dbpassword';
    	$mysql_n='dbname';
    	
    	set_time_limit(10); 
    
    		if($dblink = mysql_connect($mysql_a,$mysql_u,$mysql_p))
    		{
    			if(mysql_select_db($mysql_n))
    			{
    
    mysql_query("SET NAMES 'utf8'");
    mysql_query('TRUNCATE notice ;');
    mysql_query('TRUNCATE conversation ;');
    mysql_query('TRUNCATE reply ;');
    
    $oldID = 0;
    $newID = 1;
    $newConID = 1;
    
    //$SQL = "";
    //$result = "";
    //$myres = 
    
    for($i=0;$i<=505;$i++)
    	{
    		//post
    		
    		$oldID = $i;
    		$SQL = 'SELECT * FROM wp_posts WHERE post_type = \'post\' AND ID = '.$oldID;
    		if (!$result = mysql_query($SQL)){ 
    						echo "Execution ERROR :".mysql_error()." "; 
    						echo "SQL is :".$SQL." "; 
    		}
    		$myres = mysql_fetch_array($result);
    		if($myres['post_content']==NULL){
    		continue;
    		}
    		
    		$mynewproid = getID($myres['post_author']);
    		$myres['post_content'] = str_replace('\'','\\\'',$myres['post_content']);
    				
    		$SQL = 'INSERT INTO notice (id,profile_id,uri,content,rendered,created,modified,is_local,source,conversation) VALUES';
    		$SQL .= '('.$newID.','.$mynewproid.',\''.'http://blog.recgo.com/notice/'.$newID.'\',\''.$myres['post_content'].'\',\''.$myres['post_content'].'\',\''.$myres['post_modified_gmt'].'\',\''.$myres['post_modified'].'\','.'1'.',\''.'RecgoWPmblog'.'\','.$newConID.')';
    		
    		if (!mysql_query($SQL)){ 
    						echo "Execution ERROR :".mysql_error()." "; 
    						echo "SQL is :".$SQL." "; 
    		}
    				
    		$SQL = 'INSERT INTO conversation (id,uri,created,modified) VALUES';
    		$SQL .= '('.$newConID.',\''.'http://blog.recgo.com/conversation/'.$newConID.'\',\''.$myres['post_modified_gmt'].'\',\''.$myres['post_modified'].'\')';
    		
    		//echo $SQL;
    		if (!mysql_query($SQL)){ 
    						echo "Execution ERROR :".mysql_error()." "; 
    						echo "SQL is :".$SQL." "; 
    		}
    		
    		$newID2=$newID;
    		$newID++;
    		
    		//reply
    		$SQL = 'SELECT * FROM wp_comments WHERE comment_approved = 1 AND comment_post_ID = '.$oldID.' ORDER BY comment_ID';
    		if (!$result = mysql_query($SQL)){ 
    						echo "Execution ERROR :".mysql_error()." "; 
    						echo "SQL is :".$SQL." "; 
    		}
    		
    		while($myres = mysql_fetch_array($result))
    		{
    			if($myres['comment_content']==NULL){
    			continue;
    			}
    			
    			$mynewproid = getID($myres['comment_author']);
    			$commentID2newreplyto[$myres['comment_ID']]=$newID;
    			if($myres['comment_parent']!=0)
    			{
    				$newreplyto=$commentID2newreplyto[$myres['comment_parent']];
    			}
    			else
    			{
    				$newreplyto=$newID2;
    			}
    			
    			if($mynewproid == 3)
    			{
    				$myres['comment_content'] = '@user1 '.$myres['comment_content'];
    				$myreplyproid = 4;
    			}
    			else if($mynewproid == 4)
    			{
    				$myres['comment_content'] = '@user2 '.$myres['comment_content'];
    				$myreplyproid = 3;
    			}
    			$myres['comment_content'] = str_replace('\'','\\\'',$myres['comment_content']);
    			$myres['comment_content'] = str_replace('\"','\\\"',$myres['comment_content']);
    			
    			$SQL = 'INSERT INTO notice (id,profile_id,uri,content,rendered,created,modified,is_local,source,conversation,reply_to) VALUES';
    			$SQL .= '('.$newID.','.$mynewproid.',\''.'http://blog.recgo.com/notice/'.$newID.'\',\''.$myres['comment_content'].'\',\''.$myres['comment_content'].'\',\''.$myres['comment_date_gmt'].'\',\''.$myres['comment_date'].'\','.'1'.',\''.'RecgoWPmblog'.'\','.$newConID.','.$newreplyto.')';
    			
    			//echo $myres['comment_content'].'\n';
    			if (!mysql_query($SQL)){ 
    							echo "Execution ERROR :".mysql_error()." "; 
    							echo "SQL is :".$SQL." "; 
    			}
    			
    			$SQL = 'INSERT INTO reply (notice_id,profile_id,modified) VALUES';
    			$SQL .= '('.$newID.','.$myreplyproid.',\''.$myres['comment_date'].'\')';
    			
    			if (!mysql_query($SQL)){ 
    							echo "Execution ERROR :".mysql_error()." "; 
    							echo "SQL is :".$SQL." "; 
    			}
    			
    			$newID++;
    		}
    		$newConID++;
    	}
    
    			}
    			else
    			{
    				$self_des = "";
    				echo '<br>Linked to MySQL , Can\'t open database ';
    			}
    		}
    		else
    		{
    			$self_des = "";
    			echo '<br>Unable to link to Database ';
    		}
    		mysql_close($dblink);
    
    exit();
    ?>

    Good Luck ^_^

    2010.05.22 / 暂无评论 / 852 次点击 / 分类: 所谓技术