3 Commits

Author SHA1 Message Date
  Carlos Hernandez 4746bfb50f Fade articles content 3 years ago
  Carlos Hernandez 8604219fd5 Find way to display articles content from API 3 years ago
  Carlos Hernandez f3b526ab63 Find way to display articles content from API 3 years ago
4 changed files with 36 additions and 12 deletions
  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 View File

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

+ 3
- 3
Files-API/files_api.py View File

1
 import os
1
 import os
2
-from flask import Flask, send_from_directory, jsonify, current_app
2
+from flask import Flask, send_from_directory, jsonify
3
 from flask_cors import CORS, cross_origin
3
 from flask_cors import CORS, cross_origin
4
 
4
 
5
 
5
 
20
 @cross_origin(origin="localhost", headers=["Content-Type", "Authorization"])
20
 @cross_origin(origin="localhost", headers=["Content-Type", "Authorization"])
21
 def list_files():
21
 def list_files():
22
     files = list()
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
         if os.path.isfile(path):
25
         if os.path.isfile(path):
26
             files.append(filename)
26
             files.append(filename)
27
     return jsonify(files)
27
     return jsonify(files)

+ 6
- 5
app_template/www/articles.html View File

62
 						for (element of articles) {
62
 						for (element of articles) {
63
 							axios.get(`http://localhost:5000/articles/${element}`)
63
 							axios.get(`http://localhost:5000/articles/${element}`)
64
 								.then(response => {
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
 								.catch(error => console.error(error));
72
 								.catch(error => console.error(error));
71
 						}
73
 						}
121
 										<div class="core">
123
 										<div class="core">
122
 											<i class="icon-columns to-animate-2"></i>
124
 											<i class="icon-columns to-animate-2"></i>
123
 											<div class="fh5co-post to-animate">
125
 											<div class="fh5co-post to-animate">
124
-												<!-- <h3 async onload="fetchArticle();">Articles</h3> -->
125
 												<h3 id="articles-heading">Articles</h3>
126
 												<h3 id="articles-heading">Articles</h3>
126
 											</div>
127
 											</div>
127
 										</div>
128
 										</div>

+ 27
- 1
app_template/www/css/main.css View File

13
     animation-fill-mode: forwards;
13
     animation-fill-mode: forwards;
14
     text-decoration: none;
14
     text-decoration: none;
15
     color: white;
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
+}