Razoa commited on
Commit
94d6309
·
verified ·
1 Parent(s): 180a685

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +72 -61
app.py CHANGED
@@ -9,42 +9,64 @@ TOKEN = os.environ.get("HF_TOKEN")
9
 
10
  st.set_page_config(page_title="NIRINSBEAT", layout="wide")
11
 
12
- # --- STYLE CSS (CLEAN, NO LOGO, NO DOWNLOAD) ---
13
  st.markdown("""
14
  <style>
15
  @import url('https://fonts.googleapis.com/css2?family=Black+Ops+One&family=Poppins:wght@400;700&display=swap');
16
 
17
- .stApp { background-color: #ffffff; color: #333; font-family: 'Poppins', sans-serif; }
 
 
 
 
 
 
 
18
 
19
- /* Titre NIRINSBEAT Stylé eo ambony fotsiny */
20
  .main-title {
21
  text-align: center;
22
  font-family: 'Black Ops One', cursive;
23
- font-size: 50px;
24
  color: #6f42c1;
25
- padding-top: 30px;
26
- margin-bottom: 40px;
27
- letter-spacing: 3px;
28
- text-transform: uppercase;
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
 
31
- /* ESORINA NY DOWNLOAD (Teboka telo) */
32
  audio::-internal-media-controls-download-button { display:none; }
33
  audio::-webkit-media-controls-enclosure { overflow:hidden; }
34
  audio::-webkit-media-controls-panel { width: calc(100% + 30px); }
35
 
36
- /* WhatsApp Button madio */
37
  .whatsapp-btn {
38
- background-color: #25D366; color: white !important;
39
- border-radius: 8px; text-align: center; padding: 12px;
40
- text-decoration: none; display: block; font-weight: bold; border: none;
41
- font-size: 15px;
 
 
 
 
 
 
42
  }
 
43
 
44
- hr { border: 0; border-top: 1px solid #f2f2f2; margin: 25px 0; }
45
-
46
- /* Sary Artwork kely boribory kely ny sisiny */
47
- .stImage img { border-radius: 8px; }
48
  </style>
49
  """, unsafe_allow_html=True)
50
 
@@ -68,15 +90,15 @@ def save_and_upload(dataframe):
68
 
69
  df = load_data()
70
 
71
- # --- HEADER (TITRE FOTSINY) ---
72
  st.markdown('<div class="main-title">NIRINSBEAT</div>', unsafe_allow_html=True)
 
73
 
74
  # --- SIDEBAR ---
75
  st.sidebar.markdown("### 🔍 Filter")
76
  menu = ["🏠 Home", "🔥 Afrobeat", "🎵 Afropop", "⚡ Drill", "💃 Zouk"]
77
  choice = st.sidebar.selectbox("Sokajy", menu)
78
 
79
- # Admin Stealth (Hita rehefa manoratra admin-login ao amin'ny Search)
80
  secret = st.sidebar.text_input("Search", placeholder="Search beats...")
81
  admin_mode = False
82
  if secret == "admin-login":
@@ -85,74 +107,63 @@ if secret == "admin-login":
85
  # --- CATALOGUE ---
86
  if not admin_mode:
87
  clean_choice = choice.split(" ")[1] if " " in choice else choice
88
-
89
  display_df = df if clean_choice == "Home" else df[df['categorie'] == clean_choice]
90
 
91
  if display_df.empty:
92
- st.info("Mbola tsy misy hira ato amin'ity sokajy ity.")
93
  else:
94
  for index, row in display_df.iterrows():
95
- with st.container():
96
- # Fizarana Column: Sary | Titre & Audio | WhatsApp
97
- c_img, c_desc, c_action = st.columns([0.6, 3, 1.2])
98
-
99
- with c_img:
100
- img_url = row.get('image_url', "https://via.placeholder.com/150")
101
- st.image(img_url, width=80)
102
-
103
- with c_desc:
104
- st.markdown(f"<b style='font-size:18px;'>{row['titre']}</b>", unsafe_allow_html=True)
105
- st.markdown(f"<p style='color:grey; font-size:13px; margin:0;'>{row['categorie']} • <b>{row['prix']}</b></p>", unsafe_allow_html=True)
106
-
107
- # Audio tsy misy download (HTML5 nodownload)
108
- audio_html = f'''
109
- <audio controls controlsList="nodownload" style="width:100%; height:38px; margin-top:5px;">
110
- <source src="{row['file_url']}" type="audio/mpeg">
111
- </audio>
112
- '''
113
- st.markdown(audio_html, unsafe_allow_html=True)
114
-
115
- with c_action:
116
- # Laharana WhatsApp (SOLOY NY ANAO)
117
- wa_url = f"https://wa.me/261340000000?text=Salama%20Razoa%2C%20liana%20amin'ilay%20beat%20'{row['titre']}'%20aho."
118
- st.markdown(f'<a href="{wa_url}" target="_blank" class="whatsapp-btn">💬 WhatsApp</a>', unsafe_allow_html=True)
119
-
120
- st.markdown("<hr>", unsafe_allow_html=True)
121
 
122
  # --- ADMIN PANEL ---
123
  else:
124
- st.header("🔑 Admin Dashboard")
125
  pwd = st.text_input("Password", type="password")
126
  if pwd == "admin123":
127
- t1, t2 = st.tabs(["📤 Upload Beat", "🗑️ Manage / Delete"])
128
  with t1:
129
  with st.form("up", clear_on_submit=True):
130
- titre = st.text_input("Titre-n'ny Beat")
131
  cat = st.selectbox("Sokajy", ["Afrobeat", "Afropop", "Drill", "Zouk"])
132
- prx = st.text_input("Prix (ohatra: 20.000 Ar)")
133
- aud = st.file_uploader("Upload MP3", type=["mp3"])
134
- img = st.file_uploader("Upload Artwork (Sary)", type=["jpg", "png"])
135
-
136
  if st.form_submit_button("Hampiditra"):
137
  if aud and img and TOKEN:
138
  api = HfApi()
139
  a_p = f"beats/{aud.name}"; i_p = f"images/{img.name}"
140
  api.upload_file(path_or_fileobj=aud, path_in_repo=a_p, repo_id=REPO_ID, repo_type="space", token=TOKEN)
141
  api.upload_file(path_or_fileobj=img, path_in_repo=i_p, repo_id=REPO_ID, repo_type="space", token=TOKEN)
142
-
143
  new_row = pd.DataFrame([{"titre": titre, "categorie": cat, "prix": prx,
144
  "file_url": f"https://huggingface.co/spaces/{REPO_ID}/resolve/main/{a_p}",
145
  "image_url": f"https://huggingface.co/spaces/{REPO_ID}/resolve/main/{i_p}"}])
146
  df = pd.concat([df, new_row], ignore_index=True)
147
  save_and_upload(df)
148
- st.success("Tafiditra soa aman-tsara!")
149
  st.rerun()
150
  with t2:
151
- st.write("### Fafao ny beat tsy ilaina")
152
  for idx, row in df.iterrows():
153
- col1, col2 = st.columns([4, 1])
154
- col1.write(f"🎵 **{row['titre']}** ({row['categorie']})")
155
- if col2.button("Mamafa", key=f"del_{idx}"):
156
  df = df.drop(idx)
157
  save_and_upload(df)
158
  st.rerun()
 
9
 
10
  st.set_page_config(page_title="NIRINSBEAT", layout="wide")
11
 
12
+ # --- STYLE CSS (DECORATION PRO & STABLE) ---
13
  st.markdown("""
14
  <style>
15
  @import url('https://fonts.googleapis.com/css2?family=Black+Ops+One&family=Poppins:wght@400;700&display=swap');
16
 
17
+ /* Background miaraka amin'ny haingo kely */
18
+ .stApp {
19
+ background-color: #ffffff;
20
+ background-image: radial-gradient(#6f42c10a 1px, transparent 1px);
21
+ background-size: 20px 20px;
22
+ color: #333;
23
+ font-family: 'Poppins', sans-serif;
24
+ }
25
 
26
+ /* Titre NIRINSBEAT (Mitambatra tsara) */
27
  .main-title {
28
  text-align: center;
29
  font-family: 'Black Ops One', cursive;
30
+ font-size: clamp(30px, 8vw, 60px); /* Adjust automatically to screen size */
31
  color: #6f42c1;
32
+ padding: 20px 0;
33
+ margin: 0;
34
+ letter-spacing: 2px;
35
+ white-space: nowrap; /* Mba tsy hisaraka mihitsy ny teny */
36
+ text-shadow: 2px 2px 0px #eee;
37
+ }
38
+
39
+ /* Karatra ho an'ny Beat (Manintona kokoa) */
40
+ .beat-card {
41
+ background: #fff;
42
+ border-radius: 15px;
43
+ padding: 15px;
44
+ box-shadow: 0 4px 15px rgba(111, 66, 193, 0.1);
45
+ margin-bottom: 20px;
46
+ border-left: 5px solid #6f42c1;
47
  }
48
 
49
+ /* ESORINA NY DOWNLOAD */
50
  audio::-internal-media-controls-download-button { display:none; }
51
  audio::-webkit-media-controls-enclosure { overflow:hidden; }
52
  audio::-webkit-media-controls-panel { width: calc(100% + 30px); }
53
 
54
+ /* WhatsApp Button Stylé */
55
  .whatsapp-btn {
56
+ background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
57
+ color: white !important;
58
+ border-radius: 30px;
59
+ text-align: center;
60
+ padding: 12px;
61
+ text-decoration: none;
62
+ display: block;
63
+ font-weight: bold;
64
+ transition: 0.3s;
65
+ box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3);
66
  }
67
+ .whatsapp-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(37, 211, 102, 0.4); }
68
 
69
+ hr { border: 0; border-top: 1px solid #f2f2f2; margin: 20px 0; }
 
 
 
70
  </style>
71
  """, unsafe_allow_html=True)
72
 
 
90
 
91
  df = load_data()
92
 
93
+ # --- HEADER ---
94
  st.markdown('<div class="main-title">NIRINSBEAT</div>', unsafe_allow_html=True)
95
+ st.markdown("<p style='text-align:center; color:grey; margin-top:-10px;'>High Quality Instrumentals</p>", unsafe_allow_html=True)
96
 
97
  # --- SIDEBAR ---
98
  st.sidebar.markdown("### 🔍 Filter")
99
  menu = ["🏠 Home", "🔥 Afrobeat", "🎵 Afropop", "⚡ Drill", "💃 Zouk"]
100
  choice = st.sidebar.selectbox("Sokajy", menu)
101
 
 
102
  secret = st.sidebar.text_input("Search", placeholder="Search beats...")
103
  admin_mode = False
104
  if secret == "admin-login":
 
107
  # --- CATALOGUE ---
108
  if not admin_mode:
109
  clean_choice = choice.split(" ")[1] if " " in choice else choice
 
110
  display_df = df if clean_choice == "Home" else df[df['categorie'] == clean_choice]
111
 
112
  if display_df.empty:
113
+ st.info("Mbola tsy misy hira ato.")
114
  else:
115
  for index, row in display_df.iterrows():
116
+ # Natao anaty div "beat-card" ny beat tsirairay ho haingo
117
+ st.markdown('<div class="beat-card">', unsafe_allow_html=True)
118
+ c_img, c_desc, c_action = st.columns([1, 2.5, 1.2])
119
+
120
+ with c_img:
121
+ img_url = row.get('image_url', "https://via.placeholder.com/300")
122
+ st.image(img_url, use_container_width=True)
123
+
124
+ with c_desc:
125
+ st.markdown(f"<h3 style='margin:0; color:#6f42c1;'>{row['titre']}</h3>", unsafe_allow_html=True)
126
+ st.markdown(f"<p style='color:grey; font-size:14px;'>{row['categorie']} • <b style='color:#333;'>{row['prix']}</b></p>", unsafe_allow_html=True)
127
+ audio_html = f'<audio controls controlsList="nodownload" style="width:100%; height:40px;"><source src="{row["file_url"]}" type="audio/mpeg"></audio>'
128
+ st.markdown(audio_html, unsafe_allow_html=True)
129
+
130
+ with c_action:
131
+ wa_url = f"https://wa.me/261340000000?text=Salama%20Razoa%2C%20liana%20amin'ilay%20beat%20'{row['titre']}'%20aho."
132
+ st.markdown(f'<br><a href="{wa_url}" target="_blank" class="whatsapp-btn">💬 Hividy</a>', unsafe_allow_html=True)
133
+
134
+ st.markdown('</div>', unsafe_allow_html=True)
 
 
 
 
 
 
 
135
 
136
  # --- ADMIN PANEL ---
137
  else:
138
+ st.header("🔑 Admin Panel")
139
  pwd = st.text_input("Password", type="password")
140
  if pwd == "admin123":
141
+ t1, t2 = st.tabs(["Upload", "Manage"])
142
  with t1:
143
  with st.form("up", clear_on_submit=True):
144
+ titre = st.text_input("Titre")
145
  cat = st.selectbox("Sokajy", ["Afrobeat", "Afropop", "Drill", "Zouk"])
146
+ prx = st.text_input("Prix")
147
+ aud = st.file_uploader("MP3", type=["mp3"])
148
+ img = st.file_uploader("Artwork", type=["jpg", "png"])
 
149
  if st.form_submit_button("Hampiditra"):
150
  if aud and img and TOKEN:
151
  api = HfApi()
152
  a_p = f"beats/{aud.name}"; i_p = f"images/{img.name}"
153
  api.upload_file(path_or_fileobj=aud, path_in_repo=a_p, repo_id=REPO_ID, repo_type="space", token=TOKEN)
154
  api.upload_file(path_or_fileobj=img, path_in_repo=i_p, repo_id=REPO_ID, repo_type="space", token=TOKEN)
 
155
  new_row = pd.DataFrame([{"titre": titre, "categorie": cat, "prix": prx,
156
  "file_url": f"https://huggingface.co/spaces/{REPO_ID}/resolve/main/{a_p}",
157
  "image_url": f"https://huggingface.co/spaces/{REPO_ID}/resolve/main/{i_p}"}])
158
  df = pd.concat([df, new_row], ignore_index=True)
159
  save_and_upload(df)
160
+ st.success("Tafiditra!")
161
  st.rerun()
162
  with t2:
 
163
  for idx, row in df.iterrows():
164
+ c1, c2 = st.columns([4, 1])
165
+ c1.write(f"**{row['titre']}**")
166
+ if c2.button("Delete", key=f"del_{idx}"):
167
  df = df.drop(idx)
168
  save_and_upload(df)
169
  st.rerun()