;;-*- mode:Scheme, coding:utf-8 -*-
;; Catalog file

(use file.util)

(define *app-catalog*
  '(
    ;; Applications
    ;;   (NAME ATTR VERSION SRC-SUFFIX E-DOC J-DOC)
    ("Gauche"         ("gauche/index.html" "gauche/index-j.html")
                       "0.9.15" ".tgz"
                      "An R7RS Scheme implementation aimed at a handy
                       script engine.  Quick startup, built-in system
                       interface, and native multilingual support
                       are some of the goals."
                      "スクリプトエンジンとしての使い勝手を追求した、
                       R7RS準拠のScheme処理系です。
                       起動が速いこと、システムへのアクセスが組み込まれていること、
                       最初から多国語対応を考慮していること、
                       リスト処理ライブラリとして他のC/C++プログラムから
                       簡単にリンク可能であること、
                       などを目標としています。")
    ("WiLiKi"         "wiliki/wiliki.cgi"
                      "0.6.2" ".tgz"
                      "A wiki engine written in Scheme."
                      "Schemeで書いたWikiエンジンです。")
    ("Chaton"         "chaton/"
                      #f #f
                      "A Comet-based Webchat system."
                      "CometベースのWebchatシステムです。")
    ("escm"           "vault/escm.html"
                      "1.1" ".tar.gz"
                      "A filter program which copies the input text to output,
                       with processing embedded Scheme expressions.
                       This program itself is independent from any Scheme
                       implementation; you can use your favorite one.
                       Useful to process text files with a bit of dynamic
                       parts.  This page itself is processed by escm
                       to embed information such as the update time of
                       libraries, and synchronize with Japanese version.
                       A complete new version of escm, named aescm,
                      is being developed by TAGA Yoshitaka
                       (<a href=\"http://sourceforge.net/projects/escm/\">
                       http://sourceforge.net/projects/escm/</a>)"
                       "テキストに埋め込まれたScheme式を展開しながらコピーする
                       フィルタプログラム。このプログラム自身は特定のScheme実装とは
                       独立しており、好きなSchemeと組み合わせて使えます。
                       ダイナミックな部分がちょっとだけ入っている
                       ようなテキストファイルを処理するのに便利。このページでも
                       ライブラリの更新日時等を生成したり、英語版と同期を取るのに
                       使っています。
                       なお、escmの後継であるaescmがTAGA Yoshitakaさんによって
                       開発されています
                       (<a href=\"http://sourceforge.net/projects/escm/\">
                       http://sourceforge.net/projects/escm/</a>)")
    ))

(define *lib-catalog*
  '(
    ;; Libraries
    ;;   (NAME ATTR VERSION SRC-SUFFIX E-DOC J-DOC)
    ("textutils"      "[STk]"   "0.3.3"   ".tar.gz"
                      "A random collection of string and text manipulating
                       routines.  Including: high-level regexp macros
                       like scsh's let-match; filter functions like
                       unix's tr, grep and awk; trimming and padding
                       functions; read/write CSV files, etc."
                      "テキストデータを扱うスクリプトを書くのに便利な関数を集めました。
                       scshのlet-matchに似たregexpマクロ、unixの
                       tr, grepやawkに類似のフィルタ機能、CSVファイルの読み書き、
                       文字列のトリミングやパディングを行う小さな関数群等です。")
    ("modutils"       "[STk]"   "0.0"   ".tar.gz"
                      "Implements <b><tt>use-module</tt></b> macro,
                       a convenient way to organize libraries using
                       modules.   This is just an initial version
                       and not tested well."
                      "ライブラリをモジュール単位で整理するためのマクロ。
                       まだちゃんとテストしてません。")
    ("hashutils"      "[STk]"   "0.1"   ".tar.gz"
                      "A small set of auxiliary functions dealing with
                       STk's hash tables.  Not tested well."
                      "STkのハッシュテーブルを扱う小さな関数群。日常のスクリプティングで
                       良く使うものを集めました。まだ完全にはテストしていません。")
    ("mail"           "[STk]"   "0.1.3" ".tar.gz"
                      "A small routine to send emails via SMTP."
                      "SMTP経由でメイルを送信する小さなルーチン。")
    ("serializer"     "[STk]"   "0.3.3" ".tar.gz"
                      "A generic object serializer using STklos."
                      "STklosを用いたジェネリックなシリアライザインタフェース。")
    ("dbm"            "[STk,C]" "0.2"   ".tar.gz"
                      "A unified interface to the DBM-like libraries.
                       Requires serializer module."
                      "DBM系ライブラリへの統一されたインタフェース。
                       要serializerモジュール")
    ("pserializer"    "[S]"     "0.2"   ".tar.gz"
                      "Simple and extensible portable serializer
                       implementation."
                      "単純でポータブルなシリアライザ。")
    ("uvector"        "[C]"     "0.2.2" ".tar.gz"
                      "Uniform (homogeneous) numeric vector types,
                       as specified in
                       <a href=\"http://srfi.schemers.org/srfi-4/\">SRFI-4</a>.
                       This version is an alpha release.
                      "
                      "<a href=\"http://srfi.schemers.org/srfi-4/\">SRFI-4</a>
                       で定義されているuniform (homogeneous) numeric vector typesの
                       ネイティブコード実装。次のSTkのリリースに統合して頂ける予定。")
    ("logical"        "[C]"     "0.2"   ".tar.gz"
                      "Logical (bitwise) operation compatibile with SLIB's
                       logical feature, but this one is witten in C."
                      "ビット論理演算。SLIBのlogicalモジュールとコンパチブルだが、
                       Cで書いたので速い。")
    ("cgitool"        "[STk]"   "2.1"   ".tar.gz"
                      "A collection of functions useful to write cgi sctipt,
                       such as decoding form parameters and cookies.
                       API has been changed from version 1.0.
                       This version doesn't depend on STklos, and may be
                       used on different Scheme system with minor modification.
                       (This module is available by courtesy of
                       Square USA Inc)."
                      "URLエンコードされたフォームのパラメータやクッキーをデコードする
                       等、CGIを書くのに便利な関数群。APIを1.0から少し変更して、
                       STklosを使わないようにしたので、他のSchemeにも移植可能かも。"
                      )
    )
  )

(define (package->name package) (car package))
(define (package->attr package) (cadr package))
(define (package->vers package) (caddr package))
(define (package->sufx package) (cadddr package))
(define (package->edoc package) (list-ref package 4))
(define (package->jdoc package) (list-ref package 5))

(define *now* (sys-time))

(define (path-exists? . components)
  (let ((path (apply string-append components)))
    (and (file-exists? path) path)))

(define (find-doc name language)
  (if (equal? name "Gauche")            ;special
      (if (eq? language 'japanese)
          (path-exists? "gauche/index-j.html")
          (path-exists? "gauche/index.html"))
      (if (eq? language 'japanese)
          (or (path-exists? "vault/" name "-j.html")
              (path-exists? "vault/" name "-j.txt")
              (path-exists? "vault/" name ".html")
              (path-exists? "vault/" name ".txt"))
          (or (path-exists? "vault/" name ".html")
              (path-exists? "vault/" name ".txt")))))

(define (find-src name version suffix)
  (or (path-exists? "vault/" name "-" version suffix)
      (path-exists? "vault/" name suffix)))

(define (last-updated-date path)
  (if (file-exists? path)
      (sys-strftime "%m/%d/%Y" (sys-localtime (file-mtime path)))
      #f))

(define (build-entry package language)
  (let* ((name    (package->name package))
         (docfile (find-doc name language))
         (srcfile (find-src name
                            (package->vers package)
                            (package->sufx package)))
         (mtime   (file-mtime srcfile))
         (new?    (< (- *now* mtime) (* 7 86400))))
    (format #t "<dt> <b>~a</b> ~a -\n" name (package->attr package))
    (when docfile (format #t "<a href=~s>Document</a>, " docfile))
    (format #t "<a href=~s>Source</a>\n" srcfile)
    ;; (format #t "&nbsp;&nbsp;&nbsp;Latest version ~a (~a)\n"
    ;;         (package->vers package)
    ;;         (sys-strftime "%m/%d/%Y" (sys-localtime mtime)))
    ;; (when new?
    ;;       (format #t "<img src=\"images/new.png\" alt=\"*New*\" width=40 height=18>\n"))
    (format #t "<dd><p>~a</p>\n"
            (if (eq? language 'english)
                (package->edoc package)
                (package->jdoc package)))
    (newline)))
