A corporation manager and dashboard for EVE Online
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

55 строки
1.7 KiB

  1. # -*- coding: utf-8 -*-
  2. from flask import g, json
  3. from flask_mako import render_template
  4. from ._provided import app, blueprint
  5. def home():
  6. """Render and return the main map page."""
  7. return render_template("map/map.mako")
  8. def navitem():
  9. """Render and return the navigation item for this module."""
  10. return render_template("map/navitem.mako").decode("utf8")
  11. @blueprint.rroute("/map")
  12. def map():
  13. """Render and return the main map page."""
  14. return home()
  15. @blueprint.rroute("/map/data.json")
  16. def mapdata():
  17. """Render and return the map data as a JSON object."""
  18. payload = {
  19. "systems": {
  20. system.id: {
  21. "name": system.name,
  22. "region": system.region.id,
  23. "security": system.security,
  24. "coords": system.coords,
  25. "gates": [dest.id for dest in system.gates],
  26. "faction": system.faction.id if system.faction else -1
  27. }
  28. for system in g.eve.universe.systems() if not system.is_whspace
  29. },
  30. "regions": {
  31. region.id: {
  32. "name": region.name,
  33. "faction": region.faction.id if region.faction else -1
  34. }
  35. for region in g.eve.universe.regions() if not region.is_whspace
  36. },
  37. "factions": {
  38. faction.id: {
  39. "name": faction.name
  40. }
  41. for faction in g.eve.universe.factions() if faction.territory
  42. }
  43. }
  44. resp = app.response_class(response=json.dumps(payload), status=200,
  45. mimetype="application/json")
  46. resp.cache_control.private = True
  47. resp.cache_control.max_age = 24 * 60 * 60
  48. return resp