标签: 〖Pligg〗


Pligg 1.03 没有找到 RSS importer 插件

很迷惑。

但是 Pligg 1.03 似乎解决了中文化、汉字乱码…等一系列以前版本的问题。

RSS importer 是一定要的,先攒些文章在这里。

———-

Pligg插件RSS importer使用笔记

原文:http://hi.baidu.com/ayifa/blog/item/10abdf62573bb3d4e7113ae5.html

RSS importer几乎可说是安装Pligg后必用插件,我们可以用它来从指定的Feed定时抓取更新。在安装了Pligg Beta 9.9.5之后,可以使用管理员账号从管理面板进入Module Management,找到RSS importer安装并启用。

抓取中文内容标题与内容为空的问题

如果抓取的目标文章title是中文的话,极有可能写入后title、content均为空——事实上,直接submit一个中文标题的story也会出现这种情况。

检查/libs/link.php发现,Pligg插入Link的流程是

  1. 先插入一条含作者、创建时间、分类等关联内容的条目,这些列的类型多为int或timestamp。
  2. 然后再通过update来为刚插入的行写入title、content、title_url、tags以及extend fields等文本内容,这些列的内容多为varchar或text。

在update这个流程,它会先给这些数据分别做db-escape,如果title_url为空的话,它还将使用一个makeUrlFriendly函数处理title,赋予title_url。

这个函数在处理中文时返回的结果多数情况下会导致包含该字串的sql不能被顺利执行,以致link更新失败,从而出现link写入成功但是标题和内容均为空的问题。

比较理想的做法是如同wordpress插件cos_translator那样,利用google translate取回一个英文翻译结果赋予title_url。不想费这个劲的话,直接把titile赋给title_url也行。

修改/libs/link.php 把139行注释替换为

//if($link_title_url == ""){$link_title_url = makeUrlFriendly($this->title);}
if($link_title_url == ""){$link_title_url = $link_title;}

这样修改解决了未设置title_url时的问题,但使用RSS importer抓取的时候,插件已经先行一步使用makeUrlFriendly给title_url赋值了,这也需要取消掉。
修改/modules/rss_import/templates/import_fields_center.tpl 把78行注释替换为

//$linkres->title_url = makeUrlFriendly($linkres->title);
$linkres->title_url = $linkres->title;

抓取时重复更新计数的问题

在RSS importer里可以给一个Feed设置Random Votes,以后从该Feed抓取回来的链接,每一条都会被先预置Votes。比如我们给一个Feed预置5-10的votes,那么取回来的文章会随机的得到在这之间的一个votes。

问题就在这里设置votes的流程是

  1. 先往votes表里插入一条vote,计算该link的votes数并更新..
  2. 再往votes表里插入一条vote,计算该link的votes数并更新…
  3. 如此往复….

如果votes为200的话,那就重复200次。

我们可以把计算votes数并更新这个流程移出来,做一次就可以了。
具体是修改/modules/rss_import/templates/import_fields_center.tpl 147行,把这行起看到的第一个}移到这行之前。

———-

搭建pligg的几个问题

原文:http://www.cssass.com/blog/index.php/2009/274.html

1,我安装在服务器上之后(本人服务器之过,应属个别问题),_modules表中无法写入数据,即后台无法启用modules(类似wordpress中的plugins)。其他的modules也就算了,其中却有一个Rss Importer。可以导入RSS数据,我觉得是必不可少的。
     既然,无法通过后台PHP程序插入数据库,那在MYSQL中直接使用SQL语句插入总没问题吧。果然,可以启用。
      SQL语句,以启用Rss Importer为例:

  1. INSERT INTO `pligg_modules` (`id`, `name`, `version`, `latest_version`, `folder`, `enabled`) VALUES
  2. (2, ‘RSS Importer’, 0.9, 0, ‘rss_import’, 1);

2, 我在本地安装的时候,发现中文数据是乱码(有众多???号)。在服务器上安装没问题。其实这是因为我本地创建数据库的时候选择的charset等有问题,我选择的是默认default(我本地的SQL工具为SQLyog)。
        正确的设置是charset:utf8;collation:utf8_general_ci;
3,RSS Importer的用法。虽然启用了这个module。但用的时候,刚开始却没摸到门路。其实我很质疑rss importer的界面设计。rss importer参数设置有三步。
第一步:填Feed Name和URL。
第二步:点edit进入,按需要修改一些参数。
第三步:(我所忽略的就是这一点)点Add a new field link 。对应XML数据标记和pligg的变量,可以点击Examine this feed 做参考。一般是title——link_title;link——link_url;description——link_content

4,如何将本地和主机上的数据互搬。本来也只需把导出的SQL,搜索替换一下域名就可以了。但如果本地或主机上有一个安装目录,就需要多做一步了。

  1. Location Installed’, ‘$my_pligg_base’, ‘/digg’, ”, ‘/(folder name)’, ‘Pligg Base Folder’,

其中的digg就是安装目录了。如果是根目录,则留空。
这个设置的在settings.php中$my_pligg_base = ”;但如果修改这里,却是无效的,反而会被SQl数据所重置。
另外补充一个,数据库连接的设置在/libs/dbconnect.php中。
如果,要将本地或空间的文件覆盖对方,这个文件是不能拿去覆盖的。settings.php也不要拿去覆盖。

一个仍无头绪,但绕道解决的问题——汉化问题。
      本来这个汉化,只需修改language.conf文件就可以的,但我修改后,中文却是显示乱码。而在后台language选项下修改也不行。修改后中文显示的是Hex码。。。
最后,我无奈直接在tpl文件中修改,工作量大了很多。

      几个程序上的修改。
1,于中文信息的输入,往往出现link_title_url too long的问题。
我们找到link.php中。

  1. $link_title = $db->escape($this->title);
  2. $link_title_url = $db->escape($this->title_url);
  3. if($link_title_url == ""){$link_title_url = makeUrlFriendly($this->title);}

再搜索makeUrlFriendly这个函数,找到utils.php。
在makeUrlFriendly这个函数下第二行,

  1. $output = utf8_substr($input, 0, 240);

这个数值改大一点就可以了。
然后可能还需修改sql数据库的结构,将_inks表下link_url_title数据项的Len值留空或改大。

2,虽然可以在后台设置文章允许的html tags。但通过rss importer导入的文章显示的缩略文却是屏蔽标签的。所以如果要让首页显示的缩略文也支持html tags。可以在modules/rss_import/templates/import_fields_center.tpl中去除strip_tags函数。

  1. $linkres->link_summary = close_tags(utf8_substr(strip_tags($linkres->content), 0, StorySummary_ContentTruncate – 1));

去除后:

  1. $linkres->link_summary = close_tags(utf8_substr($linkres->content, 0, StorySummary_ContentTruncate – 1));

3,缩略文允许html tags之后,就有了一个问题:缩略文是截取原文中前400个字符的(默认),假如截取的末尾是

<a href=”abcde

这半个”号就会引发html闭合问题。
解决方法就是搜索文中的”和’号,替换为空。我们将这个代码加在close_tags的函数定义中。
找到html1.php 中的close_tags函数。
在第一行,加上

  1. $html=preg_replace ("/\’|\"/","", $html);

除此之外,colse_tags函数虽然可以闭合有开始没结束的标签(事后发现,对于复杂的html结构,这个闭合并不能生效,函数需要大改进…)。对于

<p class=”begin”

这样的半个开始标签,函数却没有解决闭合问题。
修改:

  1. if (preg_match_all(’/<([a-z]+)(?: .*)?(?<![\/|\/ ])>/iU’, $html, $m))
  2. $opened_tags = $m[1];

改为:

  1. if (preg_match_all(’/<([a-z]+)(?: .*)?(?<![\/|\/ ])>/iU’, $html, $m))
  2. {
  3. $opened_tags = $m[1];
  4. preg_match_all(’/<([a-z]+)(?: .*)?(?<![\/|\/ ])>/iU’, $html, $m);
  5. $opened_tags2=$m[1];
  6. if(count($opened_tags2)!=count($opened_tags))
  7. $html .= ‘>’;
  8. }

整个函数变为:

  1. function close_tags($html)
  2. { $html=preg_replace ("/\’|\"/","", $html); 
  3. $single_tags = array(’meta’,'img’,'br’,'link’,'area’);
  4. if (preg_match_all(’/<([a-z]+)(?: .*)?(?<![\/|\/ ])>/iU’, $html, $m))
  5. {
  6. $opened_tags = $m[1];
  7. preg_match_all(’/<([a-z]+)(?: .*)?(?<![\/|\/ ])>/iU’, $html, $m);
  8. $opened_tags2=$m[1];
  9. if(count($opened_tags2)!=count($opened_tags))
  10. $html .= ‘>’;
  11. }
  12. else
  13. return $html;
  14. if (preg_match_all(’/<\/([a-z]+)>/iU’, $html, $m))
  15. $closed_tags = $m[1];
  16. else
  17. $closed_tags = array();
  18. if (count($closed_tags) == count($opened_tags))
  19. return $html;
  20. for ($i=count($opened_tags)-1; $i>=0; $i–)
  21. {
  22. if (!in_array($opened_tags[$i],$single_tags))
  23. {
  24. if (!in_array($opened_tags[$i], $closed_tags))
  25. $html .= ‘</’.$opened_tags[$i].’>’;
  26. }
  27. }
  28. return $html;
  29. }

整个函数对于

  1. $html = " <p><b>bold text</b>sdasd<a href=’howdy.html";

可以完好闭合,
但复杂点的,如

  1. $html = "<p>s<a href=’as’ >asd</a>adasd</p><p><b>bold text</b>sdasd<a href=’howdy.html";

就不能完好闭合了。

待续改进。

———-

发表评论

Pligg Template 起步:模板安装和修改

Starting a New Template.


开始一个新的模板。

Create: /templates/TEMPLATENAME / directory, replacing TEMPLATENAME with your own template title.
创建:模板放在 / templates / TEMPLATENAME / 目录中,用你自己的模板标题替换TEMPLATENAME。

Copy: The contents of a preexisting template of your choice. Make sure that you are copying a template that is compatible with yoru version of Pligg. (ex. /templates/wistie/)
复制:对一个您所选择已经存在的模板,请确保您正在复制的模板与Pligg版本兼容。 (例如:/ templates / wistie /)

Paste: The copied template contents of your choice into the new /templates/TEMPLATENAME / directory. This will function as a starting point for creating your new template and it will make the process a lot easier than trying to figure it out and write a template from scratch.
粘贴:您所选择的模板内容复制粘贴到新的 / templates / TEMPLATENAME / 目录。这将作为一个用于创建新的模板的功能,它将使这一过程容易得多,相较定制外观和从头开始写一个模板。

This step will include your template in the settemplate.php file so that it can be selected.
此步骤将在settemplate.php文件中包括您的模板,以便它可以被选中。

Open: /templates/templates.tpl
打开:/ templates / templates.tpl

Copy/Paste the list item line for Wistie. Then rename Wistie to your template name:
复制/粘贴 Wistie的列表项行。然后重命名Wistie为您的模板名称:

HTML Code:
HTML代码:

<li><a href = "{$my_pligg_base}/settemplate.php?template=TEMPLATENAME">TEMPLATENAME</a></li>

 

Modifying a Template

修改模板

Pligg offers a built in template editor (located at /admin/admin_editor.php), but we recommend that you make edits to the tpl files from your local computer and then uploading the altered .tpl files to your server when making changes.
Pligg提供了一个内置的模板编辑器(位于 / admin / admin_editor.php),但我们建议您在本地计算机上对 .tpl 文件进行修改,然后将变更后的 .tpl 文件上载到您的服务器。

The quickest way to change the look of your site is to simply modify the stylesheet file (.css), by editing only that file you can dramatically change the look of site. For some templates, replacing images is a quick way to change the look of parts of a template.
最快捷的改变您网站的外观的方法是简单地修改样式表文件(.CSS),只通过编辑这个文件,您就可以极大地改变网站外观。对于一些模板,更换图像是一种快速的方式,对于要改变模板部件的外观。

发表评论

pligg 集成 wysiwyg 编辑器 tinymce

FROM: http://www.yeeach.com/2007/10/13/pligg-%e9%9b%86%e6%88%90wysiwyg-%e7%bc%96%e8%be%91%e5%99%a8tinymce/

由于在自己的个人站点上用pligg来作为网摘工具,因此希望在摘录时候能够直接能够把内容及格式保留下来,而不是单纯的文字介绍,因此用tinymce(用空再试fckeditor)来替代pligg本身的textarea,记录一下集成过程:

(阅读全文…)

发表评论

TinyMCE editor for Pligg: 为Pligg加TinyMCE编辑器

Steps:
1] copy files tiny_mce to /3rdParty folder (if you chose to get files from the tinyMCE main site then please copy only the folder tiny_mce under /tinymce/jscripts/ to 3rdParty in Pligg base) or download this topic.
2] Enable HTML in submit from admin panel to include the following tags

Code:


<br><font><img><p><a><strong><ul><li><ol><u><em><span><pre><h1><h2><h3><hr><embed>

3] Edit Pligg.tpl to have the following lines after the

Code:


{checkForJs}

Code:


{if $pagename eq "submit" or "editlink"} <script language="javascript" type="text/javascript" src="{$my_pligg_base}/3rdparty/tiny_mce/tiny_mce.js"></script> {/if}

4] Edit submit_step_2.tpl to have the following lines after

Code:


{config_load file="/libs/lang.conf"}

add

Code:


{literal} <script language="javascript" type="text/javascript"> tinyMCE.init({ mode : "exact", elements : "bodytext,summarytext", theme : "advanced", plugins : "advimage,advlink,emotions,iespell,insertdatetime,preview,media,visualchars,xhtmlxtras", theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,insertdate,inserttime,|,forecolor,backcolor,|,hr,removeformat,formatselect", theme_advanced_buttons2 : "link,unlink,image,media,|,undo,redo,cleanup,|,code,preview", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_path_location : "bottom", extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]", browsers : "msie,gecko,opera,safari" }); </script> {/literal}

5] Edit editlink_edit_center.tpl to have the following lines after

Code:


{config_load file="/libs/lang.conf"}

add

Code:


{literal} <script language="javascript" type="text/javascript"> tinyMCE.init({ mode : "exact", elements : "bodytext,summarytext", theme : "advanced", plugins : "advimage,advlink,emotions,iespell,insertdatetime,preview,media,visualchars,xhtmlxtras", theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,insertdate,inserttime,|,forecolor,backcolor,|,hr,removeformat,formatselect", theme_advanced_buttons2 : "link,unlink,image,media,|,undo,redo,cleanup,|,code,preview", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_path_location : "bottom", extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]", browsers : "msie,gecko,opera,safari" }); </script> {/literal}

FROM: http://www.pliggtemplates.eu/index.php?Itemid=43&catid=5&func=view&id=25&option=com_fireboard

发表评论

修改 Pligg 模板以放置广告等

修改Pligg网站右边栏:

  • 进入控制面板Admin Panel —-> Template Editor —-> 修改/templates/yget/sidebar.tpl—-> 修改相应部分的代码
  • 比如:如果不显示评论,则可删除以下代码:{assign var=sidebar_module value="sidebar_comments"}{include file=$the_template_sidebar_modules."/wrapper.tpl"},其它代码与此相似,通常红色部分表示这一部分代码的类别,如:今日之最、最新发布的资讯、分类、评论、标签等。

(阅读全文…)

发表评论

Pligg有何不同?How is Pligg Different?

How is Pligg Different?

Pligg有何不同?

Pligg was created as a social publishing CMS. While most content management systems are designed for only a handful of authors, Pligg CMS was designed to manage a site with an unlimited number of authors. All of these registered users are in control of the website’s content. It is a user driven CMS that relies on independent authors content and participation to manage news articles.

Pligg作为一种社会化发布CMS被创建。大多数内容管理系统是设计为只有极少数的作者的,而Pligg CMS是为有无限量作者的网站管理设计的。所有注册用户都在管理网站内容。它是用户驱动的CMS,依赖于独立的作者提供内容和参与管理文章。

Pligg started as a simple CMS to let users submit and vote on news articles, and that’s still what we do best. Vote on stories that interest you and articles that receive enough votes will appear on the homepage of your Pligg site. Pligg offers a 5 star method for voting or the more traditional numbered voting as seen on sites like Digg, Mixx or Reddit.

Pligg开始作为一个简单的CMS,让用户提交和表决新闻文章,而这一直是我们最擅长的。投票给你有兴趣的文章,得到足够的票数的文章将出现在您的Pligg网站的首页。Pligg提供了五个星的投票方法或者较传统的编号投票方法,就像Digg,Mixx或Reddit网站一样。

(阅读全文…)

发表评论

如何安装 Pligg(英汉对照 附实际安装截图)

How to Install Pligg
如何安装 Pligg

(阅读全文…)

Comments (3)