Nyanpre commited on
Commit
c8fc647
·
verified ·
1 Parent(s): f09bea5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +81 -1
app.py CHANGED
@@ -129,4 +129,84 @@ h1 { margin-top: 0px !important; margin-bottom: -5px !important; font-size: 32px
129
  }
130
 
131
  /* 結果表示ボックス */
132
- #oracle-box {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  }
130
 
131
  /* 結果表示ボックス */
132
+ #oracle-box {
133
+ color: #000 !important;
134
+ background: #fff !important;
135
+ border: 4px solid #000 !important;
136
+ padding: 25px 10px !important;
137
+ line-height: 1.1 !important;
138
+ min-height: 130px !important;
139
+ display: flex !important;
140
+ flex-direction: column !important;
141
+ justify-content: center !important;
142
+ margin: 0px auto -5px auto !important;
143
+ }
144
+
145
+ /* 生成された画像 */
146
+ #result-img { max-width: 400px !important; margin: 10px auto -5px auto !important; border: 1px solid #ccc; }
147
+
148
+ #peace-msg {
149
+ font-size: 20px !important;
150
+ font-weight: bold !important;
151
+ color: #d63031 !important;
152
+ margin: 0px auto -5px auto !important;
153
+ }
154
+
155
+ /* ボタン共通 */
156
+ .action-btn {
157
+ font-size: 26px !important;
158
+ font-weight: bold !important;
159
+ height: 70px !important;
160
+ width: 320px !important;
161
+ border: 2px solid #000 !important;
162
+ }
163
+
164
+ #draw-btn { margin: 0px auto -5px auto !important; }
165
+ #share-btn { margin: 0px auto 10px auto !important; }
166
+ """
167
+
168
+ with gr.Blocks(title="蓮ノ空聖書正典") as demo:
169
+ device_id_storage = gr.State()
170
+
171
+ demo.load(None, None, device_id_storage, js="""
172
+ () => {
173
+ let id = localStorage.getItem('cp_oracle_device_id');
174
+ if(!id) {
175
+ id = Math.random().toString(36).substring(2, 15);
176
+ localStorage.setItem('cp_oracle_device_id', id);
177
+ }
178
+ return id;
179
+ }
180
+ """)
181
+
182
+ with gr.Column(elem_classes="center-content"):
183
+ gr.Markdown("# ⚖️ 蓮ノ空聖書正典")
184
+ gr.Markdown("日付が変わるまであなたの思想は<br>統一されます。", elem_id="doctrine")
185
+
186
+ result_display = gr.HTML(elem_id="oracle-box", visible=False)
187
+
188
+ # 案1:画像出力(負荷軽減のため、初回描画時のみ生成)
189
+ result_image = gr.Image(label="神託の証(保存して投稿に添付してください)", elem_id="result-img", visible=False, type="pil")
190
+
191
+ peace_display = gr.Markdown(elem_id="peace-msg")
192
+
193
+ draw_btn = gr.Button("神託を受ける", variant="primary", elem_id="draw-btn", elem_classes="action-btn")
194
+ share_btn = gr.Button("信仰を広める", variant="secondary", elem_id="share-btn", elem_classes="action-btn", visible=False)
195
+
196
+ draw_btn.click(
197
+ fn=get_personal_daily_oracle,
198
+ inputs=[device_id_storage],
199
+ outputs=[result_display, peace_display, share_btn, result_display, result_image],
200
+ js=js_logic
201
+ ).then(
202
+ fn=None,
203
+ inputs=[result_display, peace_display, share_btn, result_display, result_image],
204
+ outputs=None,
205
+ js=js_save_result
206
+ )
207
+
208
+ share_btn.click(fn=None, inputs=None, outputs=None, js=js_share_bluesky)
209
+
210
+ if __name__ == "__main__":
211
+ # Gradio最新版対応
212
+ demo.launch(css=custom_css, theme=gr.themes.Monochrome())