forked from cory/tildefriends
		
	A slightly dynamic administration page. As always, uncertain if this is a good direction.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4062 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		
							
								
								
									
										22
									
								
								core/core.js
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								core/core.js
									
									
									
									
									
								
							@@ -6,6 +6,19 @@ var gProcessIndex = 0;
 | 
			
		||||
var gProcesses = {};
 | 
			
		||||
var gStatsTimer = false;
 | 
			
		||||
 | 
			
		||||
const k_global_settings = {
 | 
			
		||||
	index: {
 | 
			
		||||
		type: 'string',
 | 
			
		||||
		default_value: '/~core/apps/',
 | 
			
		||||
		description: 'Default path.',
 | 
			
		||||
	},
 | 
			
		||||
	room: {
 | 
			
		||||
		type: 'boolean',
 | 
			
		||||
		default_value: true,
 | 
			
		||||
		description: 'Whether this instance should behave as a room.',
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
var gGlobalSettings = {
 | 
			
		||||
	index: "/~core/apps/",
 | 
			
		||||
};
 | 
			
		||||
@@ -240,6 +253,15 @@ async function getProcessBlob(blobId, key, options) {
 | 
			
		||||
				}
 | 
			
		||||
			};
 | 
			
		||||
			if (process.credentials?.permissions?.administration) {
 | 
			
		||||
				imports.core.globalSettingsDescriptions = function() {
 | 
			
		||||
					let settings = Object.assign({}, k_global_settings);
 | 
			
		||||
					for (let [key, value] of Object.entries(gGlobalSettings)) {
 | 
			
		||||
						if (settings[key]) {
 | 
			
		||||
							settings[key].value = value;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					return settings;
 | 
			
		||||
				};
 | 
			
		||||
				imports.core.globalSettingsGet = function(key) {
 | 
			
		||||
					return gGlobalSettings[key];
 | 
			
		||||
				};
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ var g_database = new Database('core');
 | 
			
		||||
let g_attendants = {};
 | 
			
		||||
const k_use_create_history_stream = false;
 | 
			
		||||
const k_blobs_concurrent_target = 8;
 | 
			
		||||
const k_settings = JSON.parse(g_database.get('settings') ?? '{}');
 | 
			
		||||
 | 
			
		||||
function following(db, id) {
 | 
			
		||||
	var o = db.get(id + ":following");
 | 
			
		||||
@@ -195,7 +196,11 @@ ssb.addRpc(['blobs', 'createWants'], function(request) {
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
ssb.addRpc(['tunnel', 'isRoom'], function(request) {
 | 
			
		||||
	request.send_json({"name": "tilde friends tunnel", "membership": false, "features": ["tunnel", "room1"]});
 | 
			
		||||
	if (k_settings.room) {
 | 
			
		||||
		request.send_json({"name": "tilde friends tunnel", "membership": false, "features": ["tunnel", "room1"]});
 | 
			
		||||
	} else {
 | 
			
		||||
		request.send_json(false);
 | 
			
		||||
	}
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function notify_attendant_changed(id, type) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								src/main.c
									
									
									
									
									
								
							@@ -250,17 +250,19 @@ xopt_help:
 | 
			
		||||
static int _tf_command_export(const char* file, int argc, char* argv[])
 | 
			
		||||
{
 | 
			
		||||
	typedef struct args_t {
 | 
			
		||||
		const char* user;
 | 
			
		||||
		const char* db_path;
 | 
			
		||||
		bool help;
 | 
			
		||||
	} args_t;
 | 
			
		||||
 | 
			
		||||
	xoptOption options[] = {
 | 
			
		||||
		{ "db-path", 'd', offsetof(args_t, db_path), NULL, XOPT_TYPE_STRING, NULL, "Sqlite database path (default: db.sqlite)." },
 | 
			
		||||
		{ "user", 'u', offsetof(args_t, user), NULL, XOPT_TYPE_STRING, NULL, "User into whose apps will be exported (default: \"cory\")." },
 | 
			
		||||
		{ "help", 'h', offsetof(args_t, help), NULL, XOPT_TYPE_BOOL, NULL, "Shows this help message." },
 | 
			
		||||
		XOPT_NULLOPTION,
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	args_t args = { 0 };
 | 
			
		||||
	args_t args = { .user = "cory" };
 | 
			
		||||
	const char** extras = NULL;
 | 
			
		||||
	int extra_count = 0;
 | 
			
		||||
	const char *err = NULL;
 | 
			
		||||
@@ -292,19 +294,21 @@ static int _tf_command_export(const char* file, int argc, char* argv[])
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		const char* k_export[] = {
 | 
			
		||||
			"/~cory/admin",
 | 
			
		||||
			"/~cory/api",
 | 
			
		||||
			"/~cory/apps",
 | 
			
		||||
			"/~cory/db",
 | 
			
		||||
			"/~cory/docs",
 | 
			
		||||
			"/~cory/follow",
 | 
			
		||||
			"/~cory/ssblit",
 | 
			
		||||
			"/~cory/todo",
 | 
			
		||||
			"admin",
 | 
			
		||||
			"api",
 | 
			
		||||
			"apps",
 | 
			
		||||
			"db",
 | 
			
		||||
			"docs",
 | 
			
		||||
			"follow",
 | 
			
		||||
			"ssblit",
 | 
			
		||||
			"todo",
 | 
			
		||||
		};
 | 
			
		||||
		for (int i = 0; i < (int)_countof(k_export); i++)
 | 
			
		||||
		{
 | 
			
		||||
			printf("Exporting %s...\n", k_export[i]);
 | 
			
		||||
			tf_ssb_export(ssb, k_export[i]);
 | 
			
		||||
			char buffer[256];
 | 
			
		||||
			snprintf(buffer, sizeof(buffer), "/~%s/%s", args.user, k_export[i]);
 | 
			
		||||
			printf("Exporting %s...\n", buffer);
 | 
			
		||||
			tf_ssb_export(ssb, buffer);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	tf_ssb_destroy(ssb);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user