Skip to content

Commit

Permalink
Remove black list in tm2html_CD (#38)
Browse files Browse the repository at this point in the history
## What?
Change tm, tmu format to html for CD

## How to test?
On Linux:
```
/usr/bin/MoganResearch -headless -b CD/tm2html_CD.scm  -x "(tm2html_CD)" -q
```

On Windows:
```
build\packages\app.mogan\data\bin\MoganResearch.exe -headless -b path\to\CD\tm2html_CD.scm -x "(tm2html_CD)" -q
```
  • Loading branch information
ATQlove authored Aug 1, 2024
1 parent 4c47f5c commit a0d864c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 40 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/cd-convert-debian-bookworm.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: CI/CD for Converting tm format to html
name: CD for Converting tm format to html

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
Expand All @@ -22,18 +19,18 @@ jobs:

- name: download release from mogan research repository
run: |
wget https://github.com/XmacsLabs/mogan/releases/download/v1.2.8-rc1/mogan-research-v1.2.8-rc1-debian12.deb -O /tmp/mogan-research.deb
wget https://github.com/XmacsLabs/mogan/releases/download/v1.2.8-rc2/mogan-research-v1.2.8-rc2-debian12.deb -O /tmp/mogan-research.deb
DEBIAN_FRONTEND=noninteractive apt install -y /tmp/mogan-research.deb
- name: convert document to html format
run: |
/usr/bin/MoganResearch -headless -b CICD/tm2html_CICD.scm -x "(tm2html_CICD)" -q
/usr/bin/MoganResearch -headless -b CD/tm2html_CD.scm -x "(tm2html_CD)" -q
# Deploy to local repo
- name: Deploy
uses: s0/git-publish-subdir-action@develop
env:
REPO: self
BRANCH: gh-pages
FOLDER: CICD/html/planet
FOLDER: CD/html/planet
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50 changes: 17 additions & 33 deletions CICD/tm2html_CICD.scm → CD/tm2html_CD.scm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; MODULE : tm2html_CICD.scm
;; DESCRIPTION : Convert tm format to html for CICD
;; MODULE : tm2html_CD.scm
;; DESCRIPTION : Convert tm format to html for CD
;; COPYRIGHT : (C) 2024 ATQlove
;;
;; This software falls under the GNU general public license version 3 or later.
Expand All @@ -11,45 +11,33 @@
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(import (srfi srfi-13))
(import (srfi srfi-1))

(define (list-files dir)
(let* ((filtered-files (url->list
(url-expand
(url-complete
(url-append (url-descendants dir)
(url-or (url-wildcard "*.tm")
(url-wildcard "*.tmu")))
"fr"))))
(filtered-files-no-conflict (filter (lambda (file)
(let ((file-string (url->string file)))
(and (not (string-contains? file-string "MoganSTEMTutorial"))
(not (string-contains? file-string "LaTeX"))
(not (string-contains? file-string "UIC"))
(not (string-contains? file-string "X202402预备会议"))
(not (string-contains? file-string "SICP"))
(not (string-contains? file-string "LCPU_x_USTCLUG_Salon")))))
filtered-files)))
"fr")))))
; (display "Filtered files:\n")
; (for-each (lambda (file) (display (string-append (url->string file) "\n"))) filtered-files)
filtered-files-no-conflict))
filtered-files))

(define (export-file-to-html file base-dir output-dir)
(define (export-file-to-html base-dir file output-dir)
(let* ((relative-path (url-delta base-dir file))
(output-file-url (url-append output-dir relative-path))
(output-file-url (url-unglue output-file-url 3)) ; Remove ".tm" or ".tmu" extension
(html-file-url (url-glue output-file-url ".html"))
(output-dir-url (url-head html-file-url)))

; ; Debugging information; expect information are just some example
; (display (string-append "Base directory: " (url->string base-dir) "\n")) ; Expect: file:///F:/mogan/planet/CICD/try
; (display (string-append "File: " (url->string file) "\n")) ; Expect: file:///F:/mogan/planet/CICD/try/2/24_10_tmhtml_test.tmu
; (display (string-append "Base directory: " (url->string base-dir) "\n")) ; Expect: file:///F:/mogan/planet/CD/try
; (display (string-append "File: " (url->string file) "\n")) ; Expect: file:///F:/mogan/planet/CD/try/2/24_10_tmhtml_test.tmu
; (display (string-append "Relative path: " (url->string relative-path) "\n")) ; Expect: /2/24_10_tmhtml_test.tmu
; (display (string-append "Output file URL (before unglue): " (url->string output-file-url) "\n")) ; Expect: file:///F:/mogan/planet/CICD/html/2/24_10_tmhtml_test.tmu
; (display (string-append "Output file URL (after unglue): " (url->string (url-unglue output-file-url 3)) "\n")) ; Expect: file:///F:/mogan/planet/CICD/html/2/24_10_tmhtml_test
; (display (string-append "HTML file URL: " (url->string html-file-url) "\n")) ; Expect: file:///F:/mogan/planet/CICD/html/2/24_10_tmhtml_test.html
; (display (string-append "Output directory URL: " (url->string output-dir-url) "\n")) ; Expect: file:///F:/mogan/planet/CICD/html/2
; (display (string-append "Output file URL (before unglue): " (url->string output-file-url) "\n")) ; Expect: file:///F:/mogan/planet/CD/html/2/24_10_tmhtml_test.tmu
; (display (string-append "Output file URL (after unglue): " (url->string (url-unglue output-file-url 3)) "\n")) ; Expect: file:///F:/mogan/planet/CD/html/2/24_10_tmhtml_test
; (display (string-append "HTML file URL: " (url->string html-file-url) "\n")) ; Expect: file:///F:/mogan/planet/CD/html/2/24_10_tmhtml_test.html
; (display (string-append "Output directory URL: " (url->string output-dir-url) "\n")) ; Expect: file:///F:/mogan/planet/CD/html/2

(make-directory (url->string output-dir-url))
(display (string-append "Exporting " (url->string file) " to " (url->string html-file-url) "\n"))
Expand All @@ -62,15 +50,11 @@
(define (export-directory dir output-dir)
(let* ((files (list-files dir)))
(for-each (lambda (file)
(export-file-to-html file dir output-dir))
(export-file-to-html dir file output-dir))
files)))

(tm-define (tm2html_CICD)
; (url-exists? "/__w/planet/planet/jingkaimori")
; (url-exists? "/__w/planet/planet/CICD")
; (define filtered-files (list-files "F:/mogan/planet"))
; (display filtered-files)
(export-directory "/__w/planet/planet" "/__w/planet/planet/CICD/html")
; (export-directory "F:/mogan/planet" "F:/mogan/planet/CICD/html")
(display "Conversion from tm/tmu to html end\n"))

(define (tm2html_CD)
(let* ((current-dir (url->string (url-pwd)))
(output-dir (string-append current-dir "/CD/html")))
(export-directory current-dir output-dir)
(display "Conversion from tm/tmu to html end\n")))

0 comments on commit a0d864c

Please sign in to comment.