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

Proposed by kaputtnik
Status: Merged
Merged at revision: 381
Proposed branch: lp:~franku/widelands-website/added-css-link-classes
Merge into: lp:widelands-website
Diff against target: 121 lines (+53/-12)
2 files modified
mainpage/templatetags/wl_markdown.py (+18/-10)
media/css/base.css (+35/-2)
To merge this branch: bzr merge lp:~franku/widelands-website/added-css-link-classes
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+245346@code.launchpad.net

Description of the change

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 :-)

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

Great, now in merge requests!! Yay!

Merged and deployed.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
102 external = False102 external = False
103 break103 break
104 if external:104 if external:
105 return "external"105 return { 'class': "externalLink", 'title': "This link refers to outer space" }
106
107 if "/profile/" in (tag["href"]):
108 return { 'class': "userLink", 'title': "This link refers to a userpage" }
109
106110
107 if check_for_missing_wikipages and href.startswith("/wiki"):111 if check_for_missing_wikipages and href.startswith("/wiki/"):
112
108 # Check for missing wikilink /wiki/PageName[/additionl/stuff]113 # Check for missing wikilink /wiki/PageName[/additionl/stuff]
109 # Using href because we need cAsEs here114 # Using href because we need cAsEs here
110 pn = tag["href"][6:].split('/',1)[0]115 pn = tag["href"][6:].split('/',1)[0]
111116
112 if not len(pn): # Wiki root link is not a page117 if not len(pn): # Wiki root link is not a page
113 return None118 return { 'class': "wrongLink", 'title': "This Link misses an articlename"}
114119
115 # Wiki special pages are also not counted120 # Wiki special pages are also not counted
116 if pn in ["list","search","history","feeds","observe","edit" ]:121 if pn in ["list","search","history","feeds","observe","edit" ]:
117 return None122 return { 'class': "specialLink" }
118123
124 # article missing (or misspelled)
119 if Article.objects.filter(title=pn).count() == 0:125 if Article.objects.filter(title=pn).count() == 0:
120 return "missing"126 return { 'class': "missingLink", 'title': "This Link is misspelled or missing. Click to create it anyway." }
121127
122 return None128 return None
123129
@@ -178,11 +184,13 @@
178 soup = BeautifulSoup(unicode(soup)) # What a waste of cycles :(184 soup = BeautifulSoup(unicode(soup)) # What a waste of cycles :(
179185
180 # We have to go over this to classify links186 # We have to go over this to classify links
187
181 for tag in soup.findAll("a"):188 for tag in soup.findAll("a"):
182 rv = _classify_link(tag)189 rv = _classify_link(tag)
183 if rv:190 if rv:
184 tag["class"] = rv191 for attribute in rv.iterkeys():
185192 tag[attribute] = rv.get(attribute)
193
186 return unicode(soup)194 return unicode(soup)
187195
188196
189197
=== 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 @@
1/* Common */1/*++++++++++++++++++*/
2/* Common */
3/*------------------*/
4/* Effects to all */
5/* part of website */
6/*++++++++++++++++++*/
27
3body {8body {
4 background-color: #e9c78a;9 background-color: #e9c78a;
@@ -10,20 +15,48 @@
10 text-shadow: #000000 1px 1px 0px;15 text-shadow: #000000 1px 1px 0px;
11}16}
1217
18/*+++++++++++++++++++++++++*/
19/* Links and special links */
20/*+++++++++++++++++++++++++*/
21
13a img {22a img {
14 border: none;23 border: none;
15}24}
1625
17a {26a {
18 text-decoration: none;27 text-decoration: none;
19 color: #ffffee;28 color: rgba(254, 234, 138, 1);
20 font-weight: bold;29 font-weight: bold;
21}30}
2231
32.blogEntry a {
33 font-weight: normal;
34}
35
36a:visited {
37 color: #C8BE93;
38}
39
40a.missingLink {
41 color: yellow;
42}
43
44a.externalLink:after {
45 content: " "url("../img/replied.png");
46}
47
23a:hover {48a:hover {
24 color: #181;49 color: #181;
25}50}
2651
52/* We put this after a:hover */
53/* to prevend the hover style */
54/* for this link */
55
56a.wrongLink {
57 color: rgb(255, 117, 0);
58}
59
27a.invertedColor {60a.invertedColor {
28 color: #181;61 color: #181;
29}62}

Subscribers

People subscribed via source and target branches