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

Proposed by kaputtnik on 2014-12-23
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 2014-12-23 Approve on 2014-12-27
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.
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
1=== modified file 'mainpage/templatetags/wl_markdown.py'
2--- mainpage/templatetags/wl_markdown.py 2011-11-13 15:47:39 +0000
3+++ mainpage/templatetags/wl_markdown.py 2014-12-23 17:25:54 +0000
4@@ -102,22 +102,28 @@
5 external = False
6 break
7 if external:
8- return "external"
9+ return { 'class': "externalLink", 'title': "This link refers to outer space" }
10+
11+ if "/profile/" in (tag["href"]):
12+ return { 'class': "userLink", 'title': "This link refers to a userpage" }
13+
14
15- if check_for_missing_wikipages and href.startswith("/wiki"):
16+ if check_for_missing_wikipages and href.startswith("/wiki/"):
17+
18 # Check for missing wikilink /wiki/PageName[/additionl/stuff]
19 # Using href because we need cAsEs here
20 pn = tag["href"][6:].split('/',1)[0]
21-
22+
23 if not len(pn): # Wiki root link is not a page
24- return None
25-
26+ return { 'class': "wrongLink", 'title': "This Link misses an articlename"}
27+
28 # Wiki special pages are also not counted
29 if pn in ["list","search","history","feeds","observe","edit" ]:
30- return None
31-
32+ return { 'class': "specialLink" }
33+
34+ # article missing (or misspelled)
35 if Article.objects.filter(title=pn).count() == 0:
36- return "missing"
37+ return { 'class': "missingLink", 'title': "This Link is misspelled or missing. Click to create it anyway." }
38
39 return None
40
41@@ -178,11 +184,13 @@
42 soup = BeautifulSoup(unicode(soup)) # What a waste of cycles :(
43
44 # We have to go over this to classify links
45+
46 for tag in soup.findAll("a"):
47 rv = _classify_link(tag)
48 if rv:
49- tag["class"] = rv
50-
51+ for attribute in rv.iterkeys():
52+ tag[attribute] = rv.get(attribute)
53+
54 return unicode(soup)
55
56
57
58=== modified file 'media/css/base.css'
59--- media/css/base.css 2014-12-20 18:49:15 +0000
60+++ media/css/base.css 2014-12-23 17:25:54 +0000
61@@ -1,4 +1,9 @@
62-/* Common */
63+/*++++++++++++++++++*/
64+/* Common */
65+/*------------------*/
66+/* Effects to all */
67+/* part of website */
68+/*++++++++++++++++++*/
69
70 body {
71 background-color: #e9c78a;
72@@ -10,20 +15,48 @@
73 text-shadow: #000000 1px 1px 0px;
74 }
75
76+/*+++++++++++++++++++++++++*/
77+/* Links and special links */
78+/*+++++++++++++++++++++++++*/
79+
80 a img {
81 border: none;
82 }
83
84 a {
85 text-decoration: none;
86- color: #ffffee;
87+ color: rgba(254, 234, 138, 1);
88 font-weight: bold;
89 }
90
91+.blogEntry a {
92+ font-weight: normal;
93+}
94+
95+a:visited {
96+ color: #C8BE93;
97+}
98+
99+a.missingLink {
100+ color: yellow;
101+}
102+
103+a.externalLink:after {
104+ content: " "url("../img/replied.png");
105+}
106+
107 a:hover {
108 color: #181;
109 }
110
111+/* We put this after a:hover */
112+/* to prevend the hover style */
113+/* for this link */
114+
115+a.wrongLink {
116+ color: rgb(255, 117, 0);
117+}
118+
119 a.invertedColor {
120 color: #181;
121 }

Subscribers

People subscribed via source and target branches

to status/vote changes: