← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~franku/widelands-website/added-css-link-classes into lp:widelands-website

 

kaputtnik has proposed merging lp:~franku/widelands-website/added-css-link-classes into lp:widelands-website.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~franku/widelands-website/added-css-link-classes/+merge/245346

This branch adds css-classes for different types of links. See https://wl.widelands.org/forum/topic/1617/ for screenshots and discussion about that.

Please take a careful look at my coding in mainpage/templatetags/wl_markdown.py

I am not sure if a dict is a correct/normal returnvalue. But this will make the code more readable and is flexible in use.

If you need some content (wikiarticles/forumposts) i could provide a dev.db file.

Thanks for pay attention :-)
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~franku/widelands-website/added-css-link-classes into lp:widelands-website.
=== modified file 'mainpage/templatetags/wl_markdown.py'
--- mainpage/templatetags/wl_markdown.py	2011-11-13 15:47:39 +0000
+++ mainpage/templatetags/wl_markdown.py	2014-12-23 17:25:54 +0000
@@ -102,22 +102,28 @@
                 external = False
                 break
         if external:
-            return "external"
+            return { 'class': "externalLink", 'title': "This link refers to outer space" }
+    
+    if "/profile/" in (tag["href"]):
+        return { 'class': "userLink", 'title': "This link refers to a userpage" }
+       
 
-    if check_for_missing_wikipages and href.startswith("/wiki"):
+    if check_for_missing_wikipages and href.startswith("/wiki/"):
+        
         # Check for missing wikilink /wiki/PageName[/additionl/stuff]
         # Using href because we need cAsEs here
         pn = tag["href"][6:].split('/',1)[0]
-
+        
         if not len(pn): # Wiki root link is not a page
-            return None
-
+            return { 'class': "wrongLink", 'title': "This Link misses an articlename"}
+            
         # Wiki special pages are also not counted
         if pn in ["list","search","history","feeds","observe","edit" ]:
-            return None
-
+            return { 'class': "specialLink" }
+        
+        # article missing (or misspelled)
         if Article.objects.filter(title=pn).count() == 0:
-            return "missing"
+            return { 'class': "missingLink", 'title': "This Link is misspelled or missing. Click to create it anyway." }
 
     return None
 
@@ -178,11 +184,13 @@
     soup = BeautifulSoup(unicode(soup)) # What a waste of cycles :(
 
     # We have to go over this to classify links
+    
     for tag in soup.findAll("a"):
         rv = _classify_link(tag)
         if rv:
-            tag["class"] = rv
-
+            for attribute in rv.iterkeys():
+                tag[attribute] = rv.get(attribute)
+    
     return unicode(soup)
 
 

=== modified file 'media/css/base.css'
--- media/css/base.css	2014-12-20 18:49:15 +0000
+++ media/css/base.css	2014-12-23 17:25:54 +0000
@@ -1,4 +1,9 @@
-/* Common */
+/*++++++++++++++++++*/
+/*      Common      */
+/*------------------*/
+/*  Effects to all  */
+/* part of website  */
+/*++++++++++++++++++*/
 
 body {
 	background-color: #e9c78a;
@@ -10,20 +15,48 @@
 	text-shadow: #000000 1px 1px 0px;
 }
 
+/*+++++++++++++++++++++++++*/
+/* Links and special links */
+/*+++++++++++++++++++++++++*/
+
 a img {
 	border: none;
 }
 
 a {
 	text-decoration: none;
-	color: #ffffee;
+	color: rgba(254, 234, 138, 1);
 	font-weight: bold;
 }
 
+.blogEntry a {
+	font-weight: normal;
+}
+
+a:visited {
+  color: #C8BE93;
+}
+
+a.missingLink {
+	color: yellow;
+}
+
+a.externalLink:after {
+	content: " "url("../img/replied.png");
+}
+
 a:hover {
 	color: #181;
 }
 
+/* We put this after a:hover  */
+/* to prevend the hover style */
+/* for this link              */
+
+a.wrongLink {
+	color: rgb(255, 117, 0);
+}
+
 a.invertedColor {
 	color: #181;
 }


Follow ups