Remove HTML template and simplify API response with static home page
This commit is contained in:
@@ -1,226 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Cats of Mastodon! - Mahdium</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Atma:wght@300;400;500;600;700&display=swap');
|
||||
body {
|
||||
font-family: "Atma", system-ui;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
background-color: #1e1e1e;
|
||||
color: #e0e0e0;
|
||||
margin: 0;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.mastodon-title {
|
||||
font-size: 2.5em;
|
||||
margin-bottom: 10px;
|
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.welcome-message {
|
||||
margin-bottom: 20px;
|
||||
font-size: 1.2em;
|
||||
line-height: 1.5;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.welcome-message span {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.post-container {
|
||||
background-color: #282828;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
|
||||
padding: 20px;
|
||||
width: 90%;
|
||||
max-width: 500px;
|
||||
text-align: center;
|
||||
transition: transform 0.2s ease-in-out;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.post-container:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.post-title-inner {
|
||||
margin-bottom: 10px;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
color: #ffb347;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.cat-text {
|
||||
color: #bbdefb;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.post-image {
|
||||
width: 100%;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 15px;
|
||||
object-fit: cover;
|
||||
max-height: 500px;
|
||||
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.post-image.loading {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.image-container {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.image-loading-spinner {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
border: 4px solid #f3f3f3;
|
||||
border-top: 4px solid #6364ff;
|
||||
border-radius: 50%;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
.post-image.loading + .image-loading-spinner {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.button-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mastodon-button,
|
||||
.neutral-button {
|
||||
background-color: #404040;
|
||||
color: #e0e0e0;
|
||||
border: none;
|
||||
padding: 12px 18px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
transition: background-color 0.3s ease, transform 0.2s ease-in-out;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.mastodon-button {
|
||||
background-color: #6364ff;
|
||||
}
|
||||
|
||||
.mastodon-button:hover {
|
||||
background-color: #5253e0;
|
||||
transform: scale(1.03);
|
||||
}
|
||||
|
||||
.neutral-button:hover {
|
||||
background-color: #505050;
|
||||
transform: scale(1.03);
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
display: none;
|
||||
border: 6px solid #f3f3f3;
|
||||
border-top: 6px solid #6364ff;
|
||||
border-radius: 50%;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
.post-container.loading .loading-spinner {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.post-container.loading .post-image,
|
||||
.post-container.loading .button-container,
|
||||
.post-container.loading .post-title-inner {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
font-size: 0.8em;
|
||||
color: #909090;
|
||||
width: 90%;
|
||||
max-width: 500px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.footer a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.footer a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.footer-button {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2 class="mastodon-title">Cats of Mastodon!</h2>
|
||||
<p class="welcome-message">Welcome to Daily Catventures! </br> Get your daily dose of purr-fectly adorable feline fun! <span>✨</span><br>Posts gathered across Mastodon 🤝</p>
|
||||
<div class="post-container">
|
||||
<div class="post-content">
|
||||
<div class="post-title-inner">
|
||||
<span class="user-name">{{ .DisplayName }}</span><span class="cat-text">'s cat!</span>
|
||||
</div>
|
||||
<div class="image-container">
|
||||
<img class="post-image" src="{{ .MediaAttachment.RemoteUrl }}" alt="Cat Photo">
|
||||
<div class="image-loading-spinner"></div>
|
||||
</div>
|
||||
<div class="button-container">
|
||||
<a class="mastodon-button" href="{{ .URL }}" target="_blank">View on Mastodon</a>
|
||||
<button class="neutral-button" onclick="window.location.reload()">Show me another cat!</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<span>© 2024 Mahdium</span>
|
||||
<a href="https://mahdium.ir" class="footer-button">mahdium.ir</a>
|
||||
<a href="https://gitlab.com/mahdium/cats-of-mastodon-telegram-bot" class="footer-button">Source Code</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -16,7 +16,5 @@ func NewApiEndpointHandler(appContext *internal.AppContext) *ApiEndpointHandler
|
||||
}
|
||||
|
||||
func (appContext *ApiEndpointHandler) GetRandomPost(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"post": appContext.AppContext.PostService.GetRandomPost(),
|
||||
})
|
||||
c.JSON(200,appContext.AppContext.PostService.GetRandomPost())
|
||||
}
|
@@ -17,11 +17,5 @@ func NewMainPageHandler(appContext *internal.AppContext) *MainPageHandler {
|
||||
}
|
||||
|
||||
func (appContext *MainPageHandler) HomePageHandler(c *gin.Context) {
|
||||
randomPost := appContext.AppContext.PostService.GetRandomPost()
|
||||
|
||||
c.HTML(200, "index.tmpl", gin.H{
|
||||
"DisplayName": randomPost.Account.DisplayName,
|
||||
"MediaAttachment": randomPost.Attachments[0],
|
||||
"URL": randomPost.Url,
|
||||
})
|
||||
c.Data(200, "text/html; charset=utf-8", []byte(`<p>Welcome to CatsOfMastodonBotGo - <a href="https://git.mahdium.ir/mahdium/CatsOfMastodon">The main project</a>, writen in C# is available at that link - This is only my attempt to port it to Go for learning purposes</p>`))
|
||||
}
|
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
func SetupRouter(r *gin.Engine, appContext *internal.AppContext) *gin.Engine {
|
||||
|
||||
r.LoadHTMLGlob("templates/*")
|
||||
|
||||
adminDashboardHandler := handlers_admin.NewAdminDashboardHandler(appContext)
|
||||
homePageHandler := handlers_home.NewMainPageHandler(appContext)
|
||||
|
Reference in New Issue
Block a user