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.
 
 
 
 
 

47 regels
1.4 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. "galaxy": {
  20. system.id: {
  21. "name": system.name,
  22. "security": system.security,
  23. "coords": system.coords,
  24. "gates": [dest.id for dest in system.gates],
  25. "faction": system.faction.id if system.faction else -1
  26. }
  27. for system in g.eve.universe.systems() if not system.is_whspace
  28. },
  29. "factions": {
  30. faction.id: {
  31. "name": faction.name
  32. }
  33. for faction in g.eve.universe.factions() if faction.territory
  34. }
  35. }
  36. resp = app.response_class(response=json.dumps(payload), status=200,
  37. mimetype="application/json")
  38. resp.cache_control.private = True
  39. resp.cache_control.max_age = 24 * 60 * 60
  40. return resp