Maki commited on
Commit
dde65e8
1 Parent(s): bc28421

[feat] Dockerを使用したSlidevの環境構築とスライド生成の自動化

Browse files

以下の変更を行いました:

- Dockerfileを追加し、Node.js、Python、Slidevをインストールする環境を構築
- docker-compose.ymlを追加し、Slidevコンテナの設定を定義
- run_slidev.pyスクリプトを追加し、Slidevコマンドを実行してスライドを生成する処理を自動化
- slides/demo.mdにサンプルのスライド内容を追加
- .gitignoreにSourceSageAssetsディレクトリを追加して無視するように設定
- .gitattributesに画像ファイルの設定を追加
- README.mdにSlidevの実行コマンドを追加

これらの変更により、Dockerを使用してSlidevの環境を簡単に構築し、スライドの生成を自動化することができるようになりました。また、サンプルのスライドを追加し、README.mdにSlidevの実行コマンドを記載することで、プロジェクトの使用方法がわかりやすくなりました。

[feat] Streamlitを使用したMarpスライド生成アプリの実装

以下の変更を行いました:

- app.pyを追加し、Streamlitを使用してMarpスライド生成アプリを実装
- ユーザーがマークダウンテキストを入力し、「Generate Slides」ボタンをクリックするとスライドが生成される
- 生成されたスライドは画像として表示され、各スライドの画像はダウンロード可能なリンクとして提供される
- .streamlit/config.tomlを追加し、Streamlitのテーマを設定

これらの変更により、ユーザーがマークダウンテキストを入力するだけで簡単にMarpスライドを生成できるWebアプリケーションが作成されました。生成されたスライドは画像として表示され、ダウンロードすることも可能です。

.gitattributes ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ *.png filter=lfs diff=lfs merge=lfs -text
2
+ *.gif filter=lfs diff=lfs merge=lfs -text
3
+ *.jpg filter=lfs diff=lfs merge=lfs -text
.gitignore CHANGED
@@ -158,3 +158,4 @@ cython_debug/
158
  # and can be added to the global gitignore or merged into this file. For a more nuclear
159
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
  #.idea/
 
 
158
  # and can be added to the global gitignore or merged into this file. For a more nuclear
159
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
  #.idea/
161
+ SourceSageAssets
.streamlit/config.toml ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [theme]
2
+ base="light"
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dockerfile
2
+ FROM node:18
3
+
4
+ # Pythonのインストール
5
+ RUN apt-get update && apt-get install -y python3 python3-pip
6
+
7
+ # 作業ディレクトリの設定
8
+ WORKDIR /app
9
+
10
+ # Slidevのインストール
11
+ RUN npm install -g @slidev/cli@latest
12
+ RUN npm install -D playwright-chromium
13
+ RUN npx playwright install-deps
14
+
15
+ # Pythonスクリプトのコピー
16
+ COPY run_slidev.py .
17
+
18
+ # スライドディレクトリの作成
19
+ RUN mkdir slides
README.md CHANGED
@@ -1 +1,11 @@
1
- # SlideNova
 
 
 
 
 
 
 
 
 
 
 
1
+ # SlideNova
2
+
3
+
4
+ ```bash
5
+ npx slidev slides/demo.md --remote
6
+ ```
7
+
8
+ ```bash
9
+ npx slidev export slides/demo.md --format png --output slides/out/ --dark
10
+ ```
11
+
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from marp import Marp
3
+ import base64
4
+ from io import BytesIO
5
+
6
+ def main():
7
+ st.title("Marp Slide Generator")
8
+
9
+ # マークダウン入力欄
10
+ markdown_text = st.text_area("Enter your markdown text here:", height=400)
11
+
12
+ if st.button("Generate Slides"):
13
+ # Marpオブジェクトの作成
14
+ marp = Marp()
15
+
16
+ # マークダウンからスライドを生成
17
+ slides = marp.convert(markdown_text)
18
+
19
+ # スライドを画像に変換
20
+ images = []
21
+ for slide in slides:
22
+ image_data = slide.render(format="png")
23
+ images.append(image_data)
24
+
25
+ # 画像を表示
26
+ st.subheader("Generated Slides")
27
+ for i, image in enumerate(images):
28
+ st.image(image, caption=f"Slide {i+1}", use_column_width=True)
29
+
30
+ # 画像をダウンロード可能なリンクとして提供
31
+ buffered = BytesIO()
32
+ image.save(buffered, format="PNG")
33
+ img_str = base64.b64encode(buffered.getvalue()).decode()
34
+ href = f'<a href="data:file/png;base64,{img_str}" download="slide_{i+1}.png">Download Slide {i+1}</a>'
35
+ st.markdown(href, unsafe_allow_html=True)
36
+
37
+ if __name__ == "__main__":
38
+ main()
docker-compose.yml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # docker-compose.yml
2
+ version: '3'
3
+ services:
4
+ slidev:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile
8
+ volumes:
9
+ - ./slides:/app/slides
10
+ ports:
11
+ - "3030:3030"
12
+ # command: python3 run_slidev.py
13
+ tty: true
run_slidev.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # run_slidev.py
2
+ import os
3
+ import subprocess
4
+
5
+ # Slideを格納するディレクトリを指定
6
+ slide_dir = "./slides"
7
+
8
+ # Slideのエントリーポイントを指定
9
+ slide_entry = "slides.md"
10
+
11
+ # slidevコマンドを実行してスライドを開発モードで起動
12
+ # subprocess.run(["npx", "slidev", slide_entry])
13
+
14
+ # slidevコマンドを実行してスライドをビルド
15
+ subprocess.run(["npx", "slidev", "build", slide_entry])
slides/demo.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Slidev
2
+
3
+ Hello World
4
+
5
+ ---
6
+
7
+ # Page 2
8
+
9
+ Directly use code blocks for highlighting
10
+
11
+ ```ts
12
+ console.log('Hello, World!')
13
+ ```
14
+
15
+ ---
16
+
17
+ # Page 3
slides/out/001.png ADDED

Git LFS Details

  • SHA256: becd0ac314aad220580ba42120bfa0e74a925c78ce2436f75c2d0babe95bd6c7
  • Pointer size: 130 Bytes
  • Size of remote file: 10.2 kB
slides/out/002.png ADDED

Git LFS Details

  • SHA256: 1bfc54b7bce01acf5f990ed1f005380522cd8b908e23a361955dc0467a4bc06c
  • Pointer size: 130 Bytes
  • Size of remote file: 14 kB
slides/out/003.png ADDED

Git LFS Details

  • SHA256: c4d0b0be593f688342f03660cc31c69a4d5791a9beb6e626480fcfc2c9bf5c43
  • Pointer size: 129 Bytes
  • Size of remote file: 7.01 kB