We have clarified our Privacy Statement. Please have a look at our changes.
Browse Source

+ adding download links for .tar.gz, .deb and .rpm of displayed package

git-svn-id: svn+ssh://svn.izzysoft.de/public/histview/trunk@24 2e17d4db-7539-0410-9bcc-c6eb479cd550
tags/v0.1.9
Izzy 12 years ago
parent
commit
df6116034c
6 changed files with 143 additions and 32 deletions
  1. +28
    -23
      histview.hist
  2. +103
    -8
      histview.inc
  3. +12
    -1
      histview.php
  4. BIN
      icons/deb.png
  5. BIN
      icons/rpm.png
  6. BIN
      icons/tgz.png

+ 28
- 23
histview.hist View File

@@ -3,21 +3,26 @@ $Id$
History for HistView
====================

v0.0.1 (initial version)
------------------------
* reads in the history file and outputs a table. Everything plain text.
v0.1.3
-------------------
+ automatically add download links for *.tar.gz, *.deb and *.rpm if files
exist for a given version in the configured directories

v0.0.2 (10.12.2003)
v0.1.2 (24.01.2004)
-------------------
* replaced marks by icons (picked from the Apache distributed in /icons/)
* some cosmetical changes
! pline() sometimes broke with an error message
+ added method add_mark(): now you can add your own (user-defined) marks
+ updated api reference

v0.0.3 (12.12.2003)
v0.1.1 (05.01.2004)
-------------------
+ added method process() - now the input is not processed from the
constructor but on demand, allowing changes of settings (see below)
+ added method set_icon() - now default icon definition can be overridden
and thus default icons can be replaced
! fixed version number in copyright info
+ added download link
! line was omitted when starting with a version mark but not continuing
with a (numeric) version number (e.g. starting with "verbose")
+ date of last modification for the processed history file is now displayed
in the first line of the output
+ added stylesheet file

v0.1.0 (15.12.2003)
-------------------
@@ -27,18 +32,18 @@ v0.1.0 (15.12.2003)
+ added copyright info to output
+ first release

v0.1.1 (05.01.2004)
v0.0.3 (12.12.2003)
-------------------
! fixed version number in copyright info
+ added download link
! line was omitted when starting with a version mark but not continuing
with a (numeric) version number (e.g. starting with "verbose")
+ date of last modification for the processed history file is now displayed
in the first line of the output
+ added stylesheet file
+ added method process() - now the input is not processed from the
constructor but on demand, allowing changes of settings (see below)
+ added method set_icon() - now default icon definition can be overridden
and thus default icons can be replaced

v0.1.2 (24.01.2004)
v0.0.2 (10.12.2003)
-------------------
! pline() sometimes broke with an error message
+ added method add_mark(): now you can add your own (user-defined) marks
+ updated api reference
* replaced marks by icons (picked from the Apache distributed in /icons/)
* some cosmetical changes

v0.0.1 (initial version)
------------------------
* reads in the history file and outputs a table. Everything plain text.

+ 103
- 8
histview.inc View File

@@ -1,6 +1,6 @@
<?
#############################################################################
# HistView (c) 2003 by Itzchak Rehberg #
# HistView (c) 2003-2007 by Itzchak Rehberg #
# written by Itzchak Rehberg <devel@izzysoft.de> #
# http://www.izzysoft.de/ #
# ------------------------------------------------------------------------- #
@@ -15,10 +15,10 @@
/** Processing a history file and prepare it for HTML output
* @class histview
* @author Izzy (devel@izzysoft.de)
* @copyright (c) 2003 by Itzchak Rehberg and IzzySoft
* @copyright (c) 2003-2007 by Itzchak Rehberg and IzzySoft
*/
class histview {
var $hv_version = "0.1.2";
var $hv_version = "0.1.3";
var $download= "http://www.izzysoft.de/ftp/net/div/izzysoft/hv.php";
var $plus = "+";
var $minus = "-";
@@ -30,6 +30,16 @@ class histview {
var $iminus = "<IMG SRC='/icons/transfer.gif' BORDER='0'>";
var $ichange = "<IMG SRC='/icons/image1.gif' BORDER='0'>";
var $ibug = "<IMG SRC='/icons/alert.red.gif' BORDER='0'>";
var $itar = "<IMG SRC='/icons/box2.gif' BORDER='0'>";
var $ideb = "<IMG SRC='/icons/box2.gif' BORDER='0'>";
var $irpm = "<IMG SRC='/icons/box2.gif' BORDER='0'>";
var $tarbase = "";
var $debbase = "";
var $rpmbase = "";
var $basedir = "";
var $relname = "";
var $max_relnum = 9;
var $arch = "noarch";
var $umark; # user defined marks
var $umarks; # user defined marks

@@ -43,13 +53,15 @@ class histview {
/** Create an instance and read the input file into the internal array
* @constructor histv
* @param string infile input file name
* @param optional basename basename for files (e.g. "histview" for histview-0.1.3-izzy1.noarch.rpm)
*/
function histview($infile) {
function histview($infile,$name="") {
if (!empty($name)) $this->basename = $name;
$this->lastchange = "Last modified: ".date("F d Y",filemtime($infile));
$this->input = file($infile);
$this->idx->ver = 0;
$this->idx->mark = 0;
$this->copy = "2003-2004 by <A HREF='http://www.qumran.org/homes/izzy/' TARGET='_blank'>"
$this->copy = "2003-2007 by <A HREF='http://www.qumran.org/homes/izzy/' TARGET='_blank'>"
. "Itzchak Rehberg</A> &amp; <A HREF='http://www.izzysoft.de/' "
. "TARGET='_blank'>IzzySoft</A>";
}
@@ -74,15 +86,58 @@ class histview {
* @param optional string minus Removed stuff Icon
* @param optional string change Changed stuff Icon
* @param optional string bug BugFix Icon
* @param optional string tar Tarball Icon
* @param optional string deb Debian Icon
* @param optional string rpm RPM Icon
* @return boolean success
*/
function set_icon($iplus="",$iminus="",$ichange="",$ibug="") {
$details = array("iplus","iminus","ichange","ibug");
function set_icon($iplus="",$iminus="",$ichange="",$ibug="",$itar="",$ideb="",$irpm="") {
$details = array("iplus","iminus","ichange","ibug","itar","ideb","irpm");
foreach ($details as $var) {
if ($$var!="") $this->$var = $$var;
}
}

/** Override base URLs for archives. With $type='base' set the string to cut
* of to leave the download URL. Example: Your files are somewhere below
* /var/www/files/download, and your servers document root is /var/www, so
* you would specify "/var/www" here. If your files reside outside the
* servers document root, say below /var/ftp/download, you should create a
* directory alias called "/ftp/" pointing to /var/ftp, and specify "/var"
* here.
* @method set_basedir
* @param string type tar, deb, rpm or base
* @param string dir the directory for this type
*/
function set_basedir($type,$dir) {
switch ($type) {
case "tar" : $this->tarbase = $dir; break;
case "deb" : $this->debbase = $dir; break;
case "rpm" : $this->rpmbase = $dir; break;
case "base" : $this->basedir = $dir; break;
}
}

/** Set the release extension for *.deb/*.rpm
* For the fictive package dummy-0.1.2-johnny3.noarch.rpm this would be "johnny"
* @method set_relname
* @param string relname
*/
function set_relname($relname) {
$this->relname = $relname;
}

/** Set the maximum release number
* To take our example from set_basedir again (dummy-0.1.2-johnny3.noarch.rpm),
* the relnum of that package is "3" (the number immediately following the
* release extension). To find the latest package, histview would "replace"
* this part by $i, counting down from max_relnum to 0 until it finds a file.
* @method set_max_relnum
* @parameter integer relnum
*/
function set_max_relnum($num) {
}

/** Override default identifier mark settings
* Identifier marks are the characters used to identify the changes, such
* as a "+" for a new feature or a "!" for a bug
@@ -174,6 +229,39 @@ class histview {
}
}

/** Check whether there is a file to download - and create URL if any
* @method getdlurl
* @param string type Type (one of tar, deb, rpm)
* @return string href complete href string if found, empty string else
*/
function getdlurl($type,$fname,$version) {
$img = array("tar"=>$this->itar,"deb"=>$this->ideb,"rpm"=>$this->irpm);
$pos = strpos($version,"(");
switch ($type) {
case "tar" : $f = trim($this->tarbase."/${fname}-".substr($version,1,$pos-2)).".tar.gz"; break;
case "deb" : for ($i=$this->max_relnum;$i>=0;--$i) {
$f = trim($this->debbase."/${fname}_".substr($version,1,$pos-2))."-".$this->relname.$i."_";
if ($this->arch=="noarch") $f .= "all.deb";
else $f .= $this->arch.".deb";
if (file_exists($f)) break;
}
break;
case "rpm" : for ($i=$this->max_relnum;$i>=0;--$i) {
$f = trim($this->rpmbase."/${fname}-".substr($version,1,$pos-2))."-".$this->relname.$i.".".$this->arch.".rpm";
if (file_exists($f)) break;
}
break;
}
if (file_exists($f)) {
$f = substr($f,strlen($this->basedir));
$f = "<A HREF='$f'>";
if (!empty($img[$type])) $f .= $img[$type]; else $f .= $type;
$f .= "</A>";
return $f;
}
return "";
}

/** Generate the output array
* @class histview
* @method out
@@ -185,7 +273,14 @@ class histview {
. "<TABLE WIDTH='95%' BORDER='0' ALIGN='center'>\n";
$vers = count($this->version);
for ($i=1;$i<=$vers;++$i) {
$output .= " <TR><TH COLSPAN='2'>".$this->version[$i]->num."</TH></TR>\n";;
if (!empty($this->tarbase)) $tarfile = $this->getdlurl("tar",$this->basename,$this->version[$i]->num);
if (!empty($this->debbase)) $debfile = $this->getdlurl("deb",$this->basename,$this->version[$i]->num);
if (!empty($this->rpmbase)) $rpmfile = $this->getdlurl("rpm",$this->basename,$this->version[$i]->num);
$dllink = "${tarfile}${debfile}${rpmfile}";
if (!empty($dllink)) {
$dllink = "<SPAN ALIGN='right'>$dllink</SPAN>";
$output .= " <TR><TH COLSPAN='2'><TABLE WIDTH='100%' BORDER='0'><TR><TH>".$this->version[$i]->num."</TH><TH WIDTH='66px'>$dllink</TH></TR></TABLE></TH></TR>\n";;
} else $output .= " <TR><TH COLSPAN='2'>".$this->version[$i]->num."</TH></TR>\n";;
$chgs = count($this->version[$i]->changes);
for ($k=1;$k<=$chgs;++$k) {
$output .= " <TR><TD VALIGN='middle'>".$this->version[$i]->changes[$k]->mark."</TD>\n"

+ 12
- 1
histview.php View File

@@ -1,6 +1,6 @@
<?
#############################################################################
# HistView Client (c) 2003 by Itzchak Rehberg #
# HistView Client (c) 2003-2007 by Itzchak Rehberg #
# written by Itzchak Rehberg <devel@izzysoft.de> #
# http://www.izzysoft.de/ #
# ------------------------------------------------------------------------- #
@@ -14,11 +14,22 @@

/* $Id$ */
$prog = $_REQUEST["prog"];
if (empty($prog)) $prog = "HistView";
include("histview.inc");
$file = strtolower($prog).".hist";
# Simple method, no download links to provide:
$hv = new histview($file);
# Providing download links:
#$hv = new histview($file,strtolower($prog));
#$hv->set_icon("","","","","<IMG SRC='icons/tgz.png' BORDER='0'>","<IMG SRC='icons/deb.png' BORDER='0'>","<IMG SRC='icons/rpm.png' BORDER='0'>");
#$hv->set_basedir("base","/var");
#$hv->set_basedir("tar","/var/ftp/downloads");
#$hv->set_basedir("deb","/var/repo/debian");
#$hv->set_basedir("rpm","/var/repo/redhat/RPMS.dist");
#$hv->set_relname("johnny");

$hv->process();
$history = $hv->out();
$title = "History for $prog";

BIN
icons/deb.png View File

Before After
Width: 22  |  Height: 22  |  Size: 1.1KB

BIN
icons/rpm.png View File

Before After
Width: 22  |  Height: 22  |  Size: 1.1KB

BIN
icons/tgz.png View File

Before After
Width: 22  |  Height: 22  |  Size: 1.3KB

Loading…
Cancel
Save