Yii Framework Forum: [EXTENSION] EFeed Extension - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] EFeed Extension Feed Writer Generator Extension (RSS 1.0, RSS 2.0, and ATOM 1.0)

#1 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,462
  • Joined: 04-October 10

Posted 01 January 2011 - 03:19 PM

Hi there,

I had to make a RSS channel on my current project and didn't want to include any third party scripts that didn't have the advantages of Yii. This is why I created this Extension.

Please refer to this post for bug reports and/or suggestions.

Link to the Extension for download: http://www.yiiframew...xtension/efeed/


Hope it helps


edit: I knew it was an extension here already developed but I wanted to create something easier to use.
4

#2 User is offline   Roland Csibrei 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 29-November 10
  • Location:Slovakia

Posted 08 January 2011 - 11:35 AM

Thanks for sharing...
0

#3 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,462
  • Joined: 04-October 10

Posted 08 January 2011 - 11:41 AM

Just doing what others did (starting from creator to the rest of the network). Glad to know that my little contribution helps someone.
1

#4 User is offline   Sarke 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 25-October 10

Posted 24 January 2011 - 04:39 AM

Thank you! Very easy to use, and doesn't have to include parts of other frameworks to use! ;)


Oh, and this should probably be 1.1.5?

Quote

Developed using latest stable version of Yii (1.5)

0

#5 User is offline   Gustavo 

  • Master Member
  • Yii
  • Group: Moderators
  • Posts: 916
  • Joined: 27-July 10
  • Location:Curitiba - Brasil

Posted 24 January 2011 - 04:42 AM

It look very promissing and usefull
Ill be using it soon and give you my feed back ;)
--
Extensions:
translate modue - module to handle translations
multiActiveRecord - db selection in models
redisCache - redis cache component
mpCpanel - interact with cpanel api
mUploadify - use uploadify uploader in your application

Gustavo Salomé Silva
0

#6 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,462
  • Joined: 04-October 10

Posted 24 January 2011 - 04:53 AM

View PostSarke, on 24 January 2011 - 04:39 AM, said:

Thank you! Very easy to use, and doesn't have to include parts of other frameworks to use! ;)


Oh, and this should probably be 1.1.5?


I don't think that it wont be compatible with newest versions 1.1.5+

Thanks for the comments. The idea behind this extension was to easy the tasks of RSS feeds. I am glad it is working for you.
0

#7 User is offline   Sarke 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 25-October 10

Posted 24 January 2011 - 12:46 PM

View PostAntonio Ramirez, on 24 January 2011 - 04:53 AM, said:

I don't think that it wont be compatible with newest versions 1.1.5+

No, I meant that it says "1.5" instead of "1.1.5". There is no "Yii 1.5".
0

#8 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,462
  • Joined: 04-October 10

Posted 24 January 2011 - 01:05 PM

View PostSarke, on 24 January 2011 - 12:46 PM, said:

No, I meant that it says "1.5" instead of "1.1.5". There is no "Yii 1.5".


Thanks for pointing that out. All my extensions modified...
0

#9 User is offline   Flokey82 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 20-May 11

Posted 10 June 2011 - 03:25 PM

small bugfix...

If you want to generate nested(?) tags, I found a bug in the EFeedItemAtom.php code that overwrites the existing tag... uh.. let me show you, I'm too tired to explain:

$item->addTag('georss:where',array('gml:Point'=>'test')); <- I do this

and for the code to work I had to patch the getElement function

private function getElement( EFeedTag $tag ){

$element = '';

if(in_array($tag->name,$this->CDATAEncoded))
{
$tag->attributes['type']="html";
$element .= CHtml::openTag($tag->name,$tag->attributes);
$element .= '<![CDATA['.PHP_EOL;

}else
{
$element .= CHtml::openTag($tag->name,$tag->attributes);
}

if(is_array($tag->content))
{
foreach ($tag->content as $tag => $content) //change this to $newtag, or you will overwrite your $tag
{
$tmpTag = new EFeedTag($tag, $content);//same here.. change it to $newtag

$element .= $this->getElement( $tmpTag );
}
}
else
{
$element .= (in_array($tag->name, $this->CDATAEncoded))? $tag->content : CHtml::encode($tag->content);
}

//print_r($tag);die();
$element .= (in_array($tag->name, $this->CDATAEncoded))? "]]>":"";

$element .= CHtml::closeTag($tag->name).PHP_EOL;

return $element;
}

then I can produce Atom Code like this:

<georss:where>
<gml:Point>test</gml:Point>
</georss:where>

I just tested this with one level, but I've to make it deeper.. we'll see if it works out :)
cheers!
0

#10 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,462
  • Joined: 04-October 10

Posted 13 June 2011 - 04:31 AM

Thank you very much Flokey,

I have updated the file. If you don't mind i will mention your help.


Thanks again
0

#11 User is offline   dmaus 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 22-November 10

Posted 20 June 2011 - 08:39 AM

I'm currently looking for an Extenions to produce an Atom feed and noticed a glitch in the implementation of the UUID function: The functions doe /not/ create a valid random UUID according to RFC4122.

To do so, you need to set and flip some bits.

diff -u "c:/Users/Maus/AppData/Local/Temp/7zO2880.tmp/EFeed.php.orig" "c:/Users/Maus/AppData/Local/Temp/7zO2880.tmp/EFeed.php"
--- c:/Users/Maus/AppData/Local/Temp/7zO2880.tmp/EFeed.php.orig	2011-06-20 15:13:57.845000000 +0200
+++ c:/Users/Maus/AppData/Local/Temp/7zO2880.tmp/EFeed.php	2011-06-20 15:31:33.785000000 +0200
@@ -260,9 +260,10 @@
                 $key = ($key == null)? uniqid(rand()) : $key;
                 $chars = md5($key);
                 $uuid  = substr($chars,0,8) . '-';
-                $uuid .= substr($chars,8,4) . '-';
-                $uuid .= substr($chars,12,4) . '-';
-                $uuid .= substr($chars,16,4) . '-';
+                $uuid .= substr($chars,8,4) . '-4';
+                $uuid .= substr($chars,13,3) . '-';
+                $uuid .= sprintf('%x', hexdec(substr($chars,16,2)) & 191 | 128);
+                $uuid .= substr($chars,18,2) . '-';
                 $uuid .= substr($chars,20,12);
 
                 return $prefix . $uuid;

Diff finished.  Mon Jun 20 15:31:49 2011


Best,
-- David
0

#12 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,462
  • Joined: 04-October 10

Posted 20 June 2011 - 12:18 PM

Hi David!

Thanks for your suggestion. You are right, the uuid wasn't RFC4122 compliant and I was about to refactor it with (https://github.com/L...ter/src/uuid.js) but I wouldn't mind to use yours but is it correct?

View Postdmaus, on 20 June 2011 - 08:39 AM, said:


                 $key = ($key == null)? uniqid(rand()) : $key;
                 $chars = md5($key);
                 $uuid  = substr($chars,0,8) . '-';

+                $uuid .= substr($chars,8,4) . '-4'; <---- Is this correct?
+                $uuid .= substr($chars,13,3) . '-';
+                $uuid .= sprintf('%x', hexdec(substr($chars,16,2)) & 191 | 128);
+                $uuid .= substr($chars,18,2) . '-';
                 $uuid .= substr($chars,20,12);
 
                 return $prefix . $uuid;


0

#13 User is offline   dmaus 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 22-November 10

Posted 20 June 2011 - 03:08 PM

View PostAntonio Ramirez, on 20 June 2011 - 12:18 PM, said:

Hi David!

Thanks for your suggestion. You are right, the uuid wasn't RFC4122 compliant and I was about to refactor it with (https://github.com/L...ter/src/uuid.js) but I wouldn't mind to use yours but is it correct?


I would say so. The Specs:

4.4.  Algorithms for Creating a UUID from Truly Random or
      Pseudo-Random Numbers

   The version 4 UUID is meant for generating UUIDs from truly-random or
   pseudo-random numbers.

   The algorithm is as follows:

   o  Set the two most significant bits (bits 6 and 7) of the
      clock_seq_hi_and_reserved to zero and one, respectively.

   o  Set the four most significant bits (bits 12 through 15) of the
      time_hi_and_version field to the 4-bit version number from
      Section 4.1.3.

   o  Set all the other bits to randomly (or pseudo-randomly) chosen
      values.


  • ( & 191 | 128 ) => (& #b1011111 | 0b1000000) => Step 1
  • the literal "4" => Step 2
  • md5($key) => Step 3


The very same algorithm is used in Emacs/Org mode
0

#14 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,462
  • Joined: 04-October 10

Posted 21 June 2011 - 02:56 AM

View Postdmaus, on 20 June 2011 - 03:08 PM, said:

I would say so. The Specs:

4.4.  Algorithms for Creating a UUID from Truly Random or
      Pseudo-Random Numbers

   The version 4 UUID is meant for generating UUIDs from truly-random or
   pseudo-random numbers.

   The algorithm is as follows:

   o  Set the two most significant bits (bits 6 and 7) of the
      clock_seq_hi_and_reserved to zero and one, respectively.

   o  Set the four most significant bits (bits 12 through 15) of the
      time_hi_and_version field to the 4-bit version number from
      Section 4.1.3.

   o  Set all the other bits to randomly (or pseudo-randomly) chosen
      values.


  • ( & 191 | 128 ) => (& #b1011111 | 0b1000000) => Step 1
  • the literal "4" => Step 2
  • md5($key) => Step 3


The very same algorithm is used in Emacs/Org mode


I see, so you talking about Version 4 of UUID and that's correct:
----------
Version 4 UUIDs use a scheme relying only on random numbers. This algorithm sets the version number as well as two reserved bits. All other bits are set using a random or pseudorandom data source. Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, A, or B. e.g. f47ac10b-58cc-4372-a567-0e02b2c3d479.
----------

Thanks, will change the code asap

Cheers
0

#15 User is offline   dmaus 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 22-November 10

Posted 04 July 2011 - 09:52 AM

And another problem: I noticed that current version of EFeed passes an entry's URL to EFeed::uuid() and EFeed::uudi() uses MD5($url) as base for the UUID. But (sorry, I am quite picky with these issues) then the UUID is not a random UUID.

You could use the URL "as is"

RFC 4287, 4.2.6

Quote

Its (sc. atom:id, DM) content MUST be an IRI, as defined by [RFC3987]. Note that the
definition of "IRI" excludes relative references. Though the IRI
might use a dereferencable scheme, Atom Processors MUST NOT assume it
can be dereferenced.


Using the URL of the feed / the entry is a valid option according to RFC4287 and in my eyes far better than pretending that the ID is something else.

Best,
-- David
0

#16 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,462
  • Joined: 04-October 10

Posted 05 July 2011 - 05:15 PM

View Postdmaus, on 04 July 2011 - 09:52 AM, said:

And another problem: I noticed that current version of EFeed passes an entry's URL to EFeed::uuid() and EFeed::uudi() uses MD5($url) as base for the UUID. But (sorry, I am quite picky with these issues) then the UUID is not a random UUID.

You could use the URL "as is"

RFC 4287, 4.2.6


Using the URL of the feed / the entry is a valid option according to RFC4287 and in my eyes far better than pretending that the ID is something else.

Best,
-- David


So you are saying that this should be in place instead:

echo $this->makeNode($key,'',array('href'=>$value));
// And add the id for ATOM
echo $this->makeNode('id',$value);


I should GIT all my extensions so you all can work on to make them better... do not have much time to look at these things now


Thanks David
0

#17 User is offline   dmaus 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 22-November 10

Posted 06 July 2011 - 05:24 AM

View PostAntonio Ramirez, on 05 July 2011 - 05:15 PM, said:

So you are saying that this should be in place instead:

echo $this->makeNode($key,'',array('href'=>$value));
// And add the id for ATOM
echo $this->makeNode('id',$value);



Yes.
0

#18 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,462
  • Joined: 04-October 10

Posted 08 July 2011 - 04:24 AM

View Postdmaus, on 06 July 2011 - 05:24 AM, said:

Yes.


I definitely need to upload these extensions to Git
0

#19 User is offline   exiang 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 23-May 11

Posted 27 July 2011 - 02:22 AM

Hi, I am having this error when trying to createNewItem():

include(CTypedMap.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
0

#20 User is offline   exiang 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 23-May 11

Posted 27 July 2011 - 02:24 AM

View Postexiang, on 27 July 2011 - 02:22 AM, said:

Hi, I am having this error when trying to createNewItem():

include(CTypedMap.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory


ok, solved this issue by importing 'system.collections.*
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users