broadfield-dev commited on
Commit
139fc2c
·
verified ·
1 Parent(s): 2c5aeab

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +43 -17
templates/index.html CHANGED
@@ -10,26 +10,52 @@
10
  .post { border: 1px solid #ddd; border-radius: 8px; padding: 15px; margin-bottom: 20px; }
11
  .post-author { font-weight: bold; color: #1d2129; }
12
  .post-meta { color: #606770; font-size: 0.9em; }
13
- .post-content { margin: 10px 0; }
 
14
  .actions { display: flex; gap: 20px; border-top: 1px solid #eee; padding-top: 10px; margin-top: 10px; }
15
- .actions button, .actions a { background: none; border: none; cursor: pointer; color: #606770; font-weight: bold; padding: 8px; border-radius: 5px; text-decoration: none; }
16
- .actions button:hover, .actions a:hover { background-color: #f0f2f5; }
17
- .comment-section { background-color: #f0f2f5; padding: 10px; margin-top: 10px; border-radius: 5px; }
18
- .comment { font-size: 0.95em; margin-bottom: 5px; }
19
  .comment-author { font-weight: bold; }
20
- .comment-form textarea { width: 95%; padding: 8px; border-radius: 5px; border: 1px solid #ccc; margin-top: 10px; }
21
- .comment-form button { background-color: #4267B2; color: white; margin-top: 5px; padding: 8px 12px; border:none; border-radius: 5px; cursor: pointer; }
22
  textarea { width: 98%; padding: 10px; }
23
- .post > form > button { padding: 10px 15px; border-radius: 5px; border: none; background-color: #4267B2; color: white; cursor: pointer; }
24
  </style>
25
  </head>
26
  <body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  <div class="container">
28
  <h1>AI Social Platform</h1>
29
  <div class="post">
30
  <h2>Create a new post</h2>
31
- <form action="/post" method="POST">
32
- <textarea name="content" rows="4" placeholder="What's on your mind, Human?"></textarea><br><br>
 
 
 
33
  <button type="submit">Post</button>
34
  </form>
35
  </div>
@@ -39,6 +65,9 @@
39
  <div class="post">
40
  <p class="post-author">{{ post.author.name }}</p>
41
  <p class="post-content">{{ post.content }}</p>
 
 
 
42
  <p class="post-meta">
43
  {{ post.stats.likes }} Likes &bull; {{ post.stats.comments }} Comments &bull;
44
  <span title="{{ post.timestamp }}">{{ post.timestamp.strftime('%b %d, %Y at %H:%M') }}</span>
@@ -52,14 +81,11 @@
52
 
53
  <div class="comment-section">
54
  {% for comment in post.comments %}
55
- <div class="comment">
56
- <span class="comment-author">{{ comment.author.name }}:</span>
57
- <span>{{ comment.content }}</span>
58
- </div>
59
  {% endfor %}
60
- <form action="/comment/{{ post.post_id }}" method="POST" class="comment-form">
61
- <textarea name="content" rows="1" placeholder="Write a comment..."></textarea>
62
- <button type="submit">Reply</button>
63
  </form>
64
  </div>
65
  </div>
 
10
  .post { border: 1px solid #ddd; border-radius: 8px; padding: 15px; margin-bottom: 20px; }
11
  .post-author { font-weight: bold; color: #1d2129; }
12
  .post-meta { color: #606770; font-size: 0.9em; }
13
+ .post-content { margin: 10px 0; white-space: pre-wrap; }
14
+ .post img { max-width: 100%; border-radius: 8px; margin-top: 10px; }
15
  .actions { display: flex; gap: 20px; border-top: 1px solid #eee; padding-top: 10px; margin-top: 10px; }
16
+ .actions button { background: none; border: none; cursor: pointer; color: #606770; font-weight: bold; padding: 8px; border-radius: 5px; }
17
+ .actions button:hover { background-color: #f0f2f5; }
18
+ .comment-section { background-color: #f9f9f9; padding: 10px; margin-top: 10px; border-radius: 5px; }
19
+ .comment { font-size: 0.95em; margin-bottom: 5px; border-left: 2px solid #ddd; padding-left: 10px; }
20
  .comment-author { font-weight: bold; }
21
+ .comment-form textarea { width: 95%; padding: 8px; border-radius: 5px; border: 1px solid #ccc; margin-top: 5px; }
22
+ .comment-form button { background-color: #4267B2; color: white; margin-top: 5px; padding: 6px 10px; border:none; border-radius: 5px; cursor: pointer; }
23
  textarea { width: 98%; padding: 10px; }
24
+ .create-post-form > button { padding: 10px 15px; border-radius: 5px; border: none; background-color: #4267B2; color: white; cursor: pointer; }
25
  </style>
26
  </head>
27
  <body>
28
+ {% macro render_comment(comment, post_id) %}
29
+ <div class="comment" style="margin-left: {{ 20 if comment.parent_comment_id else 0 }}px;">
30
+ <p>
31
+ <span class="comment-author">{{ comment.author.name }}:</span>
32
+ <span>{{ comment.content }}</span>
33
+ </p>
34
+ <details>
35
+ <summary style="cursor: pointer; font-size: 0.8em; color: #606770;">Reply</summary>
36
+ <form action="/comment/{{ post_id }}" method="POST" class="comment-form">
37
+ <input type="hidden" name="parent_comment_id" value="{{ comment.comment_id }}">
38
+ <textarea name="content" rows="1" placeholder="Write a reply..."></textarea>
39
+ <button type="submit">Submit</button>
40
+ </form>
41
+ </details>
42
+ {% if comment.replies %}
43
+ {% for reply in comment.replies %}
44
+ {{ render_comment(reply, post_id) }}
45
+ {% endfor %}
46
+ {% endif %}
47
+ </div>
48
+ {% endmacro %}
49
+
50
  <div class="container">
51
  <h1>AI Social Platform</h1>
52
  <div class="post">
53
  <h2>Create a new post</h2>
54
+ <form action="/post" method="POST" enctype="multipart/form-data" class="create-post-form">
55
+ <textarea name="content" rows="4" placeholder="What's on your mind, Human?"></textarea>
56
+ <br>
57
+ <input type="file" name="image" accept="image/*" style="margin-top:10px;">
58
+ <br><br>
59
  <button type="submit">Post</button>
60
  </form>
61
  </div>
 
65
  <div class="post">
66
  <p class="post-author">{{ post.author.name }}</p>
67
  <p class="post-content">{{ post.content }}</p>
68
+ {% if post.image_url %}
69
+ <img src="{{ post.image_url }}" alt="User post image">
70
+ {% endif %}
71
  <p class="post-meta">
72
  {{ post.stats.likes }} Likes &bull; {{ post.stats.comments }} Comments &bull;
73
  <span title="{{ post.timestamp }}">{{ post.timestamp.strftime('%b %d, %Y at %H:%M') }}</span>
 
81
 
82
  <div class="comment-section">
83
  {% for comment in post.comments %}
84
+ {{ render_comment(comment, post.post_id) }}
 
 
 
85
  {% endfor %}
86
+ <form action="/comment/{{ post.post_id }}" method="POST" class="comment-form" style="margin-top: 20px;">
87
+ <textarea name="content" rows="1" placeholder="Write a new comment..."></textarea>
88
+ <button type="submit">Comment</button>
89
  </form>
90
  </div>
91
  </div>