diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/java/Global.properties | 3 | ||||
-rw-r--r-- | src/java/Global_ru.properties | 3 | ||||
-rw-r--r-- | src/java/com/juick/http/www/Discover.java | 16 | ||||
-rw-r--r-- | src/java/com/juick/http/www/Home.java | 17 | ||||
-rw-r--r-- | src/java/com/juick/http/www/PageTemplates.java | 19 | ||||
-rw-r--r-- | src/java/com/juick/http/www/User.java | 6 | ||||
-rw-r--r-- | src/java/com/juick/http/www/UserThread.java | 3 |
7 files changed, 54 insertions, 13 deletions
diff --git a/src/java/Global.properties b/src/java/Global.properties index dfc159c2..27c74eaa 100644 --- a/src/java/Global.properties +++ b/src/java/Global.properties @@ -28,4 +28,5 @@ Recommend\ message=Recommend message in\ reply\ to=in reply to (Dialog)\ Link\ to\ message=Permanent link to this message (Dialog)\ Message\ number=Message number -(Dialog)\ Share=Share in social networks
\ No newline at end of file +(Dialog)\ Share=Share in social networks +Sponsored=Sponsored diff --git a/src/java/Global_ru.properties b/src/java/Global_ru.properties index cae0a5e6..2bf0909b 100644 --- a/src/java/Global_ru.properties +++ b/src/java/Global_ru.properties @@ -28,4 +28,5 @@ Recommend\ message=\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\ in\ reply\ to=\u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 (Dialog)\ Link\ to\ message=\u041f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u044d\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 (Dialog)\ Message\ number=\u041d\u043e\u043c\u0435\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f -(Dialog)\ Share=\u041f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445
\ No newline at end of file +(Dialog)\ Share=\u041f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u043e\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0442\u044f\u0445 +Sponsored=\u0420\u0435\u043a\u043b\u0430\u043c\u0430 diff --git a/src/java/com/juick/http/www/Discover.java b/src/java/com/juick/http/www/Discover.java index a9ae360a..62822ee4 100644 --- a/src/java/com/juick/http/www/Discover.java +++ b/src/java/com/juick/http/www/Discover.java @@ -17,6 +17,7 @@ */ package com.juick.http.www; +import com.juick.server.AdsQueries; import com.juick.server.MessagesQueries; import com.juick.server.TagQueries; import java.io.IOException; @@ -110,13 +111,24 @@ public class Discover { out.println("<div id=\"content\">"); if (mids.size() > 0) { + int ad_mid = 0; + if (visitor != null && paramShow == null && paramTag == 0 && paramSearch == null) { + ad_mid = AdsQueries.getAdMID(sql, visitor.UID); + if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) { + mids.add(0, ad_mid); + AdsQueries.logAdMID(sql, visitor.UID, ad_mid); + } else { + ad_mid = 0; + } + } + out.println("<ul>"); - PageTemplates.printMessages(out, sql, null, mids, visitor, locale, visitor == null ? 2 : 3); + PageTemplates.printMessages(out, sql, null, mids, visitor, locale, visitor == null ? 2 : 3, ad_mid); out.println("</ul>"); } if (visitor != null) { - if (mids.size() == 20) { + if (mids.size() >= 20) { String nextpage = "?before=" + mids.get(mids.size() - 1); if (paramShow != null) { nextpage += "&show=" + paramShow; diff --git a/src/java/com/juick/http/www/Home.java b/src/java/com/juick/http/www/Home.java index d2500993..2705d953 100644 --- a/src/java/com/juick/http/www/Home.java +++ b/src/java/com/juick/http/www/Home.java @@ -18,6 +18,7 @@ package com.juick.http.www; import com.juick.json.Users; +import com.juick.server.AdsQueries; import com.juick.server.MessagesQueries; import com.juick.server.PMQueries; import java.io.IOException; @@ -94,12 +95,24 @@ public class Home { out.println("<div id=\"content\">"); if (mids.size() > 0) { + int ad_mid = 0; + if (paramShow == null || paramShow.equals("top")) { + ad_mid = AdsQueries.getAdMID(sql, visitor.UID); + + if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) { + mids.add(0, ad_mid); + AdsQueries.logAdMID(sql, visitor.UID, ad_mid); + } else { + ad_mid = 0; + } + } + out.println("<ul>"); - PageTemplates.printMessages(out, sql, null, mids, visitor, locale, visitor == null ? 2 : 3); + PageTemplates.printMessages(out, sql, null, mids, visitor, locale, visitor == null ? 2 : 3, ad_mid); out.println("</ul>"); } - if (mids.size() == 20) { + if (mids.size() >= 20) { String nextpage = "?before=" + mids.get(mids.size() - 1); if (paramShow != null) { nextpage += "&show=" + paramShow; diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java index d63cb5f5..c7118277 100644 --- a/src/java/com/juick/http/www/PageTemplates.java +++ b/src/java/com/juick/http/www/PageTemplates.java @@ -357,11 +357,20 @@ public class PageTemplates { return msg; } - public static void printMessages(PrintWriter out, Connection sql, com.juick.User user, ArrayList<Integer> mids, com.juick.User visitor, Locale locale, int YandexID) { + public static void printMessages(PrintWriter out, Connection sql, com.juick.User user, ArrayList<Integer> mids, com.juick.User visitor, Locale locale, int YandexID, int ad_mid) { ResourceBundle rb = ResourceBundle.getBundle("Global", locale); ArrayList<com.juick.Message> msgs = MessagesQueries.getMessages(sql, mids); + for (int i = 0; i < msgs.size(); i++) { + com.juick.Message msg = msgs.get(i); + if (msg.MID == ad_mid) { + msgs.remove(i); + msgs.add(0, msg); + break; + } + } + ArrayList<Integer> blUIDs = new ArrayList<Integer>(20); if (visitor != null) { for (int i = 0; i < msgs.size(); i++) { @@ -372,7 +381,7 @@ public class PageTemplates { for (int i = 0; i < msgs.size(); i++) { - if (i == 1 && YandexID > 0) { + if (i == 1 && YandexID > 0 && ad_mid == 0) { out.println(" <li class=\"ads\"><div id=\"yandex_ad\"></div></li>"); out.println("<script type=\"text/javascript\">"); out.println("(function(w, d, n, s, t) {"); @@ -440,7 +449,11 @@ public class PageTemplates { out.println(" <div class=\"msg-cont\">"); out.println(" <div class=\"msg-menu\"><a href=\"#\" onclick=\"showMessageLinksDialog(" + msg.MID + "); return false\"></a></div>"); out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:" + tags + "</div>"); - out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\" title=\"" + msg.TimestampString + " GMT\">" + formatDate(msg.TimeAgo, msg.TimestampString, locale) + "</a></div>"); + out.print(" <div class=\"msg-ts\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "\" title=\"" + msg.TimestampString + " GMT\">" + formatDate(msg.TimeAgo, msg.TimestampString, locale) + "</a>"); + if (msg.MID == ad_mid) { + out.print(" · " + rb.getString("Sponsored")); + } + out.println("</div>"); if (msg.Place != null) { out.println(" <div class=\"msg-place\"><a href=\"/places/" + msg.Place.pid + "\">" + msg.Place.name + "</a></div>"); } diff --git a/src/java/com/juick/http/www/User.java b/src/java/com/juick/http/www/User.java index 64675044..5de54341 100644 --- a/src/java/com/juick/http/www/User.java +++ b/src/java/com/juick/http/www/User.java @@ -115,12 +115,12 @@ public class User { out.println("<div id=\"content\">"); out.println("<ul>"); if (mids.size() > 0) { - PageTemplates.printMessages(out, sql, user, mids, visitor, locale, visitor == null ? 4 : 5); + PageTemplates.printMessages(out, sql, user, mids, visitor, locale, visitor == null ? 4 : 5, 0); } out.println("</ul>"); - if (mids.size() == 20) { - String nextpage = "?before=" + mids.get(19); + if (mids.size() >= 20) { + String nextpage = "?before=" + mids.get(mids.size() - 1); if (paramShow != null) { nextpage += "&show=" + paramShow; } diff --git a/src/java/com/juick/http/www/UserThread.java b/src/java/com/juick/http/www/UserThread.java index 0d096aa1..1e81a728 100644 --- a/src/java/com/juick/http/www/UserThread.java +++ b/src/java/com/juick/http/www/UserThread.java @@ -130,8 +130,9 @@ public class UserThread { out.println(" <li id=\"msg-" + mid + "\" class=\"msg msgthread\">"); out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"//i.juick.com/a/" + msg.User.UID + ".png\" alt=\"" + msg.User.UName + "\"/></a></div>"); out.println(" <div class=\"msg-cont\">"); + out.println(" <div class=\"msg-menu\"><a href=\"#\" onclick=\"showMessageLinksDialog(" + msg.MID + "); return false\"></a></div>"); out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:" + tags + "</div>"); - out.println(" <div class=\"msg-ts\">" + PageTemplates.formatJSLocalTime(msg.TimestampString) + "<a href=\"#\" onclick=\"showMessageLinksDialog(" + msg.MID + "); return false\" class=\"msg-menu\"></a></div>"); + out.println(" <div class=\"msg-ts\">" + PageTemplates.formatJSLocalTime(msg.TimestampString) + "</div>"); if (msg.Place != null) { out.println(" <div class=\"msg-place\"><a href=\"/places/" + msg.Place.pid + "\">" + msg.Place.name + "</a></div>"); } |