dev.metalisp.sbt/src/main.lisp

54 lines
1.7 KiB
Common Lisp
Raw Normal View History

2023-10-01 14:53:35 +02:00
;;;; -*- mode: lisp; coding: utf-8; tab-width: 4; fill-column: 100; indent-tabs-mode: nil; -*-
2024-01-24 13:05:23 +01:00
;;;; main - Provide general functions.
2023-11-25 09:59:03 +01:00
(defpackage dev.metalisp.sbt
2023-07-01 16:30:10 +02:00
(:use :cl)
(:export
2024-01-25 16:07:26 +01:00
:*use-cdn*
:*cdn-css-url*
:*cdn-js-url*
:*bs-version*
:*color-theme*
2024-01-26 11:15:37 +01:00
:write-html-to-file))
2023-07-01 16:30:10 +02:00
2023-11-25 09:59:03 +01:00
(in-package :dev.metalisp.sbt)
2023-07-03 14:43:58 +02:00
2023-07-22 13:58:46 +02:00
(setq spinneret:*fill-column* 120)
2023-07-16 13:57:42 +02:00
2024-01-25 16:07:26 +01:00
(defparameter *bs-version* "5.3.2")
(defparameter *use-cdn* t)
(defparameter *cdn-css-url*
(concatenate 'string
"https://cdn.jsdelivr.net/npm/bootstrap@"
*bs-version*
"/dist/css/bootstrap.min.css"))
(defparameter *cdn-js-url*
(concatenate 'string
"https://cdn.jsdelivr.net/npm/bootstrap@"
*bs-version*
"/dist/js/bootstrap.bundle.min.js"))
(defparameter *color-theme* "dark")
(defun download-file (url directory)
"Downloads a file from a given URL and saves it to the specified directory."
(let* ((filename (car (last (uiop:split-string url :separator "/"))))
(filepath (merge-pathnames filename directory)))
2024-01-25 19:01:54 +01:00
(ensure-directories-exist directory)
2024-01-25 16:07:26 +01:00
(with-open-file (stream filepath
:direction :output
:if-exists :supersede
:element-type '(unsigned-byte 8))
(dex:get url :stream stream))
filepath))
(defun write-html-str-to-file (filename string &key (lang "en") (style :tree) (fc 120))
2023-08-25 15:10:01 +02:00
(let ((spinneret:*html-lang* lang)
(spinneret:*html-style* style)
(spinneret:*fill-column* fc))
(with-open-file (stream filename :direction :output :if-exists :supersede)
(write-string string stream))))