3 次程式碼提交

作者 SHA1 備註 提交日期
  Carlos Hernandez 4746bfb50f Fade articles content 3 年之前
  Carlos Hernandez 8604219fd5 Find way to display articles content from API 3 年之前
  Carlos Hernandez f3b526ab63 Find way to display articles content from API 3 年之前
共有 4 個文件被更改,包括 36 次插入12 次删除
  1. 0
    3
      .gitignore
  2. 3
    3
      Files-API/files_api.py
  3. 6
    5
      app_template/www/articles.html
  4. 27
    1
      app_template/www/css/main.css

+ 0
- 3
.gitignore 查看文件

@@ -1,6 +1,3 @@
1
-# Local
2
-.vscode
3
-
4 1
 # Byte-compiled / optimized / DLL files
5 2
 __pycache__/
6 3
 *.py[cod]

+ 3
- 3
Files-API/files_api.py 查看文件

@@ -1,5 +1,5 @@
1 1
 import os
2
-from flask import Flask, send_from_directory, jsonify, current_app
2
+from flask import Flask, send_from_directory, jsonify
3 3
 from flask_cors import CORS, cross_origin
4 4
 
5 5
 
@@ -20,8 +20,8 @@ def send_text_file(article):
20 20
 @cross_origin(origin="localhost", headers=["Content-Type", "Authorization"])
21 21
 def list_files():
22 22
     files = list()
23
-    for filename in os.listdir(os.path.join(current_app.root_path, "articles")):
24
-        path = os.path.join(current_app.root_path, "articles", filename)
23
+    for filename in os.listdir("articles"):
24
+        path = os.path.join("articles", filename)
25 25
         if os.path.isfile(path):
26 26
             files.append(filename)
27 27
     return jsonify(files)

+ 6
- 5
app_template/www/articles.html 查看文件

@@ -62,10 +62,12 @@
62 62
 						for (element of articles) {
63 63
 							axios.get(`http://localhost:5000/articles/${element}`)
64 64
 								.then(response => {
65
-									let articlesHeading = document.querySelector("#articles-heading");
66
-									let articleElm = document.createElement("pre");
67
-									articleElm.textContent = response.data;
68
-									articlesHeading.appendChild(articleElm);
65
+									let articlesHeading = document.querySelector("#articles-heading").parentElement;
66
+									let articleDiv = document.createElement("button");
67
+									articleDiv.textContent = response.data;
68
+
69
+									articleDiv.classList.add("m-5", "article-content");
70
+									articlesHeading.appendChild(articleDiv);
69 71
 								})
70 72
 								.catch(error => console.error(error));
71 73
 						}
@@ -121,7 +123,6 @@
121 123
 										<div class="core">
122 124
 											<i class="icon-columns to-animate-2"></i>
123 125
 											<div class="fh5co-post to-animate">
124
-												<!-- <h3 async onload="fetchArticle();">Articles</h3> -->
125 126
 												<h3 id="articles-heading">Articles</h3>
126 127
 											</div>
127 128
 										</div>

+ 27
- 1
app_template/www/css/main.css 查看文件

@@ -13,4 +13,30 @@ a img{
13 13
     animation-fill-mode: forwards;
14 14
     text-decoration: none;
15 15
     color: white;
16
-}
16
+}
17
+
18
+.article-content {
19
+    margin-top: 10px;
20
+    margin-bottom: 10px;
21
+    padding: 5px;
22
+    border: 1px solid #777;
23
+    max-height: 300px;
24
+    overflow: hidden;
25
+    text-overflow: ellipsis;
26
+    content: "";
27
+    position: relative;
28
+}
29
+
30
+button.article-content {
31
+    background: none;
32
+}
33
+
34
+.article-content:before {
35
+    content: '';
36
+    width: 100%;
37
+    height: 100%;
38
+    position: absolute;
39
+    left: 0;
40
+    top: 0;
41
+    background: linear-gradient(transparent 150px, white);
42
+}