Skip to content

Commit

Permalink
Add smart links back to *wiki* pages
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenDragon committed Mar 13, 2015
1 parent 3ba11fc commit d668238
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion controllers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def parsed():
redirect(URL('form'))
# Leroy Jenkins! Let's do this!
experience, obtained_items, proc_items, found_items, log_file, max_hit, hit_list, restored_items, \
affected_items, created_items, rant_items, magic_items, triggered_items = parser(row[0].data)
affected_items, created_items, rant_items, magic_items, triggered_items, log_suns_mode = parser(row[0].data)
return locals()
else:
session.flash = T("Expected a known or valid UUID")
Expand Down
10 changes: 10 additions & 0 deletions models/numbers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import division
from string import digits
import urllib

def percentage(x, y):
if y == 0:
Expand Down Expand Up @@ -29,3 +30,12 @@ def safe_divide(x, y):
return "Divide/0 Error"
else:
return commify( (float(x) / y) )


def gen_wiki_url(proc_name, suns_mode):
dotd_wiki = 'http://dotd.wikia.com/wiki/Special:Search?search='
lots_wiki = 'http://zoywiki.com/index.php?search=LotS+'
if suns_mode:
return lots_wiki + str(urllib.quote_plus(proc_name)) + '&button=&title=Special%3ASearch'
else:
return dotd_wiki + str(urllib.quote_plus(proc_name)) + '&fulltext=Search'
8 changes: 4 additions & 4 deletions models/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def parser(input):

max_hit = []
hit_list = {}
biggest_hit_suns_mode = 0
log_suns_mode = 0

proc_to_names = load_proc_to_names()

Expand Down Expand Up @@ -169,7 +169,7 @@ def parser(input):

if len(object) >= 7:
experience['user'] = object[0]
biggest_hit_suns_mode = 1
log_suns_mode = 1

if isnum(object[2]):
damage = int(object[2].replace(',', ''))
Expand Down Expand Up @@ -330,7 +330,7 @@ def parser(input):
previous_hit_idx = 0

# determine indexes for the biggest hit history
if biggest_hit_suns_mode:
if log_suns_mode:
biggest_hit_idx += 1
if previous_hit_idx != 0:
previous_hit_idx += 2
Expand All @@ -347,4 +347,4 @@ def parser(input):
syslog.closelog()

return experience, obtained_items, proc_items, found_items, log_file, max_hit, hit_list, restored_items, \
affected_items, created_items, rant_items, magic_items, triggered_items
affected_items, created_items, rant_items, magic_items, triggered_items, log_suns_mode
4 changes: 1 addition & 3 deletions views/default/parsed.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
});
</script>

{{dotd_wiki = 'http://dotd.wikia.com/wiki/Special:Search?search='}}

{{if not len(experience['user']):}}

<div id="dataError" align="left">
Expand Down Expand Up @@ -190,7 +188,7 @@
<tbody>
{{for item,value in proc_items.iteritems():}}
<tr>
<td>{{=item}}</td>
<td><a href="{{=gen_wiki_url(item, log_suns_mode)}}" target="_blank">{{=item}}</a></td>
<td>{{=commify(proc_items[item]['count'])}}</td>
<td>{{=percentage(proc_items[item]['count'], total_hits)}} %</td>
<td>{{=safe_divide(proc_items[item]['damage'], proc_items[item]['count'])}}</td>
Expand Down
2 changes: 1 addition & 1 deletion views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h3>Right Sidebar</h3>
<footer class="footer span12" id="footer">
<div class="footer-content">
{{block footer}} <!-- this is default footer -->
<div class="copyright pull-left">Version: 1.3.3, {{=T('Copyright')}} &#169; {{=request.now.year}}</div>
<div class="copyright pull-left">Version: 1.3.4, {{=T('Copyright')}} &#169; {{=request.now.year}}</div>
<div id="poweredBy" class="pull-right">
{{=T('Powered by')}}
<a href="http://www.web2py.com/">web2py</a>
Expand Down

0 comments on commit d668238

Please sign in to comment.