NewsCloud Source Code Documentation
From Newscloud
We have only basic documentation right now on the source code. We hope to expand this over time - hopefully, you'll help us!
Because the NewsCloud source code evolved from CommonBits, CommonTunes, CommonFlix and CommonTimes (earlier media platform experiments), there is a moderate amount of legacy code in the system. We've tried to eliminate a lot of it and isolate other parts of it. If you follow this guide, you should be able to steer around most of it and focus on the current active code.
NewsCloud uses Apache mod_rewrite to direct page traffic. So you need to configure this properly in your .conf file. And, you need to have a .htaccess file in the root of your project.
Most traffic goes into /classes/request.php. Most of the active code in the system is in our functional objects in /classes/.
Some traffic is rooted into static directories via .htaccess. For example, scripts, stylesheets, images as well as Web services traffic.
Directory Structure
Image files are served out of two directories:
- images directory has static images
- image_files has image files that users have uploaded to the system when submitting stories and photos
The scripts directory holds all Javascript.
The styles directory holds all our CSS files. Common.css is used everywhere. Other files are specific to pages.
The cron directory holds files run by our server's cron job for scheduled tasks. Cron jobs require a proper API key be used when calling them, to prevent abuse.
The static directory holds files that can be called directly, primarily the node for our Web services API http://www.newscloud.com/static/api.
Class Files
The following files are in the /classes directory:
cache.class.php
This class handles construction of cached elements of the site, mainly the cover page top stories, latest stories, etc. By building these in batch, the performance of the cover page is improved. A cron job builds the cache database tables CacheCover, CacheEditor, etc. every five minutes.
cleanup.class.php
This class contains functions that clean up the database.
db.class.php
The database class used primarily in NewsCloud. It creates the connection to the Database and has functions that you should use when reading, writing or updating the database.
dbManage.class.php
We use this to add tables and add or modify columns in our database. The /static/DBupdates directory has a chronological directory of database changes. Each month we create a new file with the latest modifications.
email.class.php
This manages sending html email templates including the new user guides and the Week in Review, as well as administrator messages.
request.class.php
Most all page requests go through here via our .htaccess file. The request class loads the appropriate objects and calls the proper code based on the url page arguments.
user.class.php and userProfile.class.php
These classes have a number of functions related to managing user accounts, the User table and user profiles.
Cron Jobs
In /etc/cron.d, we maintain a CRON file for NewsCloud. It's in the source tree /cron/newscloud.cron as well. However, you must use a valid API key in the URL calling arguments e.g. http://www.newscloud.com/cron/hourlyCron.php?key=your-api-key-here. The api key you use must match the one in apiKey.inc.
BuildCovers.php
This builds the content of the Cover page every five minutes.
hourlyCron.php
- Sends out the Week in Review on weekends
- Sends out the Tips and Tricks Emails each hour
- Builds the SiteMaps for Google with the most frequent changes
- Pings blog tracking services for changes to our top feeds
dailyCron.php
- Rolls up statistics
- Builds other SiteMaps
- Pings blog tracking services for changes to secondary feeds
- Cleans up the Week in Review log and the API log
weeklyCron.php
- Builds other SiteMaps
monthlyCron.php
- Builds other SiteMaps
