Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

Ultimate Radiant CMS Script

This is a script that builds a Radiant CMS site with several third-party extensions I use a lot. This just saves me time from having to look up the setup commands each time. YMMV

I call this power_radiant and stick it in /usr/local/bin.

Update: this has been fixed to work with latest Radiant code (since svn path as changed and freeze:edge task no longer works). You will need Git to be installed on your machine for this to work.

#!/bin/sh
radiant --database sqlite3 $1
cd $1
echo "
production:
  adapter: sqlite3
  database: db/production.sqlite3
test:
  adapter: sqlite3
  database: db/test.sqlite3
development:
  production
" > config/database.yml
svn export http://svn.radiantcms.org/radiant/trunk/extensions/shards/ vendor/extensions/shards
svn export svn://zuurstof.openminds.be/home/kaizer/svn/rails_stuff/radiant_extensions/wym_editor_filter vendor/extensions/wym_editor_filter
svn export http://svn.seancribbs.com/svn/rails/plugins/extensions/page_attachments vendor/extensions/page_attachments
#rake radiant:freeze:edge # stopped working in latest gem
git clone git://github.com/seancribbs/radiant.git /tmp/radiant
cp -r /tmp/radiant/radiant vendor/radiant
rake production db:bootstrap
rake production db:migrate:extensions
rake production radiant:extensions:wym_editor_filter:install
rake production radiant:extensions:page_attachments:update


To run:
power_radiant my_site

PHP Flickr! personal photo album

This code uses your Flickr! account and creates the URLs to the pictures for display on your own personal website! The full documentation is available at http://www.strydominc.za.net/index.php?p=projectdetail&d=phpflickrphoto

<?php
/**********************************************************************************************
www.strydominc.za.net
Created by Jurgen Strydom, 19-08-2006, jurgen.strydom@gmail.com
Read the readme.txt
Version 1.01, 19-08-2006
**********************************************************************************************/
?>
<link href="pagefloat.css" rel="stylesheet" type="text/css">
<?php
//Stuff you should update for your script
$api_key = "6cacc91553b802874c6bbad658c9ce94"; // get yours at http://flickr.com/services/api/key.gne
$my_id = "46772344@N00"; // use idgetr: http://idgettr.com/ to find yours if you already changed it to a name
$rows = 10;
//Let the code do the walking from here on
$photos = ($rows * 2);
if (empty($_REQUEST['n'])) {
$pagenum = 1;
} else {
$pagenum = $_REQUEST['n'];
}
//http://static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg //how the url is created for the images
$xml = simplexml_load_file("http://flickr.com/services/rest/?method=flickr.people.getPublicPhotos&user_id=$my_id&api_key=$api_key&per_page=$photos&page=$pagenum");
$total = $xml->photos['total'];
$pages = $total % $photos;
$pages = ($total + $photos - $pages) / $photos;

?><table width="700" border="0" cellpadding="0" cellspacing="0">
<tr><td height="10" colspan="2" valign="top" align="left">Please select a page: <?php
for ($k = 1; $k<=$pages; $k++) { ?>
<table width="25" border="0" cellpadding="0" cellspacing="0" align="center" class="pagefloat"> <?php
?>
  <tr>
    <td width="25" height="10" valign="top" align="center"><a href="photos.php?n=<?php echo $k?>">
	<?php if ($k == $pagenum) {
		 	echo "<u><b>", $k, "</b></u>";
		 } else {
		 	echo "<b>", $k, "</b>";
		 } ?></a></td>
  </tr>
</table>
<?php } 
?>
</td></tr>
<tr>
    <td height="10" colspan="2" valign="top" align="left">&nbsp;</td>
</tr>
<?php

if (($pagenum * $photos) > $total) {
	$to = $total % $photos;
} else { $to = $photos; }
for ($k = 0; $k<$to; $k++) {
if (($k % 2) == 0) {
?>
<tr>
<td width="350" height="100" valign="top" align="center">
<?php } else {?>
<td width="350" valign="top" align="center">
<?php }
echo "<b>" , $xml->photos->photo[$k]['title'], "</b>";
?>
<br>
<a href="http://www.flickr.com/photos/jurgenstrydom/<?php echo $xml->photos->photo[$k]['id'];?>"><img src="<?php 
echo "http://static.flickr.com/";
echo $xml->photos->photo[$k]['server'];
echo "/";
echo $xml->photos->photo[$k]['id'];
echo "_";
echo $xml->photos->photo[$k]['secret'];
echo "_m.jpg"; 
?>"
alt="<?php echo $xml->photos->photo[$k]['title'] ?>" border="0"></a>
</td>
<?php
if (($k % 2) == 1) {
?> </tr>  <tr>
    <td height="10" colspan="2" valign="top" align="left">&nbsp;</td>
  </tr>  
  <?php
}
}
?>
</table>
<?php
/**********************************************************************************************
Changelog:

Version 1.01
Fixed a bug that caused code below this script to output incorrect display.

Version 1
First release.
**********************************************************************************************/
?>

PHP last.fm chart creator

This code displays the Top 50 artists XML feed from last.fm in a nice presentable way on your website. Can easily be modified to work with any other feed from last.fm, find the full guide at http://www.strydominc.za.net/index.php?p=projectdetail&d=phplastfmchart

<?php
/**********************************************************************************************
www.strydominc.za.net
Created by Jurgen Strydom, 19-08-2006, jurgen.strydom@gmail.com
Read the readme.txt
Version 1.01, 05-09-2006
**********************************************************************************************/
?>
<link href="lastfmbar.css" rel="stylesheet" type="text/css">
<div>
<?php
//User settings -> needs your attention
$user = "Alkine"; //Your username
$width = 700; //width of the list

//Code you should not worry about
$file = "http://ws.audioscrobbler.com/1.0/user/$user/topartists.xml";
$xml = simplexml_load_file("$file");
$big = $xml->artist[0]->playcount;
$total = count($xml->artist);
$factor =  $width /$big;
?>
<table width="<?php echo $width ?>" border="0" cellpadding="0" cellspacing="0">  
 <?php
 for ($k=0 ; $k<=$total - 1; $k++) {
 	$barlen = round(($xml->artist[$k]->playcount * $factor), 0);
 ?>
  <tr>
    <td width="<?php echo $width ?>" height="10" valign="center"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="<?php echo $barlen ?>" height="10" valign="center" class="lastfmbar"><?php 
		if ($barlen >= (($width + 100) /2)) {
			echo "<div align=\"right\">", $xml->artist[$k]->playcount, " - <b>", $xml->artist[$k]->name ,"</b></div>";
		}
		if (($barlen < (($width + 100) /2)) && ($barlen >= ($width / 3))) {
			echo "<div align=\"right\">", $xml->artist[$k]->playcount ," -</div>";
		}
		if ($barlen < ($width / 3)) {
			echo "&nbsp;";
		}		
		?></td>
        <td width="<?php echo $width - $barlen ?>" valign="center"><?php 
		if ($barlen >= (($width + 100) /2)) {
			echo "&nbsp;";
		}
		if (($barlen < (($width + 100) /2)) && ($barlen >= ($width / 3))) {
			echo "<div align=\"left\"><b>&nbsp;", $xml->artist[$k]->name ,"</b></div>";
		}
		if ($barlen < ($width / 3)) {
			echo "<div align=\"left\">", $xml->artist[$k]->playcount, " - <b>", $xml->artist[$k]->name ,"</b></div>";
		}		
		?></td>
      </tr>
    </table></td>
  </tr>
  <?php
  }
  ?>
</table>
</div>
<?php
/**********************************************************************************************
Changelog:

Version 1.01
Fixed a bug that caused the bar sizes to display incorrectly.

Version 1
First release.
**********************************************************************************************/
?>
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS