Skip to content

Commit

Permalink
Merge pull request #84 from catbref/master
Browse files Browse the repository at this point in the history
improved web/blog nav & cosmetic fixes
  • Loading branch information
catbref committed Jan 17, 2018
2 parents d66b78a + 4312300 commit 6c70337
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 50 deletions.
6 changes: 3 additions & 3 deletions Qora/src/controller/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ public class Controller extends Observable {


private static final Logger LOGGER = LogManager.getLogger(Controller.class);
private String version = "0.26.4";
private String buildTime = "2017-12-17 17:06:00 UTC";
private String version = "0.26.5";
private String buildTime = "2018-01-17 16:46:00 UTC";
private long buildTimestamp;

public static final String releaseVersion = "0.26.4";
public static final String releaseVersion = "0.26.5";

// TODO ENUM would be better here
public static final int STATUS_NO_CONNECTIONS = 0;
Expand Down
2 changes: 1 addition & 1 deletion Qora/src/gui/ClosingDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ClosingDialog()
this.waitDialog.setModal(false);
this.waitDialog.pack();
this.waitDialog.setLocationRelativeTo(null);
this.waitDialog.setAlwaysOnTop(true);
this.waitDialog.toFront();
this.waitDialog.setVisible(true);
this.waitDialog.repaint();

Expand Down
2 changes: 1 addition & 1 deletion Qora/src/gui/SplashFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private SplashFrame() {
this.splashDialog.setModal(false);
this.splashDialog.pack();
this.splashDialog.setLocationRelativeTo(null);
this.splashDialog.setAlwaysOnTop(true);
this.splashDialog.toFront();
this.splashDialog.setVisible(true);
this.splashDialog.repaint();

Expand Down
18 changes: 9 additions & 9 deletions Qora/src/utils/NameUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,19 @@ public static List<Pair<String, String>> getWebsitesbyValueInternal(


NameStorageMap nameStorageMap = DBSet.getInstance().getNameStorageMap();
Set<String> keys = nameStorageMap.getKeys();
Set<String> names = nameStorageMap.getKeys();

for (String key : keys) {
String value = nameStorageMap.getOpt(key, Qorakeys.WEBSITE.getKeyname());
if (value != null) {
for (String name : names) {
String data = nameStorageMap.getOpt(name, Qorakeys.WEBSITE.getKeyname());
if (data != null) {
if (searchValueOpt == null) {
results.add(new Pair<String, String>(key,
value));
results.add(new Pair<String, String>(name,
data));
} else {
if (value.toLowerCase().contains(
if (data.toLowerCase().contains(
searchValueOpt.toLowerCase())) {
results.add(new Pair<String, String>(key,
value));
results.add(new Pair<String, String>(name,
data));
}

}
Expand Down
50 changes: 31 additions & 19 deletions Qora/src/webserver/WebResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -128,16 +129,17 @@ public Response handleDefault() {
.build();
}

if (StringUtils.isBlank(searchValue)) {
return Response.ok(

pebbleHelper.evaluate(), "text/html; charset=utf-8").build();
if (StringUtil.isBlank(searchValue)) {
// effectively display web directory
searchValue = null;
}

List<Pair<String, String>> searchResults;
searchResults = NameUtils.getWebsitesByValue(searchValue);
List<Pair<String, String>> websitesByValue = NameUtils.getWebsitesByValue(searchValue);

List<HTMLSearchResult> results = generateHTMLSearchresults(searchResults);
// For now, default sort is descending alpha "name" (first entry in list pair)
websitesByValue.sort(Comparator.comparing(Pair::getA));

List<HTMLSearchResult> results = generateHTMLSearchresults(websitesByValue);

pebbleHelper.getContextMap().put("searchresults", results);

Expand Down Expand Up @@ -209,10 +211,10 @@ public Response doBlogSearch() {
try {
PebbleHelper pebbleHelper = PebbleHelper.getPebbleHelper(
"web/main.mini.html", request);
if (StringUtil.isBlank(searchValue)) {

return Response.ok(pebbleHelper.evaluate(),
"text/html; charset=utf-8").build();
if (StringUtil.isBlank(searchValue)) {
// effectively display blog directory
searchValue = null;
}

List<HTMLSearchResult> results = handleBlogSearch(searchValue);
Expand Down Expand Up @@ -860,8 +862,11 @@ public Response doWebdirectory() {
PebbleHelper pebbleHelper = PebbleHelper.getPebbleHelper(
"web/main.mini.html", request);

List<Pair<String, String>> websitesByValue = NameUtils
.getWebsitesByValue(null);
List<Pair<String, String>> websitesByValue = NameUtils.getWebsitesByValue(null);

// For now, default sort is descending alpha "name" (first entry in list pair)
websitesByValue.sort(Comparator.comparing(Pair::getA));

List<HTMLSearchResult> results = generateHTMLSearchresults(websitesByValue);

pebbleHelper.getContextMap().put("searchresults", results);
Expand Down Expand Up @@ -927,9 +932,14 @@ public Response getStatus() {
}

private List<HTMLSearchResult> handleBlogSearch(String blogSearchOpt) {
List<BlogProfile> allEnabledBlogs = BlogUtils.getEnabledBlogs(blogSearchOpt);

// For now, default sort is descending alpha blog-name
// (using lambda because there's no direct method for Comparator)
Collections.sort(allEnabledBlogs, (a, b) -> a.getProfile().getName().getName().compareTo(b.getProfile().getName().getName()));

List<HTMLSearchResult> results = new ArrayList<>();
List<BlogProfile> allEnabledBlogs = BlogUtils
.getEnabledBlogs(blogSearchOpt);

for (BlogProfile blogProfile : allEnabledBlogs) {
String name = blogProfile.getProfile().getName().getName();
String title = blogProfile.getProfile().getBlogTitleOpt();
Expand Down Expand Up @@ -2227,16 +2237,17 @@ public Response mergedBlog() {
"text/html; charset=utf-8").build();
}

pebbleHelper.getContextMap().put("postblogurl",
"postblog.html?blogname=" + blogname);
// update blogname in case it was null before
blogname = profile.getName().getName();
pebbleHelper.getContextMap().put("blogname", blogname);

pebbleHelper.getContextMap().put("blogprofile", profile);
pebbleHelper.getContextMap().put("blogenabled", true);
pebbleHelper.getContextMap().put("hideprofile", true);

List<String> followedBlogs = new ArrayList<String>(
profile.getFollowedBlogs());
followedBlogs.add(profile.getName().getName());
followedBlogs.add(blogname);

List<BlogEntry> blogPosts = BlogUtils.getBlogPosts(followedBlogs);

Expand Down Expand Up @@ -2391,8 +2402,9 @@ public Response getBlog(@PathParam("messageOpt") String messageOpt) {
"text/html; charset=utf-8").build();
}

pebbleHelper.getContextMap().put("postblogurl",
"postblog.html?blogname=" + blogname);
// update blogname in case it was null before
blogname = profile.getName().getName();
pebbleHelper.getContextMap().put("blogname", blogname);

pebbleHelper.getContextMap().put("blogprofile", profile);
pebbleHelper.getContextMap().put("blogenabled",
Expand Down
22 changes: 11 additions & 11 deletions Qora/web/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
<div id="PostModal" class="modal fade">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<iframe width="100%" height="100%" frameborder="0" src="{{postblogurl}}"></iframe>
<iframe width="100%" height="100%" frameborder="0" src="postblog.html?blogname={{blogname|escape(strategy="url_param")}}"></iframe>
</div>
</div>
</div>
Expand Down Expand Up @@ -270,7 +270,7 @@
<img align="left" src="{{blogprofile.getAvatarOpt()}}" alt="" class="tl-image-profile thumbnail">
{%endif%}
<div class="tl-profile-text">
<h1>{{blogprofile.getName().getName()}}</h1>
<h1>{{blogname}}</h1>
<ul class="profile-options list-inline">&nbsp;&nbsp;
<li class="co-tabs pull-left"><ul class="co-lists list-unstyled"><li class="co-top translate">Followers</li><li class="co-bottom">{{ follower.size() }}</li></ul></li>
<li class="co-tabs pull-left"><ul class="co-lists list-unstyled"><li class="co-top translate">Following</li><li class="co-bottom">{{ blogprofile.getFollowedBlogs().size() }}</li></ul></li>
Expand All @@ -291,19 +291,19 @@ <h1>{{blogprofile.getName().getName()}}</h1>
<div class="media">
{% if blogpost.shareAuthorOpt() is not null %}
{% if blogpost.getNameOpt() is not null %}
<h6><span class="glyphicon glyphicon-retweet"></span> <b><a href="/index/blog.html?blogname={{blogpost.shareAuthorOpt()}}">{{blogpost.shareAuthorOpt()}}</a></b> shared <b><a href="/index/blog.html?blogname={{blogpost.nameOrCreator}}">{{blogpost.nameOrCreator}}</a></b> post</h6>
<h6><span class="glyphicon glyphicon-retweet"></span> <b><a href="/index/blog.html?blogname={{blogpost.shareAuthorOpt()|escape(strategy="url_param")}}">{{blogpost.shareAuthorOpt()}}</a></b> shared <b><a href="/index/blog.html?blogname={{blogpost.nameOrCreator|escape(strategy="url_param")}}">{{blogpost.nameOrCreator}}</a></b> post</h6>
{%else%}
<h6><span class="glyphicon glyphicon-retweet"></span> <b><a href="/index/blog.html?blogname={{blogpost.shareAuthorOpt()}}">{{blogpost.shareAuthorOpt()}}</a></b> shared <b>{{blogpost.nameOrCreator}}</b> post</h6>
<h6><span class="glyphicon glyphicon-retweet"></span> <b><a href="/index/blog.html?blogname={{blogpost.shareAuthorOpt()|escape(strategy="url_param")}}">{{blogpost.shareAuthorOpt()}}</a></b> shared <b>{{blogpost.nameOrCreator}}</b> post</h6>
{%endif%}
{%endif%}
{% if blogpost.getProfileOpt() is not null and blogpost.getProfileOpt().isProfileEnabled() %}
<div class="media-left media-middle"><a href="/index/blog.html?blogname={{blogpost.nameOrCreator}}"><img src="{{blogpost.getAvatar()}}" alt="" class="media-object"></a></div>
<div class="media-left media-middle"><a href="/index/blog.html?blogname={{blogpost.nameOrCreator|escape(strategy="url_param")}}"><img src="{{blogpost.getAvatar()}}" alt="" class="media-object"></a></div>
{%else%}
<div class="media-left media-middle"><img src="{{blogpost.getAvatar()}}" alt="" class="media-object"></div>
{%endif%}
<div class="media-body">
{% if blogpost.getProfileOpt() is not null and blogpost.getProfileOpt().isProfileEnabled() %}
<h6 class="media-heading"><b><a href="/index/blog.html?blogname={{blogpost.getProfileOpt().getName().getName()}}">{{blogpost.nameOrCreator}}</a></b></h6>{{blogpost.creationTime}}
<h6 class="media-heading"><b><a href="/index/blog.html?blogname={{blogpost.getProfileOpt().getName().getName()|escape(strategy="url_param")}}">{{blogpost.nameOrCreator}}</a></b></h6>{{blogpost.creationTime}}
{%else%}
<h6 class="media-heading"><b>{{blogpost.nameOrCreator}}</b></h6>{{blogpost.creationTime}}
{%endif%}
Expand Down Expand Up @@ -336,15 +336,15 @@ <h6 class="media-heading"><b>{{blogpost.nameOrCreator}}</b></h6>{{blogpost.creat
</div>
<div class="timeline-footer">
<a><span onclick="javascript:processLike('{{blogpost.getSignature()}}', {{blogpost.isLiking()}})" ><i class="glyphicon glyphicon-heart" style=""><font color=white>.</font>{{blogpost.getLikes()}}</i></a>
<a class="pull-right"><span onclick="javascript:processShare('{{blogpost.getSignature()}}' , '{{blogpost.getBlognameOpt()}}')" ><i class="glyphicon glyphicon-share"><font color=white>.</font>{{blogpost.getShares()}}</i></a>
<a class="pull-right"><span onclick="javascript:processShare('{{blogpost.getSignature()}}' , '{{blogpost.getBlognameOpt()|escape(strategy="js")}}')" ><i class="glyphicon glyphicon-share"><font color=white>.</font>{{blogpost.getShares()}}</i></a>

<div class="commentList">
{% for comment in blogpost.getComments() %}
<div class="commentEntry">

<div class="media-left">
{% if comment.getNameOpt() is not null %}
<a href="/index/blog.html?blogname={{comment.nameOrCreator}}">
<a href="/index/blog.html?blogname={{comment.nameOrCreator|escape(strategy="url_param")}}">
{%else%}
<a href="#">
{%endif%}
Expand All @@ -359,7 +359,7 @@ <h6 class="media-heading"><b>{{blogpost.nameOrCreator}}</b></h6>{{blogpost.creat

<div class="media-body">
{% if comment.getNameOpt() is not null %}
<h4 class="media-heading Commenter"><a href="/index/blog.html?blogname={{comment.nameOrCreator}}">{{comment.nameOrCreator}}</a></h4>
<h4 class="media-heading Commenter"><a href="/index/blog.html?blogname={{comment.nameOrCreator|escape(strategy="url_param")}}">{{comment.nameOrCreator}}</a></h4>
{%else%}
<h4 class="media-heading Commenter">{{comment.nameOrCreator}}</h4>
{%endif%}
Expand Down Expand Up @@ -392,7 +392,7 @@ <h4 class="media-heading Commenter">{{comment.nameOrCreator}}</h4>
{%else%}
<h1 style="font-family: Verdana;"><span class="translate">This blog is currently disabled.</span><br>
{% if ownProfileName is not null %}
<span class="translate">You can enable the blog <a href='/index/settings.html?profilename={{ownProfileName}}'>here</a></span>
<span class="translate">You can enable the blog <a href='/index/settings.html?profilename={{ownProfileName|escape(strategy="url_param")}}'>here</a></span>
{%endif%}
</h1><br>
{% endif %}
Expand Down Expand Up @@ -875,7 +875,7 @@ <h1 style="font-family: Verdana;"><span class="translate">This blog is currently
$('#{{blogpost.getSignature()}} > .timeline-panel').toggleClass("highlighted");
$('#{{blogpost.getSignature()}} > .timeline-badge').toggleClass("highlighted");
};
if (window.location.search === '?blogname={{blogpost.nameOrCreator}}&msg={{blogpost.getSignature()}}') {
if (window.location.search === '?blogname={{blogpost.nameOrCreator|escape(strategy="url_param")}}&msg={{blogpost.getSignature()}}') {
$('#{{blogpost.getSignature()}} > .timeline-panel').toggleClass("highlighted");
$('#{{blogpost.getSignature()}} > .timeline-badge').toggleClass("highlighted");
};
Expand Down
2 changes: 1 addition & 1 deletion Qora/web/main.mini.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ <h5 class="r-t">{% autoescape true %}{{searchresult.title | abbreviate(64)}}{% e
$(document).ready(function() {
var searchval;
$('ul.nav-tabs > li').removeClass('active');
if (window.location.pathname === '/index/blogsearch.html') {
if (window.location.pathname === '/index/blogsearch.html' || window.location.pathname === '/index/blogdirectory.html') {
$('ul.nav-tabs > li:nth-child(2)').addClass('active');
} else {
$('ul.nav-tabs > li:nth-child(1)').addClass('active');
Expand Down
10 changes: 5 additions & 5 deletions Qora/web/namestorage.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,21 @@
<div class="col-lg-10">
<select class="form-control" id="select-name">
{% for name in names %}
<option value={{name.name}}>
{{name.NameBalanceString}}</option>
<option value="{{name.name|escape(strategy="html_attr")}}">
{{name.NameBalanceString|escape(strategy="html")}}</option>
{% endfor %}
</select>
</div>
<label for="title" class="col-lg-2 control-label translate">Key</label>
<div class="col-lg-10">
<input id="key" type="text" placeholder="Key (use key website or leave it blank to create a website)" class="form-control translate">
<input id="key" type="text" placeholder="Key (use the key &quot;website&quot; or leave it blank to create a website)" class="form-control translate">
</div>
</div>
<div class="form-group">
<label for="website" class="col-lg-2 control-label"><br><span class='translate'>Data</span></label>
<div class="col-lg-10">
<div style="text-align: right;"><input name="WYSIWYG" id="WYSIWYG" type="checkbox"><label for="WYSIWYG" class='translate'>Visual editor</label></div>
<pre><textarea id="website" rows="10" class="form-control">{{website}}</textarea></pre>
<pre><textarea id="website" rows="10" class="form-control">{{website|escape(strategy="html")}}</textarea></pre>
</div>
</div>

Expand Down Expand Up @@ -369,11 +369,11 @@
});
});

{% autoescape "js" %}
$(document).ready(function() {
var searchval;
$("#select-name").val('{{name}}');
$("#key").val('{{key}}');
{% autoescape true %}
$('#form').ajaxForm(
{
beforeSubmit: function() {
Expand Down

0 comments on commit 6c70337

Please sign in to comment.