profile.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. {% extends "cranefly/layout.html" %}
  2. {% import "cranefly/macros.html" as macros with context %}
  3. {% block title %}{{ macros.page_title(profile.username) }}{% endblock %}
  4. {% block container %}
  5. <div class="user-profile{% if profile.get_style() %} user-profile-{{ profile.get_style() }}{% endif %}">
  6. <div class="page-header header-primary user-profile-header">
  7. <div class="container">
  8. {{ messages_list(messages) }}
  9. <div class="header-row">
  10. {% if profile.id == user.id and not user.avatar_ban %}
  11. <a href="{{ url('usercp_avatar') }}"><img src="{{ profile.get_avatar() }}" class="header-avatar tooltip-right" title="{% trans %}Click to jump to your Avatar Settings{% endtrans %}"></a>
  12. {% else %}
  13. <img src="{{ profile.get_avatar() }}" class="header-avatar">
  14. {% endif %}
  15. <div class="header-side">
  16. <h1>{{ profile.username }} <small>{% if profile.title or profile.rank.title -%}
  17. <strong>{% if profile.title %}{{ _(profile.title) }}{% elif profile.rank.title %}{{ _(profile.rank.title) }}{% endif %}</strong>; {% endif %}
  18. {%- if online and (not hidden or acl.users.can_see_hidden_users()) -%}
  19. {%- if profile.hide_activity -%}
  20. {% trans %}Online, hidden{% endtrans %}
  21. {%- else -%}
  22. {% trans %}Online{% endtrans %}
  23. {%- endif %}
  24. {%- else -%}
  25. {% trans %}Offline{% endtrans %}
  26. {%- endif -%}, {% if not hidden or acl.users.can_see_hidden_users() -%}
  27. {%- if online -%}
  28. {% trans last_click=online.last|reltimesince|low %}last click {{ last_click }}{% endtrans %}
  29. {%- elif profile.last_date -%}
  30. {% trans last_visit=profile.last_date|reltimesince|low %}last seen {{ last_visit }}{% endtrans %}
  31. {%- else -%}
  32. {% trans %}never visited{% endtrans %}
  33. {%- endif -%}
  34. {%- else -%}
  35. {% trans %}hiding activity{% endtrans %}
  36. {%- endif %}</small></h1>
  37. <ul class="nav nav-tabs header-tabs">
  38. {% for link in tabs %}
  39. <li{% if link.active %} class="active"{% endif %}>
  40. <a href="{{ url(link.route, user=profile.pk, username=profile.username_slug) }}">{{ link.name }}</a>
  41. </li>
  42. {% endfor %}
  43. {% if user.is_authenticated() and user.pk != profile.pk %}
  44. <li class="pull-right">
  45. <form class="form-inline" action="{% if ignores %}{{ url('unignore_user', user=profile.id) }}{% else %}{{ url('ignore_user', user=profile.id) }}{% endif %}" method="post">
  46. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  47. <input type="hidden" name="fallback" value="{{ fallback }}">
  48. <button type="submit" class="btn btn-icon tooltip-top{% if ignores %} btn-inverse{% endif %}" title="{% if ignores %}{% trans user=profile.username %}Remove {{ user }} from ignored{% endtrans %}{% else %}{% trans user=profile.username %}Add {{ user }} to ignored{% endtrans %}{% endif %}">
  49. <i class="icon-ban-circle"></i>
  50. </button>
  51. </form>
  52. </li>
  53. <li class="pull-right">
  54. <form class="form-inline" action="{% if follows %}{{ url('unfollow_user', user=profile.id) }}{% else %}{{ url('follow_user', user=profile.id) }}{% endif %}" method="post">
  55. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  56. <input type="hidden" name="fallback" value="{{ fallback }}">
  57. <button type="submit" class="btn btn-icon tooltip-top{% if follows %} btn-success{% endif %}" title="{% if follows %}{% trans user=profile.username %}Stop following {{ user }}{% endtrans %}{% else %}{% trans user=profile.username %}Start following {{ user }}{% endtrans %}{% endif %}">
  58. <i class="icon-heart"></i>
  59. </button>
  60. </form>
  61. </li>
  62. {% if acl.private_threads.can_start() %}
  63. <li class="pull-right">
  64. <a href="{{ url('private_thread_start_with', username=profile.username_slug, user=profile.pk) }}" class="btn btn-icon tooltip-top" title="{% trans user=profile.username %}Start private thread with {{ user }}{% endtrans %}"><i class="icon-envelope"></i></a>
  65. </li>
  66. {% endif %}
  67. {% if acl.destroy_users.can_destroy_user(profile) %}
  68. <li class="pull-right">
  69. <form class="form-inline form-destroy-user" action="{{ url('destroy_user', username=profile.username_slug, user=profile.pk) }}" method="post">
  70. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  71. <button type="submit" class="btn btn-icon tooltip-top" title="{% trans user=profile.username %}Destroy {{ user }}'s user account, deleting it, its threads and soft-deleting it's replies in other threads.{% endtrans %}">
  72. <i class="icon-remove"></i>
  73. </button>
  74. </form>
  75. </li>
  76. {% endif %}
  77. {% endif %}
  78. </ul>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <div class="container container-primary">
  84. {% block tab %}{% endblock %}
  85. </div>
  86. </div>
  87. {% endblock %}
  88. {% macro draw_graph() %}
  89. <script src="{{ STATIC_URL }}cranefly/js/d3.min.js"></script>
  90. <script type="text/javascript">
  91. var data = [{{ (',').join(graph) }}];
  92. {% if graph_max %}
  93. var max = {{ graph_max }};
  94. {% else %}
  95. var max = 1;
  96. {% endif %}
  97. var barWidth = 8;
  98. var width = (barWidth + 2) * data.length;
  99. var height = 40;
  100. // add the canvas to the DOM
  101. var barDemo = d3.select("#user-graph")
  102. .append("svg")
  103. .attr("width", "100%")
  104. .attr("height", 40)
  105. .attr("preserveAspectRatio", 'none')
  106. .attr("viewBox", "0 0 " + width + " " + height);
  107. barDemo.selectAll("rect")
  108. .data(data)
  109. .enter()
  110. .append("rect")
  111. .attr("shape-rendering", 'crispEdges')
  112. .attr("x", function(datum, index) { return (2 + barWidth) * index; })
  113. .attr("y", function(datum) { return height - ((datum / max) * height) - 2; })
  114. .attr("height", function(datum) { return ((datum / max) * (height)) + 2; })
  115. .attr("width", barWidth)
  116. .attr("fill", "#DDD");
  117. </script>
  118. {% endmacro %}
  119. {% block javascripts %}
  120. {{ super() }}
  121. <script type="text/javascript">
  122. $('.form-destroy-user').submit(function() {
  123. var decision = confirm("{% trans %}Are you sure you want to destroy this member's account? This action is not reversible!{% endtrans %}");
  124. return decision;
  125. });
  126. </script>
  127. {% endblock %}