profile.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. {% if acl.warnings.can_warn_members() %}
  78. <li class="pull-right">
  79. <form class="form-inline" action="{{ url('warn_user', user=profile.pk, slug=profile.username_slug) }}" method="post">
  80. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  81. <input type="hidden" name="retreat" value="{{ request_path }}">
  82. <input type="hidden" name="reason" value="{% trans %}Your profile contents were found to violate community guidelines.{% endtrans %}">
  83. <button type="submit" class="btn btn-icon tooltip-top" title="{% trans user=profile.username %}Increase {{ user }}'s warning level.{% endtrans %}">
  84. <i class="icon-warning-sign"></i>
  85. </button>
  86. </form>
  87. </li>
  88. {% endif %}
  89. {% endif %}
  90. </ul>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. <div class="container container-primary">
  96. {% block tab %}{% endblock %}
  97. </div>
  98. </div>
  99. {% endblock %}
  100. {% macro draw_graph() %}
  101. <script src="{{ STATIC_URL }}cranefly/js/d3.min.js"></script>
  102. <script type="text/javascript">
  103. var data = [{{ (',').join(graph) }}];
  104. {% if graph_max %}
  105. var max = {{ graph_max }};
  106. {% else %}
  107. var max = 1;
  108. {% endif %}
  109. var barWidth = 8;
  110. var width = (barWidth + 2) * data.length;
  111. var height = 40;
  112. // add the canvas to the DOM
  113. var barDemo = d3.select("#user-graph")
  114. .append("svg")
  115. .attr("width", "100%")
  116. .attr("height", 40)
  117. .attr("preserveAspectRatio", 'none')
  118. .attr("viewBox", "0 0 " + width + " " + height);
  119. barDemo.selectAll("rect")
  120. .data(data)
  121. .enter()
  122. .append("rect")
  123. .attr("shape-rendering", 'crispEdges')
  124. .attr("x", function(datum, index) { return (2 + barWidth) * index; })
  125. .attr("y", function(datum) { return height - ((datum / max) * height) - 2; })
  126. .attr("height", function(datum) { return ((datum / max) * (height)) + 2; })
  127. .attr("width", barWidth)
  128. .attr("fill", "#DDD");
  129. </script>
  130. {% endmacro %}
  131. {% block javascripts %}
  132. {{ super() }}
  133. <script type="text/javascript">
  134. $('.form-destroy-user').submit(function() {
  135. var decision = confirm("{% trans %}Are you sure you want to destroy this member's account? This action is not reversible!{% endtrans %}");
  136. return decision;
  137. });
  138. </script>
  139. {% endblock %}