A corporation manager and dashboard for EVE Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

171 lines
7.1 KiB

  1. <%!
  2. from calefaction.format import (
  3. format_quantity, format_isk_compact, format_utctime_compact,
  4. format_security, get_security_class)
  5. %>
  6. <%def name="_killboard_kill(kill, detail, any_alliances, any_factions)">
  7. <%
  8. victim = kill["victim"]
  9. system = g.eve.universe.system(kill["system"])
  10. killed = g.eve.universe.killable(victim["ship_id"])
  11. %>
  12. <tr>
  13. <td class="fluid">
  14. <abbr title="${kill["date"].strftime("%Y-%m-%d %H:%M")}">${format_utctime_compact(kill["date"]) | h}</abbr><br/>
  15. <a href="https://zkillboard.com/kill/${kill['id']}/">
  16. <abbr title="${"{:,.2f}".format(kill["value"])} ISK">${format_isk_compact(kill["value"]) | h}</abbr>
  17. </a>
  18. </td>
  19. <td class="fluid extra">
  20. <a href="https://zkillboard.com/system/${system.id}/">${system.name | h}</a> <abbr title="${system.security}" class="${get_security_class(system.security)}">${format_security(system.security)}</abbr><br/>
  21. <a href="https://zkillboard.com/region/${system.region.id}/">${system.region.name | h}</a>
  22. </td>
  23. <td class="icon">
  24. <a href="https://zkillboard.com/kill/${kill['id']}/">
  25. <img title="Kill ${kill['id']}: ${killed.name | h}" alt="Kill ${kill['id']}: ${killed.name | h}" src="${g.eve.image.inventory(victim["ship_id"], 64)}"/>
  26. </a>
  27. </td>
  28. <td class="icon extra">
  29. <a href="https://zkillboard.com/character/${victim['char_id']}/">
  30. <img title="${victim['char_name'] | h}" alt="${victim['char_name'] | h}" src="${g.eve.image.character(victim["char_id"], 128)}"/>
  31. </a>
  32. </td>
  33. % if detail:
  34. <td class="detail-item">
  35. <a href="https://zkillboard.com/character/${victim['char_id']}/">${victim['char_name'] | h}</a>
  36. (${killed.name | h})
  37. </td>
  38. % endif
  39. <td class="icon${' extra' if victim["alliance_id"] and victim["faction_id"] else ''}">
  40. <a href="https://zkillboard.com/corporation/${victim['corp_id']}/">
  41. <img title="${victim['corp_name'] | h}" alt="${victim['corp_name'] | h}" src="${g.eve.image.corp(victim["corp_id"], 128)}"/>
  42. </a>
  43. </td>
  44. % if any_alliances:
  45. <td class="icon${'' if victim["alliance_id"] else ' extra'}">
  46. % if victim["alliance_id"]:
  47. <a href="https://zkillboard.com/alliance/${victim['alliance_id']}/">
  48. <img title="${victim['alliance_name'] | h}" alt="${victim['alliance_name'] | h}" src="${g.eve.image.alliance(victim["alliance_id"], 128)}"/>
  49. </a>
  50. % endif
  51. </td>
  52. % endif
  53. % if any_factions:
  54. <td class="icon${'' if victim["faction_id"] else ' extra'}">
  55. % if victim["faction_id"]:
  56. <a href="https://zkillboard.com/faction/${victim['faction_id']}/">
  57. <img title="${victim['faction_name'] | h}" alt="${victim['faction_name'] | h}" src="${g.eve.image.faction(victim["faction_id"], 128)}"/>
  58. </a>
  59. % endif
  60. </td>
  61. % endif
  62. % if not detail and (any_alliances or any_factions) and not victim["alliance_id"] and not victim["faction_id"]:
  63. <td class="icon spacer"></td>
  64. % endif
  65. % if detail:
  66. <td class="detail-item">
  67. <ul class="detail-list">
  68. <li><a href="https://zkillboard.com/corporation/${victim['corp_id']}/">${victim['corp_name'] | h}</a></li>
  69. % if victim['alliance_name']:
  70. <li><a href="https://zkillboard.com/alliance/${victim['alliance_id']}/">${victim['alliance_name'] | h}</a></li>
  71. % endif
  72. % if victim['faction_name']:
  73. <li><a href="https://zkillboard.com/faction/${victim['faction_id']}/">${victim['faction_name'] | h}</a></li>
  74. % endif
  75. </ul>
  76. </td>
  77. % endif
  78. </tr>
  79. </%def>
  80. <%def name="_itemboard_item(item)">
  81. <%
  82. type_id, count, value = item
  83. type = g.eve.universe.type(type_id)
  84. %>
  85. <tr>
  86. <td class="icon">
  87. <img title="${type.name | h}" alt="" src="${g.eve.image.inventory(type_id, 64)}"/>
  88. </td>
  89. <td>
  90. <a href="https://eve-central.com/home/quicklook.html?typeid=${type_id | u}">${type.name | h}</a>
  91. </td>
  92. <td>
  93. <span class="count">${format_quantity(count) | h}</span><br/>
  94. <abbr class="price" title="${"{:,.2f}".format(value)} ISK">${format_isk_compact(value) | h}</abbr>
  95. </td>
  96. </tr>
  97. </%def>
  98. <%def name="_build_sort_changer(keys, descriptors, sortby)">
  99. % if keys:
  100. <ul class="change-sort">
  101. % for key in keys:
  102. % if key == sortby:
  103. <li class="cur">${descriptors[key]}</li>
  104. % else:
  105. <li><a href="${url_for('.operation', cname=cname, opname=opname, sort=key)}">${descriptors[key]}</a></li>
  106. % endif
  107. % endfor
  108. </ul>
  109. % endif
  110. </%def>
  111. <%def name="_killboard_recent(summary, detail, sortby)">
  112. % if detail:
  113. <%
  114. descriptors = {
  115. "new": "most recent first",
  116. "old": "most recent last",
  117. "value": "most valuable first"
  118. }
  119. if sortby not in descriptors:
  120. sortby = "new"
  121. %>
  122. <h3 class="head">Kills:</h3>
  123. ${_build_sort_changer(["new", "old", "value"], descriptors, sortby)}
  124. % else:
  125. <div class="head">Most recent kills:</div>
  126. % endif
  127. <%
  128. any_alliances = any(kill["victim"]["alliance_id"] for kill in summary)
  129. any_factions = any(kill["victim"]["faction_id"] for kill in summary)
  130. %>
  131. <div class="contents">
  132. <table class="board killboard">
  133. % for kill in summary:
  134. ${_killboard_kill(kill, detail, any_alliances, any_factions)}
  135. % endfor
  136. </table>
  137. </div>
  138. </%def>
  139. <%def name="_collection_items(summary, detail, sortby)">
  140. % if detail:
  141. <%
  142. descriptors = {
  143. "value": "most valuable first",
  144. "quantity": "greatest quantity first",
  145. "price": "most expensive first"
  146. }
  147. if sortby not in descriptors:
  148. sortby = "value"
  149. %>
  150. <h3 class="head">Items:</h3>
  151. ${_build_sort_changer(["value", "quantity", "price"], descriptors, sortby)}
  152. % else:
  153. <div class="head">Top items:</div>
  154. % endif
  155. <div class="contents">
  156. <table class="board itemboard">
  157. % for item in summary:
  158. ${_itemboard_item(item)}
  159. % endfor
  160. </table>
  161. </div>
  162. </%def>
  163. <%def name="render_summary(renderer, summary, detail=False, sortby=None)"><%
  164. if renderer == "killboard_recent":
  165. return _killboard_recent(summary, detail, sortby)
  166. if renderer == "collection_items":
  167. return _collection_items(summary, detail, sortby)
  168. raise RuntimeError("Unknown renderer: %s" % renderer)
  169. %></%def>