On 24 May 2009, at 18:45, Carlo de Falco wrote:
On 17 May 2009, at 22:40, Søren Hauberg wrote:
søn, 17 05 2009 kl. 22:34 +0200, skrev Carlo de Falco:
If we change
generate_package_html (..., ..., "octave-forge")
to produce one file for each package containing the text that is
meant
to go on that page,
then the server-side script would just need to read all files in a
given directory in alphabeticl order
and print their contents. I believe this should be fast enough.
Sounds reasonable. Do you need anything from me to work on this?
Søren
Søren,
Here is my first attempt at this, I am not happy about having to
specify a "section" (either "main", "extra", "language" or
"nonfree") separately from the options but I see no other way to
handle this...
For this to work you need to apply the changeset I sent today to
patch pkg.m.
Any comments?
c.
<get_html_options.m>
oops, wrong attachment, here is the patch.
c.
Index: inst/generate_package_html.m
===================================================================
--- inst/generate_package_html.m (revision 5861)
+++ inst/generate_package_html.m (working copy)
@@ -48,7 +48,8 @@
## @seealso{get_html_options}
## @end deftypefn
-function generate_package_html (name, outdir = "manual", options = struct ())
+function generate_package_html (name = [], outdir = "manual",
+ options = struct (), section = "extra")
## Check input
if (isempty (name))
list = pkg ("list");
@@ -56,15 +57,15 @@
generate_package_html (list {k}.name, outdir, options);
endfor
return;
- elseif (isstruct (name))
+ elseif ((isstruct (name)) && (isfield (name, "name")))
desc = name;
- packname = "";
+ packname = desc.name;
elseif (ischar (name))
packname = name;
pkg ("load", name);
desc = pkg ("describe", name){1};
else
- error (["generate_package_html: first input must either be the name of a
", \
+ error (["generate_package_html: first input must either be the name of a
", ...
"package, or a structure giving its description."]);
endif
@@ -177,4 +178,30 @@
fprintf (fid, "\n%s\n", footer);
fclose (fid);
+
+ #####################################################
+ ## Write short description for forge overview page ##
+ #####################################################
+
+ if (options.include_package_list_entry)
+
+ pkg_list_item_filename = get_pkg_list_item_filename (desc.name, outdir,
section);
+
+ text = strrep (options.package_list_entry, "%name", desc.name);
+ text = strrep (text, "%uppername", toupper(desc.name));
+ text = strrep (text, "%version", desc.version);
+ text = strrep (text, "%extension", "tar.gz");
+
+ fid = fopen (pkg_list_item_filename, "w");
+ if (fid)
+ fprintf (fid, text);
+ fclose (fid);
+ else
+ error (sprintf("generate_package_html: unable to open file %s.",
+ pkg_list_item_filename));
+ endif
+
+ endif
+
endfunction
+
Index: inst/get_html_options.m
===================================================================
--- inst/get_html_options.m (revision 5861)
+++ inst/get_html_options.m (working copy)
@@ -125,11 +125,27 @@
#options.overview_header = strrep (strrep (hh, "%date", date ()),
"%body_command", "");
options.manual_body_cmd = 'onload="javascript:fix_top_menu ();
javascript:manual_menu ();"';
+ ## Options for package list page
+ options.include_package_list_entry = true;
+ options.package_list_entry = ...
+"<div class=\"package\" id=\"%name\">\n\
+<table class=\"package\"><tr>\n\
+<td><b><a href=\"javascript:unfold('%name');\" class=\"package_head_link\">\n\
+<img src=\"show.png\" id=\"%name_im\" alt=\"show/hide\" style=\"padding-right:
0.5em; border: none;\"/> %uppername </a></b></td>\n\
+<td style=\"text-align: right;\">» <a href=\"./%name/index.html\"
class=\"package_link\">details</a> |\n\
+<a class=\"package_link\"
href=\"http://downloads.sourceforge.net/octave/%name-%version.%extension?download\">download</a></td>\n\
+</tr></table>\n\
+<p id=\"%name_detailed\" style=\"display: none;\"> %shortdescription </p>\n\
+</div>\n";
+
case "octave"
options.header = "__HEADER__(`%title')";
options.footer = "__OCTAVE_TRAILER__";
- options.title = "Function Reference: %name";
-
+ options.title = "Function Reference: %name";
+ ## Options for package list page
+ options.include_package_list_entry = false;
+ options.package_list_entry = "";
+
case "docbrowser"
## Basic HTML header
hh = "\
@@ -159,6 +175,10 @@
options.overview_header = strrep (hh, "%css", sprintf ("../%s", css));
options.overview_title = "Overview: %name";
+ ## Options for package list page
+ options.include_package_list_entry = false;
+ options.package_list_entry = "";
+
otherwise
error ("get_html_options: unknown project name: %s", project_name);
endswitch
Index: inst/private/get_pkg_list_item_filename.m
===================================================================
--- inst/private/get_pkg_list_item_filename.m (revision 0)
+++ inst/private/get_pkg_list_item_filename.m (revision 0)
@@ -0,0 +1,48 @@
+## Copyright (C) 2009 Carlo de Falco
+##
+## This program is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; see the file COPYING. If not, see
+## <http://www.gnu.org/licenses/>.
+
+## THIS FUNCTION SHOULD BE private
+
+function pkg_list_item_filename = get_pkg_list_item_filename (name, outdir,
section)
+
+ pldir = mk_package_list_dir (outdir, section);
+ pkg_list_item_filename = fullfile (pldir, name);
+
+endfunction
+
+function pldir = mk_package_list_dir (outdir, section)
+
+ descdir = fullfile (outdir, "short_package_descriptions");
+ pldir = fullfile (descdir, section);
+
+ if (!exist (descdir, "dir"))
+ succ = mkdir (descdir);
+ if (! succ)
+ error (sprintf("generate_package_html: unable to create directory %s.",
+ descdir));
+ endif
+ endif
+
+ if (!exist (pldir, "dir"))
+ succ = mkdir (pldir);
+ if (! succ)
+ error (sprintf("generate_package_html: unable to create directory %s.",
+ pldir));
+ endif
+ endif
+
+endfunction
+
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev