sync
authorBlastytheBlue <blastofmn@gmail.com>
Tue, 16 Dec 2014 09:46:40 +0000 (17:46 +0800)
committerBlastytheBlue <blastofmn@gmail.com>
Tue, 16 Dec 2014 09:46:40 +0000 (17:46 +0800)
Pman/Reddit/DataObjects/Reddit_livefeed_embed.php
Pman/Reddit/DataObjects/reddit.sql
app.webkitpdf [new symlink]

index 9f3a8e8..85f833d 100644 (file)
@@ -15,6 +15,10 @@ class Pman_Reddit_DataObjects_Reddit_livefeed_embed extends DB_DataObject
     public $feed_id;                      // string(254)  not_null
     public $seqid;                        // int(11) not_null
     public $url;                          // string(254) not_null
+    public $frame_width;                   // int(11)
+    public $frame_height;                  // int(11)
+    public $frame_style;                   // TEXT
+    public $frame_body;                    // TEXT
     
     
     /* the code above is auto generated do not remove the tag below */
@@ -35,8 +39,9 @@ class Pman_Reddit_DataObjects_Reddit_livefeed_embed extends DB_DataObject
             echo $dir . "\n";
             mkdir($dir,0775,true);
         }
-        $url = 'http://www.redditmedia.com/mediaembed/liveupdate/tnc30xhiiqom/LiveUpdate_' . $x->uid . '/' . $this->seqid;
-        $cmd = "/usr/bin/xvfb-run seed app.webkitpdf/main.js -u  " . $url . " -d 5000 -H " . $file;
+        //$url = 'http://www.redditmedia.com/mediaembed/liveupdate/tnc30xhiiqom/LiveUpdate_' . $x->uid . '/' . $this->seqid;
+        $url = 'http://roojs.com/reddit/index.php/Embedly?url=' . $this->url;
+        $cmd = "/usr/bin/xvfb-run seed app.webkitpdf/main.js -u  " .escapeshellarg( $url ) . " -d 5000 -H " . $file;
         echo "\n\n".$file."\n\n";
         echo $cmd;
         `$cmd`;
@@ -58,33 +63,33 @@ class Pman_Reddit_DataObjects_Reddit_livefeed_embed extends DB_DataObject
 //        $data = file_get_contents('/home/chris/test_png/test.html');
         
 //        print_r(strlen($data));
-        $html5Tag = array(
-            'canvas', 'audio', 'embed', 'source', 'track',
-            'video', 'datalist', 'keygen', 'output', 'article',
-            'aside', 'bdi', 'details', 'dialog', 'figcaption',
-            'figure', 'figure', 'footer', 'header', 'main',
-            'mark', 'menuitem', 'meter', 'nav', 'progress',
-            'rp', 'rt', 'ruby', 'section', 'summary', 'time',
-            'wbr');
-//        $retData = $data;
-        
-        $testTag = "/\<(".implode('|', $html5Tag).")/i";
-        
-        $retData = preg_replace($testTag, "<div", $data);
-        
-        $testTag = "/\<\/(".implode('|', $html5Tag).")/i";
-        $data = preg_replace($testTag, "</div", $retData);
+//        $html5Tag = array(
+//            'canvas', 'audio', 'embed', 'source', 'track',
+//            'video', 'datalist', 'keygen', 'output', 'article',
+//            'aside', 'bdi', 'details', 'dialog', 'figcaption',
+//            'figure', 'figure', 'footer', 'header', 'main',
+//            'mark', 'menuitem', 'meter', 'nav', 'progress',
+//            'rp', 'rt', 'ruby', 'section', 'summary', 'time',
+//            'wbr');
+////        $retData = $data;
+//        
+//        $testTag = "/\<(".implode('|', $html5Tag).")/i";
+//        
+//        $retData = preg_replace($testTag, "<div", $data);
+//        
+//        $testTag = "/\<\/(".implode('|', $html5Tag).")/i";
+//        $data = preg_replace($testTag, "</div", $retData);
          
 //        print_r($data);exit;
         
         //for fix the HTML issue
-        $data = tidy_repair_string(mb_convert_encoding($data, 'HTML-ENTITIES', "UTF-8"),array(),'UTF8');
-//        print_r($data);exit;
-        if($this->debug_on){
-            echo "Created tidy.... \n\n";
-            echo "<textarea style=\"width: 500px; height: 250px;\">{$data}</textarea>";
-            echo "\n\n";
-        }
+//        $data = tidy_repair_string(mb_convert_encoding($data, 'HTML-ENTITIES', "UTF-8"),array(),'UTF8');
+////        print_r($data);exit;
+//        if($this->debug_on){
+//            echo "Created tidy.... \n\n";
+//            echo "<textarea style=\"width: 500px; height: 250px;\">{$data}</textarea>";
+//            echo "\n\n";
+//        }
         
         
       
@@ -119,10 +124,11 @@ class Pman_Reddit_DataObjects_Reddit_livefeed_embed extends DB_DataObject
         //}
         //
         
-        echo "about to do stylesheets\n";
+        //echo "about to do stylesheets\n";
         
         // get stylesheets.
-        foreach ($xpath->query('//link[@href]') as $l) {
+        
+        /*foreach ($xpath->query('//link[@href]') as $l) {
             
             
             
@@ -136,6 +142,18 @@ class Pman_Reddit_DataObjects_Reddit_livefeed_embed extends DB_DataObject
             $this->addStyleSheet($href);
                      
              
+        }*/
+        echo "about to do iframe\n";
+        foreach ($xpath->query('//iframe') as $f) {
+            $this->frame_width = $f->getAttribute('width');
+            $this->frame_height = $f->getAttribute('height');
+            $this->frame_style = $f->getAttribute('style');
+            $src=$dir . "/" . $f->getAttribute('src');
+            
+            $this->frame_body = file_get_contents($src);
+            $this->update();
+            //echo "done";
+            break;
         }
         
         //echo "about to do style\n"; 
index 7223db2..9009c90 100644 (file)
@@ -1,14 +1,14 @@
 
 CREATE TABLE reddit_livefeed 
 (
-   id INT(11)  NOT NULL auto_increment,
-   body TEXT,
-  uid varchar(64) default '',
-  created_dt datetime,
-  embeds TEXT,
-  author varchar(64),
-  body_html TEXT,
-  PRIMARY KEY (id)
+    id INT(11)  NOT NULL auto_increment,
+    body TEXT,
+    uid varchar(64) default '',
+    created_dt datetime,
+    embeds TEXT,
+    author varchar(64),
+    body_html TEXT,
+    PRIMARY KEY (id)
 
 );
 
@@ -19,7 +19,11 @@ CREATE TABLE livefeed_embed
     id INT(11)  NOT NULL auto_increment,
     feed_id INT(11),
     seqid INT(11),
-    url TEXT
+    url TEXT,
+    frame_width INT(11),
+    frame_height INT(11),
+    frame_style TEXT,
+    frame_body LONGTEXT
 
     PRIMARY KEY (id)
 
diff --git a/app.webkitpdf b/app.webkitpdf
new file mode 120000 (symlink)
index 0000000..ef36961
--- /dev/null
@@ -0,0 +1 @@
+../app.webkitpdf
\ No newline at end of file