[MINOR: moved license handling to a new 'Licenses' module.
argot@x9c.fr**20111030065355
Ignore-this: 74c22921b72ca1943aca19b45c74dfac
] addfile ./src/licenses.ml
hunk ./src/licenses.ml 1
+(*
+ * This file is part of Argot.
+ * Copyright (C) 2010-2011 Xavier Clerc.
+ *
+ * Argot 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.
+ *
+ * Argot 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. If not, see .
+ *)
+
+let predefined = [
+ ["gpl"; "gpl1"; "gplv1"],
+ "http://www.gnu.org/licenses/old-licenses/gpl-1.0.html";
+ ["gpl2"; "gplv2"],
+ "http://www.gnu.org/licenses/old-licenses/gpl-2.0.html";
+ ["gpl3"; "gplv3"],
+ "http://www.gnu.org/licenses/gpl.html";
+ ["lgpl"; "lgplv2"],
+ "http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html";
+ ["lgpl21"; "lgpl2.1"; "lgpl2_1"; "lgplv21"; "lgplv2.1"; "lgplv2_1"],
+ "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html";
+ ["lgpl3"; "lgplv3"],
+ "http://www.gnu.org/licenses/lgpl.html";
+ ["agpl"],
+ "http://www.gnu.org/licenses/agpl.html";
+ ["bsd"],
+ "http://www.freebsd.org/copyright/license.html";
+ ["mit"],
+ "http://www.opensource.org/licenses/mit-license.php";
+ ["apache"],
+ "http://www.apache.org/licenses/";
+ ["qpl"],
+ "http://doc.trolltech.com/3.0/license.html";
+ ["cecill"; "cecill-a"],
+ "http://www.cecill.info/licences/Licence_CeCILL_V2-en.html";
+ ["cecill-b"],
+ "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html";
+ ["cecill-c"],
+ "http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html"
+]
+
+let table =
+ let res = Hashtbl.create 17 in
+ List.iter
+ (fun (names, addr) ->
+ List.iter
+ (fun name ->
+ Hashtbl.add res name addr)
+ names)
+ predefined;
+ res
+
+let to_html name =
+ let enclose addr =
+ Printf.sprintf "%s" addr name in
+ try
+ enclose (Hashtbl.find table (String.lowercase name))
+ with Not_found -> name
addfile ./src/licenses.mli
hunk ./src/licenses.mli 1
+(*
+ * This file is part of Argot.
+ * Copyright (C) 2010-2011 Xavier Clerc.
+ *
+ * Argot 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.
+ *
+ * Argot 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. If not, see .
+ *)
+
+(** Support for 'licence' tag. *)
+
+val predefined : (string list * string) list
+(** Predefined licenses as an association list from names (with possible
+ synonyms) to URLs. *)
+
+val to_html : string -> string
+(** [to_html name] return the HTML portion related to the license whose
+ name is passed. *)
hunk ./src/main.ml 25
-let licenses = [
- ["gpl"; "gpl1"; "gplv1"],
- "http://www.gnu.org/licenses/old-licenses/gpl-1.0.html";
- ["gpl2"; "gplv2"],
- "http://www.gnu.org/licenses/old-licenses/gpl-2.0.html";
- ["gpl3"; "gplv3"],
- "http://www.gnu.org/licenses/gpl.html";
- ["lgpl"; "lgplv2"],
- "http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html";
- ["lgpl21"; "lgpl2.1"; "lgpl2_1"; "lgplv21"; "lgplv2.1"; "lgplv2_1"],
- "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html";
- ["lgpl3"; "lgplv3"],
- "http://www.gnu.org/licenses/lgpl.html";
- ["agpl"],
- "http://www.gnu.org/licenses/agpl.html";
- ["bsd"],
- "http://www.freebsd.org/copyright/license.html";
- ["mit"],
- "http://www.opensource.org/licenses/mit-license.php";
- ["apache"],
- "http://www.apache.org/licenses/";
- ["qpl"],
- "http://doc.trolltech.com/3.0/license.html";
- ["cecill"; "cecill-a"],
- "http://www.cecill.info/licences/Licence_CeCILL_V2-en.html";
- ["cecill-b"],
- "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html";
- ["cecill-c"],
- "http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html"
-]
-
-let licenses : (string, string) Hashtbl.t =
- let res = Hashtbl.create 17 in
- List.iter
- (fun (names, addr) ->
- List.iter
- (fun name ->
- Hashtbl.add res name addr)
- names)
- licenses;
- res
-
hunk ./src/main.ml 205
- self#register_text_tag
- ~prefix:"License: "
- ~modifier:(fun text ->
- let enclose addr =
- Printf.sprintf "%s" addr text in
- try
- enclose (Hashtbl.find licenses (String.lowercase text))
- with Not_found -> text)
- "license";
+ self#register_text_tag ~prefix:"License: " ~modifier:Licenses.to_html "license";