Update dmd version + dependencies

This commit is contained in:
Chris Josten 2023-12-08 22:52:11 +01:00
parent bdb7615044
commit 651668526d
7 changed files with 50 additions and 25 deletions

View file

@ -5,17 +5,19 @@
"botan-math": "1.0.3",
"diet-ng": "1.8.1",
"dyaml": "0.8.6",
"eventcore": "0.9.20",
"eventcore": "0.9.26",
"fswatch": "0.5.0",
"libasync": "0.8.6",
"libevent": "2.0.2+2.0.16",
"memutils": "1.0.4",
"memutils": "1.0.9",
"mir-linux-kernel": "1.0.1",
"openssl": "3.2.2",
"openssl": "3.3.3",
"openssl-static": "1.0.2+3.0.8",
"stdx-allocator": "2.77.5",
"taggedalgebraic": "0.11.22",
"tinyendian": "0.2.0",
"vibe-core": "1.22.4",
"vibe-d": "0.9.5"
"vibe-container": "1.0.1",
"vibe-core": "2.5.1",
"vibe-d": "0.9.7"
}
}

View file

@ -5,6 +5,7 @@ import article;
import page;
import project;
@safe:
/**
* Default ordering and list with pointers to ordered articles.

View file

@ -9,19 +9,29 @@ import cache;
import http;
import watcher;
void watchTask(T, C)(C *cache, string directory) @safe nothrow {
do {
try {
initPages!T(cache, directory);
} catch(Exception e) {
logWarn("Error while watching pages: " ~ e.msg);
}
} while(Task.getThis().running);
}
void main() {
startHTTPServer();
// Start indexing pages.
runTask({
initPages!Page(&pages, "pages");
watchTask!Page(&pages, "pages");
});
runTask({
initPages!Article(&articles, "articles");
watchTask!Article(&articles, "articles");
});
runTask({
initPages!Project(&projects, "projects");
watchTask!Project(&projects, "projects");
});
runApplication();
}

View file

@ -10,6 +10,7 @@ import vibe.d;
import page;
import utils;
@safe:
/**
* Represents an article on the blog

View file

@ -9,6 +9,7 @@ import vibe.vibe;
import utils;
@safe:
/**
* Exception thrown when a page has syntax errors e.g.
@ -51,7 +52,7 @@ class Page {
/**
* Creates a page from a file. This will read from the file and parse it.
*/
this(string file) {
this(string file) @safe {
this.m_name = file;
this.m_contentSource = readText(file);
// Find the seperator and split the string in two

View file

@ -9,6 +9,8 @@ import page;
import utils;
import staticpaths;
@safe:
/**
* Represents a project, like an unfinished application
*/

View file

@ -1,6 +1,6 @@
import std.array;
import std.algorithm;
import std.experimental.logger;
//import std.experimental.logger;
import std.file;
import std.stdio;
import std.traits;
@ -13,27 +13,35 @@ import page;
/**
* Loads pages into memory and sets up a "watcher" to watch a directory for file changes.
*/
void initPages(T, C)(C *cache, const string directory)
void initPages(T, C)(C *cache, const string directory) @trusted
if (isImplicitlyConvertible!(T, Page)) {
NativePath watchingDir;
try {
watchingDir = getWorkingDirectory() ~ directory;
} catch(PathValidationException) {
logError("Cannot watch path " ~ directory);
return;
}
bool addPage(string path) {
try {
T newPage = new T(path);
logf("Added %s", newPage.slug);
logInfo("Added %s", newPage.slug);
cache.addItem(newPage);
return true;
} catch (page.ArticleParseException e) {
logf("Could not parse %s: %s", path, e);
logWarn("Could not parse %s: %s", path, e);
return false;
} catch (Exception e) {
logf("Other exception while parsing %s: %s", path, e);
logWarn("Other exception while parsing %s: %s", path, e);
return false;
}
}
// Initial scan
void scan(NativePath path, int level = 0) {
logf("Scanning %s", path.toString());
logInfo("Scanning %s", path.toString());
foreach(file; iterateDirectory(path)) {
if (file.isDirectory) {
scan(path ~ file.name, level + 1);
@ -43,11 +51,11 @@ void initPages(T, C)(C *cache, const string directory)
}
}
if (!existsFile(getWorkingDirectory() ~ directory)) {
createDirectory(getWorkingDirectory() ~ directory);
if (!existsFile(watchingDir)) {
createDirectory(watchingDir);
}
scan(getWorkingDirectory() ~ directory);
DirectoryWatcher watcher = watchDirectory(getWorkingDirectory() ~ directory, true);
scan(watchingDir);
DirectoryWatcher watcher = watchDirectory(watchingDir, true);
bool shouldStop = false;
while (!shouldStop) {
@ -55,16 +63,16 @@ void initPages(T, C)(C *cache, const string directory)
DirectoryChange[] changes;
shouldStop = !watcher.readChanges(changes);
foreach(change; changes) {
logf("=======[New changes]======");
logInfo("=======[New changes]======");
string[] changeTypes = ["added", "removed", "modified"];
logf("Path: %s, type: %s", change.path.toString(), changeTypes[change.type]);
logInfo("Path: %s, type: %s", change.path.toString(), changeTypes[change.type]);
if (endsWith(change.path.toString(), ".kate-swp")) continue;
switch (change.type) with (DirectoryChangeType){
case added:
try {
addPage(change.path.toString());
} catch(Exception e) {
warningf("Error while updating %s: %s", change.path.toString(), e.msg);
logWarn("Error while updating %s: %s", change.path.toString(), e.msg);
}
break;
case modified:
@ -73,16 +81,16 @@ void initPages(T, C)(C *cache, const string directory)
newPage = new T(change.path.toString());
cache.changeItem(newPage);
} catch(page.ArticleParseException e) {
warningf("Could not parse %s", change.path.toString());
logWarn("Could not parse %s", change.path.toString());
} catch (Exception e) {
warningf("Error while updating %s: %s", change.path.toString(), e.msg);
logWarn("Error while updating %s: %s", change.path.toString(), e.msg);
}
break;
case removed:
try {
cache.removeItemByName(change.path.toString());
} catch(Exception e) {
logf("Error while trying to remove %s: %s", T.stringof, e.msg);
logInfo("Error while trying to remove %s: %s", T.stringof, e.msg);
}
break;
default: break;