Skip to content

Commit

Permalink
Blog fix (#12)
Browse files Browse the repository at this point in the history
* unescaped file

* code highlighting cleanup

* tool i used to fix wp exporter escapaing

* cleanup orcle

* css updates and section verbage

* link to theme, not site code in gh
  • Loading branch information
eddiewebb authored Feb 12, 2020
1 parent 3c1b5f7 commit d197a6c
Show file tree
Hide file tree
Showing 81 changed files with 1,468 additions and 1,366 deletions.
16 changes: 16 additions & 0 deletions .circleci/unescape_blog.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /bin/bash


DIR=${1:-"src/content/blog"}
for file in ${DIR}/*/index.md; do
path=${file%/*}
echo $path
mv "$file" "${path}/unescaped.md"
while IFS= read line;do
echo "$line"
done < "${path}/unescaped.md" > "$file"
rm "${path}/unescaped.md"
done


#grep -oh "\(https://blog.edwardawebb.com/wp-content/uploads/[A-Za-z0-9/_-]*\.png\)" src/content/blog/keys-putty-cygwin-passwordless-login-ssh-scp.md
15 changes: 13 additions & 2 deletions src/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ title = "Eddie Webb"
theme = "resume"
enableGitInfo = true

pygmentsCodeFences = true
pygmentsCodeFencesGuessSyntax = true
[markup]
[markup.highlight]
codeFences = true
guessSyntax = true
hl_Lines = ""
lineNoStart = 1
lineNos = false
lineNumbersInTable = true
tabWidth = 4
style = "tango"




[taxonomies]
tag = "tags"
Expand Down
2 changes: 1 addition & 1 deletion src/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ sitemap:

Eddie has over a decade of experience enabling agile, CI/CD and DevOps culture in the enterprise. Previously the Director of Enterprise Software Delivery Platforms at a Fortune 100 company, Eddie now leverages his experience influencing culture and technology to help CircleCI customers of all sizes adopt the best technologies and practices along their journey.

This site was generated using [HUGO](https://gohugo.io/) from an [open source theme](https://github.com/eddiewebb/json-resume) via a [CircleCI](https://circleci.com/gh/eddiewebb/json-resume).
This site was generated using [HUGO](https://gohugo.io/) from an [open source theme](https://github.com/eddiewebb/hugo-resume) via a [CircleCI](https://circleci.com/gh/eddiewebb/json-resume).

![CircleCI Status Badge](https://circleci.com/gh/eddiewebb/json-resume.svg?style=svg)
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ sitemap:
priority : 0.9
---
This section contains articles migrated from my old Wordpress site. Forgive the formatting please :)

<!--more-->
The "featured" articles are those with highest comment count from WP.
76 changes: 42 additions & 34 deletions src/content/blog/add-rss-feed-cakephp-models/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,54 +32,61 @@ No need to over complicate things here. Imagine you have a standard Model, oh le

#### app/controllers/posts_controller.php -snippet

/\*\*
\* Returns an array of all public posts less than one month old, orderd by date
\*
\* @return unknown
*/
function newsfeed($count=null) {
if(!$count) $count=5;
$this->Post->recursive = 0;
$posts=$this->Post->findAll('is_public = 1
AND is_published = 1
AND Post.date_modified >= now() - INTERVAL 1 MONTH'
,null,'Post.date_modified DESC',$count);
if(isset($this->params\['requested'\])) {
return $posts;
}
$this->set('posts',$posts );
}

```php
<?
/**
* Returns an array of all public posts less than one month old, orderd by date
*
* @return unknown
*/
function newsfeed($count=null) {
if(!$count) $count=5;
$this->Post->recursive = 0;
$posts=$this->Post->findAll('is_public = 1
AND is_published = 1
AND Post.date_modified >= now() - INTERVAL 1 MONTH'
,null,'Post.date_modified DESC',$count);
if(isset($this->params['requested'])) {
return $posts;
}
$this->set('posts',$posts );
}
```
It would be really helpful if CakePHP provided an RSS helper. Zoot alors !  They do!

#### app/controllers/posts_controller.php -snippet

```php
<?
var $helpers = array('Rss');
var $components = array ('RequestHandler');

```
### The XML Generating View

Just like any other view, all we need to do is transform some provided data into a formatted page. This time it will be strict XML without all the html clutter.

#### app/views/posts/rss/newsfeed.ctp

$item\['Post'\]\['title'\],
'link' => array('controller' => 'posts', 'action' => 'view', $item\['Post'\]\['id'\]),
'guid' => array('controller' => 'posts', 'action' => 'view', $item\['Post'\]\['id'\]),
'description' => strip_tags($item\['Post'\]\['body'\]),
'pubDate' => $item\['Post'\]\['date_added'\],
```php
<?
$item['Post']['title'],
'link' => array('controller' => 'posts', 'action' => 'view', $item['Post']['id']),
'guid' => array('controller' => 'posts', 'action' => 'view', $item['Post']['id']),
'description' => strip_tags($item['Post']['body']),
'pubDate' => $item['Post']['date_added'],
);
}

$this->set('items', $rss->items($posts, 'rss_transform'));

$this->set('channelData', $channelData);
?>

```
And of course sticking with format we should want to add an RSS layout.

#### app/views/layouts/rss/default.ctp

```php
<?
header();
$channelData = array('title' => 'Recent News | Digital Business',
'link' => array('controller' => 'posts', 'action' => 'index', 'ext' => 'rss'),
Expand All @@ -89,24 +96,25 @@ header();
);
$channel = $rss->channel(array(), $channelData, $items);
echo $rss->document(array(), $channel);
?>

```
### The RSS compliant URL

You only need to add 2 lines to your routes configuration file for CakePHP to catch and handle the url to pint to your RSS feed. You might use feed.rss, I choice live.rss.

#### app/config/routes.php -snippet

/\*\*
\* ...allow rssextensions
\* and send live.rss to the rss feed
```php
<?
/**
* ...allow rssextensions
* and send live.rss to the rss feed
*/
Router::connect('/live', array('controller' => 'posts', 'action' => 'newsfeed'));
// see my posts on sitemaps to use this next line ;)
Router::connect('/sitemap', array('controller' => 'sitemaps', 'action' => 'index'));
// see my posts on sitemaps to use this next line ;)
Router::connect('/sitemap', array('controller' => 'sitemaps', 'action' => 'index'));

Router::parseExtensions('rss','xml');

```
Yes, you'll notice an additional route there for [dynamic sitemaps](https://blog.edwardawebb.com/programming/php-programming/cakephp/generating-dynamic-sitemaps-cakephp), very useful as well. Sweet! Now just visit http://example.com/live.rss, or throw that url in your favorite Feed Reader to see the results.

#### http://example.com/live.rss
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class DATABASE_CONFIG
function __construct ()
{
//check to see if server name is set (thanks Frank)
if(isset($\_SERVER\['SERVER\_NAME'\])){
switch($\_SERVER\['SERVER\_NAME'\]){
if(isset($_SERVER['SERVER_NAME'])){
switch($_SERVER['SERVER_NAME']){
case 'digbiz.localhost':
$this->default = $this->dev;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ So it goes like this; Your user registers a new account, or sends you a contact

The red boundary denotes new code for the announce submission

Since every cms, site and blog are different, I am unable to provide specifics, but yu should be able to track down the code for your form and find the portion that handles the submission. (Most obviously denoted with $\_POST or $\_GET variable use.)  I will also assume your email field is named 'email' and your name field is two fields; 'firstName', 'lastName';
Since every cms, site and blog are different, I am unable to provide specifics, but yu should be able to track down the code for your form and find the portion that handles the submission. (Most obviously denoted with $_POST or $_GET variable use.)  I will also assume your email field is named 'email' and your name field is two fields; 'firstName', 'lastName';

### Details on the API command

Below is a link to details on the command, needed parameters and possible responses. [Add Subscriber API Command](http://wiki.dreamhost.com/Application_programming_interface#announcement_list-add_subscriber)

### The Announce Submission Code

if(isset($\_POST\['subscribeMe'\]) && $\_POST\['subscribeMe'\] == 1)
if(isset($_POST['subscribeMe']) && $_POST['subscribeMe'] == 1)
{

//get the values we need from form(this should in aprt already be somewhere in the code your editing)
$email=$_POST\['email'\];
$fullName=$\_POST\['firstName'\]." ".$\_POST\['lastName'\];
$email=$_POST['email'];
$fullName=$_POST['firstName']." ".$_POST['lastName'];

//set values we shoudl know, and are constant
$domain="domain of this form";
Expand All @@ -45,8 +45,8 @@ if(isset($\_POST\['subscribeMe'\]) && $\_POST\['subscribeMe'\] == 1)


$ch = curl_init('https://api.dreamhost.com/');
curl\_setopt ($ch, CURLOPT\_POST, 1);
curl\_setopt ($ch, CURLOPT\_POSTFIELDS, "key=$apiKey&cmd=announcement\_list-add\_subscriber&listname=$listname&domain=$domain&email=$email&name=$fullName");
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "key=$apiKey&cmd=announcement_list-add_subscriber&listname=$listname&domain=$domain&email=$email&name=$fullName");
$result=curl_exec ($ch);
curl_close ($ch);

Expand Down
Loading

0 comments on commit d197a6c

Please sign in to comment.