Skip to content

Commit

Permalink
fixed broken profile pictures of deleted users, show notice of user o…
Browse files Browse the repository at this point in the history
…bject deleted
  • Loading branch information
albogdano committed Sep 20, 2017
1 parent c566db7 commit 90f5516
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
package com.erudika.scoold.controllers;

import com.erudika.scoold.utils.ScooldUtils;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/*
* Copyright 2013-2017 Erudika. https://erudika.com
Expand All @@ -25,6 +16,15 @@
*
* For issues and patches go to: https://github.com/erudika
*/
package com.erudika.scoold.controllers;

import com.erudika.scoold.utils.ScooldUtils;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public String get(@PathVariable(required = false) String id, HttpServletRequest
model.addAttribute("isMyProfile", isMyProfile);
model.addAttribute("badgesCount", showUser.getBadgesMap().size());
model.addAttribute("canEdit", isMyProfile || canEditProfile(authUser, id));
model.addAttribute("gravatarPicture", utils.getGravatar(showUser.getUser().getEmail()));
model.addAttribute("gravatarPicture", utils.getGravatar(showUser));
model.addAttribute("itemcount1", itemcount1);
model.addAttribute("itemcount2", itemcount2);
model.addAttribute("questionslist", questionslist);
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/erudika/scoold/core/Feedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
package com.erudika.scoold.core;

import java.io.Serializable;

/**
*
* @author Alex Bogdanovski [[email protected]]
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/erudika/scoold/core/Question.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
package com.erudika.scoold.core;

import java.io.Serializable;

/**
*
* @author Alex Bogdanovski [[email protected]]
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/erudika/scoold/utils/ScooldUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ public String getGravatar(String email) {
return "https://www.gravatar.com/avatar/" + Utils.md5(email) + "?size=400&d=retro";
}

public String getGravatar(Profile profile) {
if (profile == null || profile.getUser() == null) {
return "https://www.gravatar.com/avatar?d=retro&size=400";
} else {
return getGravatar(profile.getUser().getEmail());
}
}

public void clearSession(HttpServletRequest req, HttpServletResponse res) {
if (req != null) {
HttpSession session = req.getSession(false);
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/templates/feedback.vm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
<ul id="tags-dropdown" class="dropdown-content ac-dropdown"></ul>
<input type="hidden" name="tags" class="ac-hidden" value="">
</div>
#getmessagebox("red white-text" $error.get("tags"))
<div class="pll mll">
#getmessagebox("red white-text" $error.get("tags"))
</div>

<div><i class="fa fa-save save-icon green-text hidden-save-icon"></i> &nbsp;</div>
<button class="btn mtl waves-effect waves-light" type="submit">
Expand Down Expand Up @@ -81,7 +83,7 @@
</div>
#else
<div class="mtl ptl center">
<a href="$signinlink?returnto=$!returnto" rel="nofollow" class="btn"
<a href="$signinlink?returnto=$!returnto" rel="nofollow" class="btn-large"
title="Reply"><i class="fa fa-pencil"></i> $!lang.get("feedback.writereply")</a>
</div>
#end
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/templates/macro.vm
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@
#if ($showFriend.groups == "mods")
<i class="fa fa-dot-circle-o orange-text mhs tooltipped" data-delay="0" data-tooltip="$!lang.get('mod')"></i>
#end
#if(!$showFriend.user && $isMod)
<small class="grey-text">$!lang.get("profile.deleted")</small>
#end
<div class="grey-text r prl tooltipped" data-position="top" data-tooltip="$!{lang.get('profile.about.lastseen')}">
<i class="fa fa-clock-o"></i> #formatdate($!{showFriend.lastseen} "")
</div>
Expand Down Expand Up @@ -633,7 +636,7 @@ $utils.formatDate($date, $format, $currentLocale)
<div class="progress ajaxwait $!{hidden}"><div class="indeterminate"></div></div>
#end
#####################################
#macro(profilepic $user)#if($user && $user.picture.matches("^(http:|https:|data:).*"))$!{user.picture}#else https://www.gravatar.com/avatar/?size=350&d=mm #end#end
#macro(profilepic $user)#if($user && $user.user && $user.picture.matches("^(http:|https:|data:).*"))$!{user.picture}#else https://www.gravatar.com/avatar/?size=350&d=mm #end#end
#####################################
#macro(infostrip )
#if ($request.getParameter("success"))
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/templates/profile.vm
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@
$!{lang.get("profile.about.lastseen")} #formatdate($!{showUser.lastseen} "")</h5>
#end

#if(!$showUser.user && $isMod)
<h5 class="grey-text text-darken-1 pvs"><i class="fa fa-warning"></i> &nbsp; $!lang.get("profile.deleted")</h5>
#end

#set($badges = $showUser.badgesMap)
#if (!$badges.isEmpty())
<span class="largeText grey-text text-darken-1" title=" $!lang.get('badges.title')"><i class="fa fa-star"></i>&nbsp;</span>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/question.vm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</div>
#else
<div class="mtl ptl center">
<a href="$signinlink?returnto=$!returnto" rel="nofollow" class="btn"
<a href="$signinlink?returnto=$!returnto" rel="nofollow" class="btn-large"
title="Answer this question"><i class="fa fa-pencil"></i> $!lang.get("posts.writeanswer")</a>
</div>
#end
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/templates/questions.vm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
<ul id="tags-dropdown" class="dropdown-content ac-dropdown"></ul>
<input type="hidden" name="tags" class="ac-hidden" value="">
</div>
#getmessagebox("red white-text" $error.get("tags"))
<div class="pll mll">
#getmessagebox("red white-text" $error.get("tags"))
</div>

<a href="#" class="next-div-toggle mll pll click2hide">
<i class="fa fa-map-marker"></i> $!lang.get("posts.location")
Expand Down

0 comments on commit 90f5516

Please sign in to comment.