added view file containing the mark up for the blog output with basic styles
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 4 Aug 2016 15:45:01 +0000 (11:45 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 4 Aug 2016 15:45:01 +0000 (11:45 -0400)
index.php
js/front/front.js [new file with mode: 0644]
models/GlmHubSpotBlog_Widget.php
views/frontPage.php [new file with mode: 0644]

index 125fe04..9b4cf5a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -8,6 +8,7 @@
  * License: All right reserved
  */
 define('GLM_HUBSPOT_PLUGIN_PATH_FILE', __FILE__);
+define('GLM_HUBSPOT_PLUGIN_DIR', plugin_dir_path(__FILE__));
 define('GLM_HUBSPOT_DB_VERSION', '0.0.1');
 define('GLM_HUBSPOT_DB_VERSION_OPTION_NAME', 'glm_hubspot_db_version');
 define('GLM_HUBSPOT_TABLE', 'glm_hubspot_feed');
diff --git a/js/front/front.js b/js/front/front.js
new file mode 100644 (file)
index 0000000..6b44c8d
--- /dev/null
@@ -0,0 +1,6 @@
+/* 
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
index dc30763..37edea7 100644 (file)
@@ -68,8 +68,15 @@ class GlmHubSpotBlog_Widget
     {
         $path = plugin_dir_path(__FILE__);
         $this->check_for_updates();
-        //echo '<pre>$this->feed_data: ' . print_r( $this->feed_data, true ) . '</pre>';
+        $title = $this->feed_data->objects[0]->html_title;
+        $image_url = $this->feed_data->objects[0]->featured_image;
+        $content = $this->feed_data->objects[0]->post_body;
+        $url = $this->feed_data->objects[0]->published_url;
+//        echo '<pre>$this->feed_data: ' . print_r( $this->feed_data, true ) . '</pre>';
+        include_once GLM_HUBSPOT_PLUGIN_DIR . '/views/frontPage.php';
     }
+   
 
     /**
      * check_for_updates
diff --git a/views/frontPage.php b/views/frontPage.php
new file mode 100644 (file)
index 0000000..ede9c2a
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+        
+echo '<div class="hubspot-container">'
+        . '<div class="hubspot-title">'
+            . '<a href="' .$url .'">'
+                . '<h1>' . $title. '</h1>'
+            . '</a>'
+        . '</div>'
+        . '<a class="image-link" href="' .$url .'">'
+            . '<div class="hubspot-featured-image" style="margin: 0 auto;width: 200px; height: 200px;background: url('. $image_url . ') no-repeat center    center;">'
+            . '</div>'
+        . '</a>'
+        . '<div class="hubspot-blog">' . $content . '</div>'
+        . '<a href="' .$url .'"> Read More </a>'
+  . '</div>';
+        ?>
+
+<script type="text/javascript">
+    
+     var blog = jQuery('.hubspot-blog');
+     var image_link = jQuery(".image-link");
+     var image = jQuery(".hubspot-featured-image");
+     var blog_characters = blog.text().length;
+
+     image.css("margin-bottom", "20px").css("background-size", "cover");
+     image_link.css("display", "block").css("width", "200px");
+     blog.find('img').remove();
+
+     if(blog_characters > 600){
+         blog.text(blog.text().substring(0,600) + '...');
+     }
+
+</script>
\ No newline at end of file