Info

Weird Hap'nins—Building a News Aggregating Site

Bad news is always good news for the press. This is why Vaughan Pyre has decided to take advantage of this fact and create a web site that will aggregate bad news and weird happenings from all over the world. The content of the site will be entirely derived from Really Simple Syndication (RSS) feeds from several sources (each feed being automatically fetched and its items displayed on the web site).

Weird Hap'nins requirements will be the need to:

• Get external feed sources and allocate them to menu links on the web site

• Create the means to automatically fetch and display article items located in the feeds

• Display blocks of latest content from each feed source on the front page

Theme

The theme chosen is "Strange Little Town", which is a contributed theme that fits the description of this unique web site.

weird hap'nins jBSgi|®fe.ti THE ESgpF ÄAIlW6gi|§ÄÄ.:'

Forthe latest in bad n and spooky Stun do vfsitthis site' often.

' Despite Long Rap Sheet, Superior Court Judge Gives OutA Second Chant

> Calls to legalise drugs to halve crime • Ex-soldier's trial hits home

> Obasanfo Not Cleared^Says Crimes Commission

> Estate plagued by crime to be demolished forlbn rebirth

■ Do evil spirits still linger at St James's?

■ Heaven can wait a white h Spooky goings y There's always a bull market somewhere

■ Paranormal group unsure [fSeneca County courthouse gave up the ghost

■ Do evil spirits still linger at St James's?

■ Heaven can wait a white h Spooky goings y There's always a bull market somewhere

■ Paranormal group unsure [fSeneca County courthouse gave up the ghost

Build Weird Hap'nins

Vaughan Pyre is a very ambitious webpreneur. What he really hopes for is a web site that is completely self-maintaining, and on which he can place some Google AdSense blocks. Clicks from the visitors to his site will ensure that he makes lots of money. For this, he needs a site where the content updates regularly with fresh content so that visitors will keep coming back to click on some more Google ads. Vaughan's ultimate objective is to create several of these web sites.

Modules

This is, surprisingly, a very simple site to build, and much of the requirements can be achieved by using the Core Aggregator module. Indeed, were it not for the fact that Vaughan needs the content to automatically update, we needn't use any module other than the Aggregator module.

Optional Core modules

We will be using the following Core modules, which can be enabled via the Modules page:

• Aggregator—for aggregating syndicated content (RSS, RDF, and Atom feeds)

Contributed modules

We will also be using the following contributed modules from Drupal.org. Install, and enable them via the Modules page:

• Poormanscron—internal scheduler for users without a cron application

Configure the Poormanscron module

First we need to enable the Poormanscron module, so that the incoming feeds will be able to self-refresh. From the Administer page, we will access the Poormanscron configuration page, mainly to set the time interval between runs of cron to update feed items, as shown in the following screenshot:

Poormanscron

The settings provided here allow you to administer Poormancron.

—Time intervals-

Poormanscron

The settings provided here allow you to administer Poormancron.

—Time intervals-

Retry interval:

Retry interval:

Logging

Log successful cron runs:

ptoig

Log poormanscron progress:

If you want to log the progress of a poormanscron run to the Drupel watchdog, say Yes here. If those messages annoy

In this case, we have left the Time intervals at the default value of 60 minutes. -[ 211 ]-

Configure the Aggregator module

The Aggregator module should be configured to define the feed sources, how often they will be polled, and how they're categorized. For this, if we select the Feed aggregator link on the Administer page, then we should arrive at the following page:

Feed aggregator Add category Add feed Settings

Thousands of sites (particularly news sites and blogs) publish their latest headlines and posts in feeds, using a number of standardized XML-based formats. Formats supported by the aggregator include RSS, RDF, and Atom.

Current feeds are listed below, and new feeds may be added, For each feed or feed category, the latest items block may be enabled at the blocks administration page.

Feed overview

Title Items Last update Next update Operations

Category overview

Title Items Operations

On the Settings page, we will define some more requirements, as follows:

1. Allowed HTML tags—which are the tags that are embedded in the incoming feed that we want Drupal to accept. The allowed tags do not include image tags. So if any images are coming with the feed, then they will be excluded. However, we don't want this to happen, so we have added the image tag <img> to the list.

2. Items shown in sources and categories pages—we have defined this to be 20 items, but you may select another figure.

3. Discard items older than—we want the feed items to be completely refreshed every week so we have set this at 1 week.

4. Category selection type—we are not categorizing the feeds, so we will leave this setting as it is.

Basic content

The site is built around the Aggregator module, and no other Content type will need to be created. Vaughan has decided to initially use three feeds obtained from

www.newsfeedmaker.com, as follows:

• Bad News —http://www.newsfeedmaker.com/feed.php?code=ddb874f7

• Crime—http://www.newsfeedmaker.com/feed.php?code=3 3a5a4 6a

• Paranormal—http://www.newsfeedmaker.com/feed.php?code=936f006a

It is from these feeds that we will create the necessary content.

il Tips and traps

C I An excellent source for "mashup" feeds on any topic is

^ pipes.yahoo.com.

Add feeds

On the Add feeds page, which is under the Feed aggregator configuration page, we finally get to define our feeds, and how often we want them to be polled.

We want our Bad News feed to be polled every hour, so we have configured it this way. The same procedure is followed to create the feeds for Crime and Paranormal.

Display the feeds

It is necessary to first start the feeds so that you can be sure that they work. Therefore, if we go to the List tab on the Feed aggregator page and click on the update items link on the righthand side of each listed feed, then we will see that the site polls items from the feeds that we have configured.

Feed aggregator

Add category Add feed Settings

There is new syndicated content from Crime .

Thousands of sites (particularly news sites and blogs) publish their latest headlines and posts in feeds, using a number of standardized XML-based formats. Formats supported by the aggregator include RSS, RDF, and Atom.

Current feeds are listed below, and new feeds may be added. For each feed or feed category; the latest items block may be enabled at the blocks administration page.

Number of items polled after initial updating U uvui vieilii

Items

Click here to update feed

Last update

Next update

Operations

Items

Last update

Next update

Operations

Bad News

20 items

55 sec ago

59 mirt 5 sec left

edit

remove items

update items

Crime

20 items

0 sec ago

1 hour left

edit

remove items

update items

Paranormal

0 items

never

never

edit

remove items

update items

Category ovemew

Title

Items

Operations

Clicking on the Title of the feed on this page will show a page view of the resulting feed. For example, the Bad News page gives us the following view:

Bad NeWS Categorize Configure

Powered by Newsfeed Maker, a free service for creating customized RSS, JS, IFrame, HTML newsfeeds for g your website or blog.

URL: http://www.inboxrobot.com/news/bad-news?nfcode=ddbB74f7 Updated: 1 day 2 hours ago

Chris Brown pleads not guilty to Rihanna assault

... commit a crime "which would result in death and great bodily injury", the 19-year-old murmured ,,, her into a headlock. "I'm going to kill you," he allegedly told her. Brown later ...

Shock in Calderdale village over murder of newsagent's daughter

... of a popular newsagent in Ripponden. A murder inquiry is underway after 20-year-old Sabira Alam ... underway after 20-year-old Sabira Alam was discovered dead on Sunday at Buckstones Edge near Scammonden, ... suspicion of murder in connection with Sabira's death. She had been reported missing on Friday ...

Stars, newcomers come for 73rd Masters Golf

... only green jacket in his first Masters appearance, Zoeller, who took the first Masters sudden-death playoff over Tom Watson and Ed Sneed, will have his daughter Gretchen serving as ...

Gunman kills at least 2 in German court

... A gunman opened fire in a courthouse in Bavaria Tuesday, killing a woman and injuring several other people, German police said. The gunman then apparently ...

East Central's Dickerson sparks first-round sweep

... Saturday and moved to Meridian after Theodore Dickerson, 70, collapsed in the stands and died of cardiac arrest a short time later at Providence Hospital in Mobile. "I never...

Lorry crashes through level crossing

Tuesday, 10.30a, - MOTORISTS had to be diverted on Monday after a lorry went through the level crossing barriers on Wyberton's Chain Bridge Road. ...

Newsfeed blocks

Vaughan wants to have blocks containing the latest items from the incoming feeds placed on the front page to encourage visitors to read more and to visit more often. If we visit the Blocks page, then we will see that blocks for Bad News feed latest items, Crime feed latest items, and Paranormal feed latest items have been conveniently created by the Aggregator module. We may now assign these blocks to the Bottom Content region, and configure the blocks to only show on the front page.

Create the front page post

Vaughan needs only one post on the front page, and wants this to be placed at the top of the page, to describe the web site. This post will be created from the Page Content type. In order to do this, click on the Create content link on the lefthand side of the screen, and select the Page link. You will see a form similar to the one shown in the following screenshot:

| We Bring you the best of bad news always l> Menu settings

Split summary at cursor Body: ^-1-'

For the latest in bad news and spooky stuff do visit this site often.

C" Input format t> Revision information :> Comment settings :> Authoring information [> Publishing options

In this form, we enter the introductory text for the site. At the bottom of the page, in the Publishing option panel, we will promote it to the front page and make it Sticky at top of list. This is necessary just in case Vaughan decides to add new items to the front page, which may effectively displace the site description post that he always wants to be at the top.

Tips and traps

Remember to change the permissions to access news feeds on the Administer | User management | Permissions page.

Menus

Now let's tidy up our site by creating a menu system that is more intuitive. For simplicity, we will be putting all of our feeds page views menu under a new Feeds menu, to separate it from our user's menu.

In order to do this, go to the Menu link on the Administer page.

1. Click on the Add menu tab at the top of this page to access the page that will permit you to add the new menu (in our example the Feeds menu), as shown in the following screenshot:

2. After this, we need to create the menu items that link to each of the feeds pages. The URLs for the feeds that we have created are:

° Bad News —aggregator/sources/1

° Crime —aggregator/sources/2

° Paranormal —aggregator/sources/3

These URLs may be obtained from the display in the browser without the preceding string (http://.../?q=).

Return to the Menus link on the Administer page and select Feeds. At the top of the page that comes up, select the Add item tab. This will take us to a page (shown in the following screenshot) where we can define the items in our menu.

We will also see from the Blocks link on the Administer page that a new block has been created for Feeds, and we will assign this to the Right sidebar, which is where we want it.

Finishing up

We can now enable our new theme, Strange Little Town, on the Themes page, which will give us a new front page, as shown in the following screenshot:

weird hap'nins

Forthe latest in bad news and spooky stuff do visit this site often.

> Chris Brown pi e ads not guilty to Rihanna assault

> Shock in Calderdate village over murder of newsagent's daughter » Stars, newcomers come for 73rd Masters Golf i Gunman kills atleast2 in German court

Despite Long Rap Sheet, Superior Court Judge Gives Out ASecond Chance

Calls to legalise drugs to halve crime

Ex-soldier's trial hits home

Obasanfo Not Cleared, Says Crimes Commission

Estate plagued by crime to be demolished forlbn rebirth

• Do evil spirits still linger atSt James's? i Heaven can wait a whiFe i Spooky goings i There's always a bull market somewhere

> Paranormal group unsure if Seneca County courthouse gave up the ghost

Forthe latest in bad news and spooky stuff do visit this site often.

> Chris Brown pi e ads not guilty to Rihanna assault

> Shock in Calderdate village over murder of newsagent's daughter » Stars, newcomers come for 73rd Masters Golf i Gunman kills atleast2 in German court

Summary

In this chapter, you have learned how to:

• Build a basic site for publishing news feeds, using the Aggregator module

• Use the Poormanscron module to run regular site tasks

0 0

Post a comment