swish/commit
WIP connecting chat-enabled SWISH
author | Jan Wielemaker |
---|---|
Sun May 14 13:05:52 2017 +0200 | |
committer | Jan Wielemaker |
Tue May 23 12:00:43 2017 +0200 | |
commit | df00901d80227f7c54237fe555b7804b4f0e9140 |
tree | 861b9c3deb25437b7ecde8134c1df5f7ccdb8adf |
parent | b87b853f16811240f5bf1e2402d24afb3374b3c4 |
Diff style: patch stat
diff --git a/Makefile b/Makefile index 5179db3..5d1cff8 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,37 @@ # Create a ClioPatria SWISH package from the SWISH distribution. FONTDIR=web/bower_components/bootstrap/dist/fonts -DIRS=lib/swish lib/swish/render web/icons web/help client $(FONTDIR) \ +PACKDIR=lib/swish/pack +PACKS=profile +DIRS=lib/swish lib/swish/render lib/swish/plugin $(PACKDIR) \ + web/icons web/help client $(FONTDIR) \ web/bower_components/codemirror/mode/htmlmixed \ web/bower_components/codemirror/mode/css \ - web/bower_components/codemirror/mode/javascript + web/bower_components/codemirror/mode/javascript \ + $(addprefix $(PACKDIR)/, $(addsuffix /prolog, $(PACKS))) \ + $(PACKDIR)/profile/prolog/profile/backend SWISHLIB=storage.pl page.pl help.pl examples.pl config.pl gitty.pl \ highlight.pl render.pl template_hint.pl search.pl form.pl \ include.pl swish_csv.pl logging.pl trace.pl markdown.pl \ gitty_driver_files.pl gitty_driver_bdb.pl gitty_tools.pl \ swish_debug.pl profiles.pl procps.pl download.pl r_swish.pl \ - patch.pl rgb.txt + patch.pl chat.pl authenticate.pl pep.pl avatar.pl \ + noble_avatar.pl chatstore.pl paths.pl messages.pl \ + rgb.txt RENDER=table.pl graphviz.pl c3.pl codes.pl swish.pl chess.pl sudoku.pl svgtree.pl +PLUGIN=email.pl +PACKFILES0=profile/pack.pl profile/prolog/user_profile.pl \ + profile/prolog/profile/backend/profile_prolog.pl +PACKFILES=$(addprefix $(PACKDIR)/, $(PACKFILES0)) LIBS= $(addprefix lib/swish/, $(SWISHLIB)) \ - $(addprefix lib/swish/render/, $(RENDER)) + $(addprefix lib/swish/render/, $(RENDER)) \ + $(addprefix lib/swish/plugin/, $(PLUGIN)) JS=web/js/swish-min.js web/js/swish-min.js.gz web/js/require.js CSS=web/css/swish-min.css web/css/swish-min.css.gz ICON_FILES=owl_25_years.png running.gif page-fold-20.png \ COMMIT_logo.png Synerscope-logo.png VU-logo.png \ vre4eic-logo.png cwi-logo.png \ - pl.png swinb.png + pl.png swinb.png noble ICONS=$(addprefix web/icons/, $(ICON_FILES)) HELP=$(addprefix web/help/, $(notdir $(wildcard src/web/help/*.html))) FONTFILES=glyphicons-halflings-regular.ttf \ @@ -41,7 +53,7 @@ CMFILES=mode/htmlmixed/htmlmixed.js \ CM=$(addprefix web/bower_components/codemirror/, $(CMFILES)) all: $(DIRS) $(LIBS) $(JS) $(CSS) $(ICONS) $(HELP) $(FONTS) $(CLIENTS) \ - $(CM) $(EXAMPLES) + $(CM) $(EXAMPLES) $(PACKFILES) $(DIRS): mkdir -p $@ @@ -64,6 +76,9 @@ web/js/require.js: src/web/bower_components/requirejs/require.js web/css/%: src/web/css/% rsync -u $< $@ +web/icons/noble: src/web/icons/noble + rsync -ua $</ $@ + web/icons/%: src/web/icons/% rsync -u $< $@ @@ -76,6 +91,9 @@ examples/%: src/examples/% $(FONTDIR)/%: src/$(FONTDIR)/% rsync -u $< $@ +$(PACKDIR)/%: src/pack/% + rsync -u $< $@ + web/bower_components/codemirror/%: src/web/bower_components/codemirror/% rsync -u $< $@ diff --git a/applications/swish.pl b/applications/swish.pl index 79d9174..a4b6171 100644 --- a/applications/swish.pl +++ b/applications/swish.pl @@ -37,6 +37,26 @@ :- use_module(library(http/http_json)). :- use_module(rdfql(sparql_csv_result)). + /******************************* + * PATHS * + *******************************/ + +:- multifile + http:location/3, + user:file_search_path/2. + +http:location(swish, root(swish), []). + +user:file_search_path(render, library(swish/render)). +user:file_search_path(swish_pack, library(swish/pack)). + + + /******************************* + * MODULES * + *******************************/ + +:- use_module(library(swish/messages)). +:- use_module(library(swish/paths)). :- use_module(library(swish/config)). :- use_module(library(swish/page), []). :- use_module(library(swish/storage)). @@ -49,15 +69,7 @@ :- use_module(library(swish/markdown)). :- use_module(library(swish/render)). :- use_module(library(swish/template_hint)). - - - /******************************* - * PATHS * - *******************************/ - -http:location(swish, root(swish), []). - -user:file_search_path(render, library(swish/render)). +:- use_module(library(swish/chat), []). /******************************* @@ -95,8 +107,12 @@ user:file_search_path(render, library(swish/render)). % - ping % Ping pengine status every N seconds. Updates sparkline % chart with stack usage. -% - nb_eval_script -% Evaluate scripts in HTML cells of notebooks? +% - notebook +% Dict holding options for notebooks. +% - nb_eval_script +% Evaluate scripts in HTML cells of notebooks? +% - chat +% Activate the chat interface swish_config:config(show_beware, false). swish_config:config(tabled_results, true). @@ -105,6 +121,7 @@ swish_config:config(csv_formats, [rdf, prolog]). swish_config:config(public_access, true). swish_config:config(ping, 10). swish_config:config(notebook, _{eval_script: true}). +swish_config:config(chat, true). %% swish_config:source_alias(Alias, Options) is nondet. % diff --git a/lib/swish/cp_authenticate.pl b/lib/swish/cp_authenticate.pl index f399dca..3bf6a89 100644 --- a/lib/swish/cp_authenticate.pl +++ b/lib/swish/cp_authenticate.pl @@ -3,7 +3,8 @@ Author: Jan Wielemaker E-mail: J.Wielemaker@cs.vu.nl WWW: http://www.swi-prolog.org - Copyright (C): 2014, VU University Amsterdam + Copyright (C): 2014-2017, VU University Amsterdam + CWI, Amsterdam This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -27,11 +28,11 @@ the GNU General Public License. */ -:- module(swish_authenticate, +:- module(cp_swish_authenticate, [ ]). :- use_module(library(pengines), []). -:- use_module(library(lists)). +:- use_module(library(broadcast)). :- use_module(user(user_db)). /** <module> SWISH login management @@ -51,8 +52,38 @@ the server will challenge the user. The logged in user is available through pengine_user/1. */ -pengines:authentication_hook(_Request, _Application, User) :- - logged_on(User). +:- multifile + swish_config:authenticate/2, + swish_config:user_info/3. + +swish_config:authenticate(_Request, User) :- + logged_on(User). + + +swish_config:user_info(_Request, local, Info) :- + logged_on(User), + findall(Name-Value, cp_user_property(User, Name, Value), Pairs), + dict_pairs(Info, u, Pairs). + +cp_user_property(User, user, User). +cp_user_property(User, name, RealName) :- + user_property(User, realname(RealName)). +cp_user_property(User, email, Email) :- + user_property(User, email(Email)). +cp_user_property(User, group, Group) :- + user_property(User, allow(Allow)), + ( memberchk(admin(_), Allow) + -> Group = admin + ; memberchk(write(_,_), Allow) + -> Group = writer + ; Group = reader + ). + +:- listen(identity_property(Identity, Property), + cp_identity_property(Identity, Property)). + +cp_identity_property(Identity, Property) :- + _{user:User, identity_provider:local} :< Identity, + Property =.. [Name,Value], + cp_user_property(User, Name, Value). -pengines:not_sandboxed(User, _Application) :- - catch(check_permission(User, admin(swish)), _, fail).