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
2 |
+
import datetime
|
3 |
+
import calendar
|
4 |
+
|
5 |
+
class EventManager:
|
6 |
+
def __init__(self):
|
7 |
+
# 월별 기본 컨셉 정의
|
8 |
+
self.monthly_concepts = {
|
9 |
+
1: {"theme": "신년/설날", "colors": ["#FF6B6B", "#FFE66D"], "mood": "희망찬, 따뜻한"},
|
10 |
+
2: {"theme": "발렌타인데이", "colors": ["#FF69B4", "#FFB6C1"], "mood": "로맨틱, 달콤한"},
|
11 |
+
3: {"theme": "화이트데이/봄", "colors": ["#FFFFFF", "#F0F8FF"], "mood": "순수한, 상쾌한"},
|
12 |
+
4: {"theme": "벚꽃/봄나들이", "colors": ["#FFB7C5", "#98FB98"], "mood": "생기발랄, 활기찬"},
|
13 |
+
5: {"theme": "로즈데이/가정의달", "colors": ["#FF1493", "#FF69B4"], "mood": "감사한, 사랑스러운"},
|
14 |
+
6: {"theme": "결혼시즌/초여름", "colors": ["#87CEEB", "#F0E68C"], "mood": "청량한, 행복한"},
|
15 |
+
7: {"theme": "여름휴가", "colors": ["#00CED1", "#FFE4B5"], "mood": "시원한, 자유로운"},
|
16 |
+
8: {"theme": "무더위극복", "colors": ["#20B2AA", "#F0FFFF"], "mood": "시원한, 에너지 넘치는"},
|
17 |
+
9: {"theme": "가을시작", "colors": ["#DEB887", "#CD853F"], "mood": "따뜻한, 아늑한"},
|
18 |
+
10: {"theme": "할로윈", "colors": ["#FF4500", "#8B0000"], "mood": "신비로운, 재미있는"},
|
19 |
+
11: {"theme": "단풍/감사", "colors": ["#DAA520", "#B22222"], "mood": "감사한, 따뜻한"},
|
20 |
+
12: {"theme": "크리스마스/연말", "colors": ["#DC143C", "#228B22"], "mood": "축제같은, 따뜻한"}
|
21 |
+
}
|
22 |
+
|
23 |
+
# 이벤트 타입별 기본 설정
|
24 |
+
self.event_types = {
|
25 |
+
"댓글이벤트": {
|
26 |
+
"action": "댓글 작성",
|
27 |
+
"reward_frequency": "1시간마다",
|
28 |
+
"participation": "유익하고 착한 댓글 남기기"
|
29 |
+
},
|
30 |
+
"채용공고": {
|
31 |
+
"action": "채용공고 확인",
|
32 |
+
"reward_frequency": "일별",
|
33 |
+
"participation": "채용공고 열람 및 지원"
|
34 |
+
},
|
35 |
+
"게시글작성": {
|
36 |
+
"action": "게시글 작성",
|
37 |
+
"reward_frequency": "일별",
|
38 |
+
"participation": "양질의 게시글 작성"
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
def calculate_event_duration(self, start_date: str, end_date: str):
|
43 |
+
"""이벤트 기간 계산"""
|
44 |
+
try:
|
45 |
+
start = datetime.datetime.strptime(start_date, "%Y-%m-%d")
|
46 |
+
end = datetime.datetime.strptime(end_date, "%Y-%m-%d")
|
47 |
+
duration = (end - start).days + 1
|
48 |
+
month = start.month
|
49 |
+
return duration, month
|
50 |
+
except:
|
51 |
+
return 0, 0
|
52 |
+
|
53 |
+
def generate_monthly_concept(self, month: int):
|
54 |
+
"""월별 컨셉 생성"""
|
55 |
+
if month in self.monthly_concepts:
|
56 |
+
concept = self.monthly_concepts[month]
|
57 |
+
return {
|
58 |
+
"theme": concept["theme"],
|
59 |
+
"colors": concept["colors"],
|
60 |
+
"mood": concept["mood"],
|
61 |
+
"month_name": calendar.month_name[month]
|
62 |
+
}
|
63 |
+
return {}
|
64 |
+
|
65 |
+
def generate_event_copy(self, event_type: str, concept: Dict, duration: int,
|
66 |
+
custom_details: str = "") -> str:
|
67 |
+
"""이벤트 카피 생성"""
|
68 |
+
if not concept:
|
69 |
+
return "먼저 이벤트 기간을 설정해주세요."
|
70 |
+
|
71 |
+
theme = concept.get("theme", "특별한")
|
72 |
+
mood = concept.get("mood", "즐거운")
|
73 |
+
|
74 |
+
base_copy = f"""✨ {theme} 특별 이벤트 ✨
|
75 |
+
{mood} {theme} 시즌을 맞아 특별한 이벤트를 준비했어요!
|
76 |
+
|
77 |
+
🎯 이벤트 참여방법
|
78 |
+
{self.event_types.get(event_type, {}).get('participation', '이벤트에 참여하세요')}
|
79 |
+
|
80 |
+
⏰ 이벤트 기간
|
81 |
+
{duration}일간 진행되는 특별한 이벤트입니다!
|
82 |
+
|
83 |
+
🎁 혜택
|
84 |
+
{self.event_types.get(event_type, {}).get('reward_frequency', '정기적으로')} 선물을 드려요!
|
85 |
+
"""
|
86 |
+
|
87 |
+
if custom_details:
|
88 |
+
base_copy += f"\n📝 추가 정보\n{custom_details}"
|
89 |
+
|
90 |
+
return base_copy
|
91 |
+
|
92 |
+
def generate_design_advice(self, concept: Dict) -> str:
|
93 |
+
"""디자인 조언 생성"""
|
94 |
+
if not concept:
|
95 |
+
return "컨셉 정보가 필요합니다."
|
96 |
+
|
97 |
+
colors = concept.get("colors", ["#000000", "#FFFFFF"])
|
98 |
+
mood = concept.get("mood", "")
|
99 |
+
theme = concept.get("theme", "")
|
100 |
+
|
101 |
+
advice = f"""🎨 디자인 조언
|
102 |
+
|
103 |
+
🎯 컬러 팔레트
|
104 |
+
- 메인 컬러: {colors[0]}
|
105 |
+
- 서브 컬러: {colors[1]}
|
106 |
+
- 20-40대 여성에게 어필하는 {mood} 느낌
|
107 |
+
|
108 |
+
📐 레이아웃 추천
|
109 |
+
- 제목: 큰 폰트로 임팩트 있게
|
110 |
+
- 핵심 정보: 시각적으로 구분되는 박스 활용
|
111 |
+
- CTA 버튼: 눈에 띄는 컬러로 강조
|
112 |
+
- 이미지: {theme} 테마에 맞는 일러스트 활용
|
113 |
+
|
114 |
+
👀 가독성 향상
|
115 |
+
- 충분한 여백 활용
|
116 |
+
- 계층적 정보 구조
|
117 |
+
- 스캔하기 쉬운 레이아웃
|
118 |
+
- 모바일 친화적 디자인"""
|
119 |
+
|
120 |
+
return advice
|
121 |
+
|
122 |
+
def create_interface():
|
123 |
+
event_manager = EventManager()
|
124 |
+
|
125 |
+
with gr.Blocks(title="이벤트 관리 시스템", theme=gr.themes.Soft()) as demo:
|
126 |
+
gr.Markdown("# 🎉 이벤트 관리 시스템")
|
127 |
+
gr.Markdown("월별 이벤트 기획부터 디자인 조언까지 한 번에!")
|
128 |
+
|
129 |
+
with gr.Row():
|
130 |
+
with gr.Column(scale=1):
|
131 |
+
gr.Markdown("## 📅 이벤트 기본 정보")
|
132 |
+
|
133 |
+
start_date = gr.Textbox(
|
134 |
+
label="이벤트 시작일",
|
135 |
+
placeholder="YYYY-MM-DD (예: 2025-05-15)",
|
136 |
+
value="2025-05-15"
|
137 |
+
)
|
138 |
+
|
139 |
+
end_date = gr.Textbox(
|
140 |
+
label="이벤트 종료일",
|
141 |
+
placeholder="YYYY-MM-DD (예: 2025-05-25)",
|
142 |
+
value="2025-05-25"
|
143 |
+
)
|
144 |
+
|
145 |
+
event_type = gr.Dropdown(
|
146 |
+
choices=list(event_manager.event_types.keys()),
|
147 |
+
label="이벤트 종류",
|
148 |
+
value="댓글이벤트"
|
149 |
+
)
|
150 |
+
|
151 |
+
custom_details = gr.Textbox(
|
152 |
+
label="추가 상세내용",
|
153 |
+
placeholder="특별한 조건이나 상세 내용을 입력하세요",
|
154 |
+
lines=3
|
155 |
+
)
|
156 |
+
|
157 |
+
generate_btn = gr.Button("✨ 이벤트 생성하기", variant="primary")
|
158 |
+
|
159 |
+
with gr.Column(scale=2):
|
160 |
+
gr.Markdown("## 📊 생성 결과")
|
161 |
+
|
162 |
+
duration_info = gr.Textbox(
|
163 |
+
label="이벤트 기간 정보",
|
164 |
+
interactive=False
|
165 |
+
)
|
166 |
+
|
167 |
+
concept_info = gr.Textbox(
|
168 |
+
label="월별 컨셉 정보",
|
169 |
+
interactive=False,
|
170 |
+
lines=3
|
171 |
+
)
|
172 |
+
|
173 |
+
event_copy = gr.Textbox(
|
174 |
+
label="이벤트 카피",
|
175 |
+
interactive=False,
|
176 |
+
lines=8
|
177 |
+
)
|
178 |
+
|
179 |
+
design_advice = gr.Textbox(
|
180 |
+
label="디자인 조언",
|
181 |
+
interactive=False,
|
182 |
+
lines=10
|
183 |
+
)
|
184 |
+
|
185 |
+
def generate_event_content(start_date_val, end_date_val, event_type_val, custom_details_val):
|
186 |
+
# 기간 계산
|
187 |
+
duration, month = event_manager.calculate_event_duration(start_date_val, end_date_val)
|
188 |
+
|
189 |
+
if duration == 0:
|
190 |
+
return "날짜 형식을 확인해주세요", "", "", ""
|
191 |
+
|
192 |
+
duration_text = f"{duration}일간 ({start_date_val} ~ {end_date_val})"
|
193 |
+
|
194 |
+
# 월별 컨셉 생성
|
195 |
+
concept = event_manager.generate_monthly_concept(month)
|
196 |
+
concept_text = f"테마: {concept.get('theme', '')}\n분위기: {concept.get('mood', '')}\n컬러: {', '.join(concept.get('colors', []))}"
|
197 |
+
|
198 |
+
# 카피 생성
|
199 |
+
copy_text = event_manager.generate_event_copy(event_type_val, concept, duration, custom_details_val)
|
200 |
+
|
201 |
+
# 디자인 조언 생성
|
202 |
+
design_text = event_manager.generate_design_advice(concept)
|
203 |
+
|
204 |
+
return duration_text, concept_text, copy_text, design_text
|
205 |
+
|
206 |
+
generate_btn.click(
|
207 |
+
fn=generate_event_content,
|
208 |
+
inputs=[start_date, end_date, event_type, custom_details],
|
209 |
+
outputs=[duration_info, concept_info, event_copy, design_advice]
|
210 |
+
)
|
211 |
+
|
212 |
+
gr.Markdown("""
|
213 |
+
## 📝 사용 가이드
|
214 |
+
1. **이벤트 기간 설정**: 시작일과 종료일을 YYYY-MM-DD 형식으로 입력
|
215 |
+
2. **이벤트 종류 선택**: 드롭다운에서 이벤트 타입 선택
|
216 |
+
3. **추가 정보 입력**: 특별한 조건이나 상세내용 입력 (선택사항)
|
217 |
+
4. **생성하기 클릭**: 자동으로 컨셉, 카피, 디자인 조언 생성
|
218 |
+
|
219 |
+
### 🎯 다음 단계 개발 예정
|
220 |
+
- 이미지 레퍼런스 분석 기능
|
221 |
+
- 상세한 공지사항 템플릿
|
222 |
+
- 이벤트 종류별 맞춤 설정
|
223 |
+
""")
|
224 |
+
|
225 |
+
return demo
|
226 |
+
|
227 |
+
if __name__ == "__main__":
|
228 |
+
demo = create_interface()
|
229 |
+
demo.launch(share=True)
|