-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add sorting * add yaml adapter * add compiler * modify CI to use compiler
- Loading branch information
1 parent
8f60acc
commit 6a7e989
Showing
16 changed files
with
487 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
FROM golang:1.23 as build | ||
FROM golang:1.23 | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download && go mod verify | ||
|
||
COPY . . | ||
RUN make build | ||
RUN ./anemon generate | ||
|
||
FROM debian:latest | ||
COPY --from=build /app/assets/latex/output/ /internal_output | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
texlive \ | ||
texlive-latex-extra \ | ||
texlive-fonts-extra \ | ||
texlive-xetex \ | ||
texlive-font-utils \ | ||
fonts-font-awesome \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* | ||
fonts-font-awesome && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
RUN make build | ||
|
||
CMD mkdir -p /tmp_output && cd /internal_output && for i in *.tex; do pdflatex $i -output-directory=/tmp_output || true; done && ls && pwd && ls /tmp_output && cp /internal_output/*.pdf /output/ | ||
CMD ["./anemon", "generate"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package input | ||
|
||
import ( | ||
core "anemon/internal/core" | ||
"os" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
type YamlSource struct{} | ||
|
||
func (*YamlSource) GetParamsFrom(root string) (core.Params, error) { | ||
params := core.Params{} | ||
yamlFile, err := os.ReadFile(root + "/params.yml") | ||
if err != nil { | ||
return params, err | ||
} | ||
err = yaml.Unmarshal(yamlFile, ¶ms) | ||
if err != nil { | ||
return params, err | ||
} | ||
return params, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package output | ||
|
||
import ( | ||
"fmt" | ||
"log/slog" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
"sync" | ||
) | ||
|
||
|
||
const COMPILER = "pdflatex" | ||
type LatexCompiler struct{} | ||
|
||
//Compile the template into PDF | ||
func (*LatexCompiler) CompileTemplate(root string)error{ | ||
templates,err := getListOfTemplate(root);if err != nil { | ||
return err | ||
} | ||
var wg sync.WaitGroup | ||
for _,template := range templates{ | ||
wg.Add(1) | ||
go compile(template,root,&wg) | ||
} | ||
wg.Wait() | ||
return nil | ||
} | ||
|
||
//Compile the template into a pdf | ||
func compile(template string, root string, wg* sync.WaitGroup){ | ||
defer wg.Done() | ||
cmd := exec.Command(COMPILER,"-interaction=nonstopmode", | ||
"-output-directory="+root+"/assets/latex/output", template ) | ||
log, err := cmd.Output(); if err != nil { | ||
slog.Info("---FROM pdflatex ---\n"+string(log)) | ||
slog.Error("failed to compile file:"+template) | ||
} | ||
} | ||
|
||
//Return the path of latex file inside the template directory | ||
func getListOfTemplate(root string)([]string, error){ | ||
var res []string | ||
templates, err := os.ReadDir(root + "/assets/latex/output"); if err != nil { | ||
slog.Error("failed to read directory because: "+ err.Error()) | ||
return res,err | ||
} | ||
for _, template := range templates { | ||
if strings.HasSuffix(template.Name(),".tex"){ | ||
res = append(res, root+"/assets/latex/output/"+template.Name()) | ||
} | ||
} | ||
fmt.Println(res) | ||
return res,nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.