View source with raw comments or as raw
    1/*  Part of ClioPatria SeRQL and SPARQL server
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@cs.vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (C): 2010, University of Amsterdam,
    7		   VU University Amsterdam
    8
    9    This program is free software; you can redistribute it and/or
   10    modify it under the terms of the GNU General Public License
   11    as published by the Free Software Foundation; either version 2
   12    of the License, or (at your option) any later version.
   13
   14    This program is distributed in the hope that it will be useful,
   15    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17    GNU General Public License for more details.
   18
   19    You should have received a copy of the GNU General Public
   20    License along with this library; if not, write to the Free Software
   21    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22
   23    As a special exception, if you link this library with other files,
   24    compiled with a Free Software compiler, to produce an executable, this
   25    library does not by itself cause the resulting executable to be covered
   26    by the GNU General Public License. This exception does not however
   27    invalidate any other reasons why the executable file might be covered by
   28    the GNU General Public License.
   29*/
   30
   31:- module(user_preferences,
   32	  [ user_preference/2		% ?Preference, ?Value
   33	  ]).   34:- use_module(library(semweb/rdf_db)).   35:- use_module(cliopatria(hooks)).   36
   37:- rdf_register_ns(user, 'http://www.swi-prolog.org/cliopatria/user/').

User preference handling

This module defines access to user-preferences. The API for the preference system is based on RDF. This allows for using the RDF-store for storing preferences, typically using the OpenID URI as subject. The actual storage infrastructure must be implemented using hooks in the cliopatria module: cliopatria:user_preference_db/2 and cliopatria:user_preference_default/2.

Preferences are defines in the RDF namespace with prefix user, which expands to:

http://www.swi-prolog.org/cliopatria/user/

*/

   56:- rdf_meta
   57	user_preference(r,o),
   58	builtin_default(r,o).
 user_preference(?Preference:resource, ?Value:object) is nondet
True if Preference has Value. Preference and Value use the RDF data-representation. E.g.,
?- user_preference(user:lang, literal(Lang))

Lang = en
See also
- cliopatria:user_preference_db/2 provides the storage hook
- cliopatria:user_preference_default/2 provides a hook for defaults
- builtin_default/2 provides built-in defaults
   76user_preference(Pref, Value) :-
   77	nonvar(Pref), !,
   78	(   cliopatria:user_preference_db(Pref, Value)
   79	*-> true
   80	;   cliopatria:user_preference_default(Pref, Value)
   81	*-> true
   82	;   builtin_default(Pref, Value)
   83	).
   84user_preference(Pref, Value) :-
   85	current_preference(Pref),
   86	user_preference(Pref, Value).
   87
   88current_preference(Pref) :-
   89	setof(P, current_pref(P), Prefs),
   90	member(Pref, Prefs).
   91
   92current_pref(P) :- cliopatria:user_preference_db(P, _).
   93current_pref(P) :- cliopatria:user_preference_default(P, _).
   94current_pref(P) :- builtin_default(P, _).
 builtin_default(?Preference, ?Value) is nondet
Provide defaults for commonly used preferences.
  100builtin_default(user:lang, literal(en))