4 Коміти c6025205e4 ... 5af01c06b8

Автор SHA1 Опис Дата
  zortazert 5af01c06b8 No more line under links 2 роки тому
  jyamihud 5763c95be2 Added a file for DRM 2 роки тому
  jyamihud 532e9e3b23 Made the sources of the pages actually readable. LOL 2 роки тому
  Jeison Yehuda Amihud (Blender Dumbass) bd0d7b652d Merge branch 'master' of TrueAuraCoral/FreeCompetitors into master 2 роки тому
4 змінених файлів з 171 додано та 43 видалено
  1. 1 0
      data/issues/DRM.html
  2. 2 0
      default.css
  3. 161 40
      modules/render.py
  4. 7 3
      server.py

Різницю між файлами не показано, бо вона завелика
+ 1 - 0
data/issues/DRM.html


+ 2 - 0
default.css

@@ -75,10 +75,12 @@ th,td {
 
 a {
     color: #C648EA;
+    text-decoration: none;
 }
 
 a:hover {
     color: #DB82F4;
+    text-decoration: none;
 }
 
 img {

+ 161 - 40
modules/render.py

@@ -15,14 +15,36 @@ def html(page, json):
     # This function adds a rendering of the json into the page
 
     free = search.is_free(json)
-    page = page + "\n <h1>"
+    name = json.get("names",["Unknown"])[0]
+    page = page + """
+
+
+    <!-- For each software in the list we do mostly the same things.
+    And here it is. First we show it's name as a link to be able
+    to search Free Competitors to what is found. -->
+
+    """
+
+    page = page + "\n    <a href=\"/"+name.replace(" ", "+").lower()+"\">"
+    page = page + "\n        <h1>"
     try:
-        page = page + '\n<img src="'+ json["links"]["icon"] + '" alt="Logo" style="height:50px;">'
+        page = page + '\n            <img src="'+ json["links"]["icon"] + '" alt="[LOGO]" style="height:50px;"> <!-- The logo of the software in question.-->\n'
     except:
         pass
-    name = json.get("names",["Unknown"])[0]
-    page = page + "\n" + name 
-    page = page + "</h1>"
+
+    page = page + "            "+ name +" <!-- The title of the program -->\n"
+    page = page + "        </h1>\n    </a>\n\n"
+
+    page = page + """
+
+    <!-- Next there is a short paragraph about the program.
+    ( Often Copypasted from some official page about it ).
+    Which means, it may contain the terrible words "Open Source"
+    that hide the fact that Free Software is about User Freedom
+    first of all. So we are trying to link to a special page on
+    GNU.ORG if such a thing is found -->
+
+    """
         
     # Few words about it
     comment = json.get("comment","")
@@ -34,9 +56,10 @@ def html(page, json):
         if where == -1:
             where = comment.lower().find("open-source")
         ops = comment[where:where+11]
-        comment = comment.replace(ops,
-        "<a href=\"https://www.gnu.org/philosophy/open-source-misses-the-point.en.html\">"+ops+"</a>")
-    page = page + "<p>"+comment+"</p>"
+        if ops:
+            comment = comment.replace(ops,
+                                      "<a href=\"https://www.gnu.org/philosophy/open-source-misses-the-point.en.html\">"+ops+"</a>")
+    page = page + "\n    <p>\n        "+comment+"\n    </p>\n\n"
 
     # I want to show nothing else from if it's proprietary
     issues_files = list(os.listdir("data/issues"))
@@ -59,21 +82,26 @@ def html(page, json):
     
     # Links
 
-    # <table>
-    #  <tr>
-    #   <th>Company</th>
-    #  <th>Contact</th>
-    # <th>Country</th>
-    #</tr>
+    page = page + """
+    <!-- To organize the buttons with the main links we are using
+    a table. But since I don't know what CSS file the maintainer
+    will choose. And I want the table to be invisible. I insert here
+    a bit of CSS code. -->
+
+    """
 
     page = page + """
     <style>
-    table, th, td {
-    border-right:none;
-    border-left:none;
-    border-bottom:none;
-    border-top:none
-    }</style>
+        table, th, td {
+        border-right:none;
+        border-left:none;
+        border-bottom:none;
+        border-top:none
+    }
+    </style>
+
+    <!-- And now the table itself. -->
+    
     """
     
     page = page + "<table><tr>"
@@ -84,13 +112,26 @@ def html(page, json):
             continue
         link = links[website]
         page = page + """
-        <th><form action=\""""+link+"""\">
-            <button title=\""""+link+"""\" type="submit">"""+linksfilter.get(website,website).upper()+"""</button>
-        </form></th>
+        
+        <!-- Here's how to do a simple button -->
+
+        <th>
+            <form action=\""""+link+"""\"> <!-- You make a form with a link -->
+            <button title=\""""+link+"""\" type="submit">"""+linksfilter.get(website,website).upper()+"""</button> <!-- And you activare that form with a button -->
+            </form>
+        </th>
        """
 
     page = page + "</tr></table>"
 
+    page = page + """
+
+    <!-- Details are those little collapsable things that I like to
+    use very much. It's very simple really. Just read the code
+    carefully and you will get it -->
+
+    """
+    
     # Details
 
     categories = {"generic_name":"Features",
@@ -128,8 +169,8 @@ def html(page, json):
             matchtext = "<i>( "+str(matches)+" )</i>"
         else:
             matchtext = ""
-        page = page + "<details>"
-        page = page +"<summary>"+categories[c]+": "+matchtext+"</summary>"
+        page = page + "\n\n    <details>"
+        page = page +"\n        <summary>"+categories[c]+": "+matchtext+"</summary>"
 
         for i in l:
             matchtext = ""
@@ -138,10 +179,29 @@ def html(page, json):
                 matchtext = "&nbsp;&nbsp;&nbsp;&nbsp;<i>( match )</i> "
             if i+".html" in allfiles:
                 datapage = open("data/"+folder+"/"+i+".html")
-                page = page + "<details><summary>&nbsp;&nbsp;&nbsp;&nbsp;"+matchtext+i+"</summary><span><p>"+datapage.read()+"<p></span></details>"
+                page = page + """
+
+            <!-- Just so happened that about \""""+i+"""\" we had a file
+            in data/"""+folder+""" folder. So why not make a detail inside a detail,
+            a detail-sception, so to speak. And add the text of explanation into it. -->
+
+            """
+                page = page + "<details>\n"
+                page = page + "            <summary>&nbsp;&nbsp;&nbsp;&nbsp;"+matchtext+i+"</summary>\n"
+                page = page + "            <span>\n                <p>\n"
+                page = page + "                    " + datapage.read()+"\n"
+                page = page + "                </p>\n            </span>\n            </details>"
             else:
-                page = page + "&nbsp;&nbsp;&nbsp;&nbsp;"+matchtext+i+"<br>"
-        page = page + "<span><br></span></details>"
+                page = page + "\n            <span>&nbsp;&nbsp;&nbsp;&nbsp;"+matchtext+i+"</span>\n    <br>\n"
+        page = page + """
+        
+        <!-- Just a tiny space after all the spans. So no to feel
+        too crowded, so to speak -->
+        <span><br></span>
+
+    </details>
+
+        """
         
     
     return page
@@ -150,7 +210,17 @@ def suggestions(page, json):
 
     # This function will render suggestions
 
-    page = page + "<h1>Free Competitors:</h1>"
+    page = page + """
+    
+    <!-- ===========================================================
+
+    This is where ther actual competitors are starting to show!!!
+
+    ============================================================ -->
+    
+    <h1>Free Competitors:</h1>
+
+    """
     
     found = search.suggest(json)
 
@@ -170,11 +240,28 @@ def suggestions(page, json):
             frac = 0
 
         if frac < 20 and not more: # Below 40% features match
-            page = page + """<hr><details>
-            <summary><h1 title="Click to show more / less.">Problematic Competitors:</h1></summary>"""
+            page = page + """
+            
+            <!-- Sometimes the suggestion is not very good. Below 40%
+            of suggestion score. But it still kind of valid. So we
+            want to put it into the page. Only when the user clicks
+            something. Why not using the same old details? -->
+
+            <hr>
+            <details>
+                <summary><h1 title="Click to show more / less.">Problematic Competitors:</h1></summary>
+
+            """
             more = True
+
+        page = page +"""
         
-        page = page + "<hr><br>Suggestion score: " + str(frac) + "%"
+        <hr>
+<!-- ================================================================== -->
+
+        """
+            
+        page = page + "<br>Suggestion score: " + str(frac) + "%"
         page = html(page, i[-1])
         
     if more:
@@ -186,12 +273,21 @@ def search_widget(page, address):
     # Adds a search bar to the page
 
     page = page + """
+    <!-- Search widget! This widget makes it possible to implement
+    a search feature without using a single line of JavaScript code.
+    In HTML, there is an input field that we can use. If we pare it
+    with a button into a <form>, we can get a button that activates
+    the search. -->
+
     <form action="""
     page = page + address
     page = page + """search method="GET">
     <input type="text" name="item" class="search" placeholder="Name of Software">
     <button type="submit">Search</button>
     </form>
+
+    <!-- And that's it for the search widget -->
+
     """
     #page = page.format(ADDRESS)
     
@@ -201,15 +297,31 @@ def source_code_link(page):
 
     # Adds a source code link
 
-    page = page + "<br><br><hr><p>This website is under the GNU AGPL license.</p>"
     page = page + """
+    
+    <!-- This the the footer of every page -->
+    
+    <br>
+    <br>
+
+    <hr>
+
+    <p>This website is under the GNU AGPL license.</p>
+    
+    <!-- As always I want to add a bit of CSS to make tables
+    invisible -->
+
     <style>
-    table, th, td {
-    border-right:none;
-    border-left:none;
-    border-bottom:none;
-    border-top:none
-    }</style>
+        table, th, td {
+        border-right:none;
+        border-left:none;
+        border-bottom:none;
+        border-top:none
+    }
+    </style>
+    
+    <!-- This is self explanatory ( if you read most of the page ) -->
+
     <table><tr>
 
         <th><form action=https://notabug.org/jyamihud/FreeCompetitors>
@@ -230,7 +342,16 @@ def source_code_link(page):
     
         <th><form action=https://notabug.org/jyamihud/FreeCompetitors/issues/24>
             <button title="Report a mistake in data about software." type="submit">MISTAKE?</button>
-        </form></th></tr></table><br><br>
+        </form></th></tr>
+    
+    </table>
+
+    <br>
+    <br>
+
+    <!-- And this was the page of Free Competitors. No Javascript.
+    No crap. No trackers. No nothing. And still works. Take that
+    Google!!! -->
     
 
        """

+ 7 - 3
server.py

@@ -88,10 +88,14 @@ class handler(BaseHTTPRequestHandler):
             self.send_header('Content-type', 'text/html')
         self.end_headers()
 
-    def send(self, text):
-        text = str(text)
+    def send(self, textin):
+        textin = str(textin)
         csstext = '<link media="all" href="'+CSS+'" type="text/css" rel="stylesheet" />'
-        text = '<head>'+csstext+'</head><body>'+text+'</body>'
+        text = "<!-- Welcome to Free Competitors Page Source!!!--> \n\n"
+        text = text + "<!-- Let's add some CSS, you can edit 'config.json' to change it. -->\n"
+        text = text + '<head>'+csstext+'</head>\n\n'
+        text = text + "<!-- Now the body. The main part of the page, so to speak. -->\n"
+        text = text + '<body>\n\n'+textin+'\n\n</body>'