View source with formatted comments or as raw
    1/*  Part of ClioPatria
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (c)  2010-2011 University of Amsterdam
    7                             CWI, Asterdam
    8                             VU University Amsterdam
    9    All rights reserved.
   10
   11    Redistribution and use in source and binary forms, with or without
   12    modification, are permitted provided that the following conditions
   13    are met:
   14
   15    1. Redistributions of source code must retain the above copyright
   16       notice, this list of conditions and the following disclaimer.
   17
   18    2. Redistributions in binary form must reproduce the above copyright
   19       notice, this list of conditions and the following disclaimer in
   20       the documentation and/or other materials provided with the
   21       distribution.
   22
   23    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   24    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   25    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   26    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   27    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   28    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   29    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   30    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   31    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   33    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   34    POSSIBILITY OF SUCH DAMAGE.
   35*/
   36
   37:- module(cpa_version_help,
   38          [
   39          ]).   40:- use_module(library(http/html_write)).   41:- use_module(library(http/http_dispatch)).   42:- use_module(library(version)).   43:- use_module(library(occurs)).   44:- use_module(library(sgml)).   45:- use_module(library(lists)).   46:- use_module(components(basics)).   47
   48/** <module> Provide detailed version information
   49*/
   50
   51:- http_handler(root(help/versions), version_info, []).   52
   53%!  version_info(+Request)
   54%
   55%   HTTP handler that provides detailed   information  on the loaded
   56%   (and registered) GIT modules.
   57
   58version_info(_Request) :-
   59    reply_html_page(cliopatria(default),
   60                    [ title('Version details') ],
   61                    [ h4('GIT modules'),
   62                      \git_modules,
   63                      h4('Server implementation language'),
   64                      p(\prolog_version),
   65                      div(class(textbox), \about_git_versions)
   66                    ]).
   67
   68%!  git_modules//
   69%
   70%   Component that creates a table of registered GIT modules.
   71%
   72%   @see register_git_module/2
   73
   74git_modules -->
   75    { findall(C-V, git_module_property(C, version(V)), Pairs) },
   76    html(table(class(block),
   77               [ tr([ th('GIT module'), th('Version'), th('Directory') ]),
   78                 \git_modules(Pairs)
   79               ])).
   80
   81git_modules([]) --> [].
   82git_modules([H|T]) -->
   83    git_module(H),
   84    git_modules(T).
   85
   86git_module(Name-Version) -->
   87    { git_module_property(Name, directory(Dir)) -> true },
   88    html(tr([td(\home_link(Name)), td(Version), td(Dir)])).
   89
   90home_link(Component) -->
   91    { git_module_property(Component, home_url(Home)) },
   92    !,
   93    html(a(href(Home), Component)).
   94home_link(Component) -->
   95    html(Component).
   96
   97
   98%!  prolog_version//
   99%
  100%   Component that emits the current version of SWI-Prolog
  101
  102prolog_version -->
  103    { current_prolog_flag(version_data, swi(Major, Minor, Patch, _)),
  104      atomic_list_concat([Major, Minor, Patch], '.', Version)
  105    },
  106    html([ a(href('http://www.swi-prolog.org'), 'SWI-Prolog'), ' ',
  107           'version ', b(Version)
  108         ]),
  109    (   { current_prolog_flag(version_git, GitVersion),
  110          GitVersion \== Version
  111        }
  112    ->  html([' (GIT version ', b(GitVersion), ')'])
  113    ;   []
  114    ).
  115
  116%!  about_git_versions//
  117%
  118%   Component    that    emits    the    both      of    the    file
  119%   html('git-versions.html'), explaining the background  behind git
  120%   stamped versions.
  121
  122
  123about_git_versions -->
  124    insert_html_file(html('git-versions.html'))