This repository has been archived by the owner on Aug 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
8,811 additions
and
206 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
PrivateConstants.java | ||
target/generated-sources/apt/com/aknow/a_know_home/meta | ||
target | ||
war/WEB-INF/appengine-generated | ||
war/WEB-INF/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/aknow/a_know_home/controller/AdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.aknow.a_know_home.controller; | ||
|
||
import org.slim3.controller.Controller; | ||
import org.slim3.controller.Navigation; | ||
|
||
import com.aknow.a_know_home.util.PrivateConstants; | ||
|
||
public class AdminController extends Controller { | ||
|
||
private final String password = PrivateConstants.HASHED_PASS; | ||
|
||
@Override | ||
public Navigation run() throws Exception { | ||
|
||
String function = requestScope("function"); | ||
String send_pass = requestScope("password"); | ||
|
||
if(!this.password.equals(send_pass)){ | ||
return this.forward("/"); | ||
}else{ | ||
return this.redirect(PrivateConstants.ADMIN_MENU.get(function)); | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/main/java/com/aknow/a_know_home/controller/GetBlogRssController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.aknow.a_know_home.controller; | ||
|
||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.net.URLEncoder; | ||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Calendar; | ||
import java.util.Collection; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import net.arnx.jsonic.JSON; | ||
|
||
import org.slim3.controller.Controller; | ||
import org.slim3.controller.Navigation; | ||
import org.slim3.memcache.Memcache; | ||
|
||
import com.aknow.a_know_home.util.UtilityMethods; | ||
|
||
import de.nava.informa.core.ItemIF; | ||
|
||
public class GetBlogRssController extends Controller { | ||
|
||
@Override | ||
public Navigation run() throws Exception { | ||
this.response.setContentType("application/json; charset=UTF-8"); | ||
|
||
|
||
Map<String, ArrayList<Map<String, String>>> map = new LinkedHashMap<String, ArrayList<Map<String, String>>>(); | ||
ArrayList<Map<String, String>> array = new ArrayList<Map<String, String>>(); | ||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); | ||
Calendar cal1 = Calendar.getInstance(); | ||
|
||
@SuppressWarnings("rawtypes") | ||
Collection list = UtilityMethods.getRss("http://d.hatena.ne.jp/a-know/rss", "yyyy-MM-dd"); | ||
|
||
@SuppressWarnings("unchecked") | ||
ItemIF[] items = (ItemIF[]) list.toArray(new ItemIF[0]); | ||
|
||
for (int i = 0; i < 5; i++) { | ||
Map<String, String> entry = new HashMap<String, String>(); | ||
entry.put("target_title", items[i].getTitle()); | ||
entry.put("target_url", items[i].getLink().toString()); | ||
entry.put("description", items[i].getDescription()); | ||
Date tmpDate = (items[i].getDate()); | ||
cal1.setTime(tmpDate); | ||
cal1.add(Calendar.HOUR, 9); | ||
entry.put("date", sdf1.format(cal1.getTime())); | ||
|
||
String url_str2 = "http://api.b.st-hatena.com/entry.count?url=" + URLEncoder.encode(items[i].getLink().toString(), "utf-8"); | ||
String is_str = Memcache.get(url_str2 + sdf2.format(cal1.getTime())); | ||
if (is_str == null){ | ||
InputStream is = new URL(url_str2).openStream(); | ||
is_str = UtilityMethods.inputStreemToString(is); | ||
Memcache.put(url_str2 + sdf2.format(cal1.getTime()), is_str); | ||
} | ||
entry.put("hatebu_count",is_str); | ||
entry.put("hatebu_url", "http://b.hatena.ne.jp/entry/" + items[i].getLink().toString()); | ||
array.add(entry); | ||
} | ||
map.put("entries", array); | ||
|
||
|
||
JSON.encode(map, this.response.getOutputStream()); | ||
|
||
return null; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/main/java/com/aknow/a_know_home/controller/GetBukumaController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.aknow.a_know_home.controller; | ||
|
||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.net.URLEncoder; | ||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Calendar; | ||
import java.util.Collection; | ||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import net.arnx.jsonic.JSON; | ||
|
||
import org.slim3.controller.Controller; | ||
import org.slim3.controller.Navigation; | ||
import org.slim3.memcache.Memcache; | ||
|
||
import com.aknow.a_know_home.util.UtilityMethods; | ||
|
||
import de.nava.informa.core.ItemIF; | ||
|
||
public class GetBukumaController extends Controller { | ||
|
||
@Override | ||
public Navigation run() throws Exception { | ||
this.response.setContentType("application/json; charset=UTF-8"); | ||
|
||
|
||
Map<String, ArrayList<Map<String, String>>> map = new LinkedHashMap<String, ArrayList<Map<String, String>>>(); | ||
ArrayList<Map<String, String>> array = new ArrayList<Map<String, String>>(); | ||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
|
||
Calendar cal1 = Calendar.getInstance(); | ||
|
||
@SuppressWarnings("rawtypes") | ||
Collection list = UtilityMethods.getRss("http://b.hatena.ne.jp/a-know/rss", "yyyy-MM-dd-HH"); | ||
|
||
@SuppressWarnings("unchecked") | ||
ItemIF[] items = (ItemIF[]) list.toArray(new ItemIF[0]); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
Map<String, String> entry = new HashMap<String, String>(); | ||
entry.put("target_title", items[i].getTitle()); | ||
entry.put("target_url", items[i].getLink().toString()); | ||
entry.put("comment", items[i].getDescription()); | ||
Date tmpDate = (items[i].getDate()); | ||
cal1.setTime(tmpDate); | ||
cal1.add(Calendar.HOUR, 9); | ||
entry.put("date", sdf1.format(cal1.getTime())); | ||
|
||
String url_str2 = "http://api.b.st-hatena.com/entry.count?url=" + URLEncoder.encode(items[i].getLink().toString(), "utf-8"); | ||
String is_str = Memcache.get(url_str2); | ||
if(is_str == null){ | ||
InputStream is = new URL(url_str2).openStream(); | ||
is_str = UtilityMethods.inputStreemToString(is); | ||
Memcache.put(url_str2, is_str); | ||
} | ||
entry.put("hatebu_count", is_str); | ||
entry.put("hatebu_url", "http://b.hatena.ne.jp/entry/" + items[i].getLink().toString()); | ||
array.add(entry); | ||
} | ||
map.put("entries", array); | ||
|
||
|
||
JSON.encode(map, this.response.getOutputStream()); | ||
|
||
return null; | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
src/main/java/com/aknow/a_know_home/controller/GetImaCocoController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.aknow.a_know_home.controller; | ||
|
||
import java.net.URL; | ||
import java.util.LinkedHashMap; | ||
|
||
import net.arnx.jsonic.JSON; | ||
|
||
import org.scribe.builder.ServiceBuilder; | ||
import org.scribe.builder.api.DefaultApi10a; | ||
import org.scribe.model.OAuthRequest; | ||
import org.scribe.model.Response; | ||
import org.scribe.model.Token; | ||
import org.scribe.model.Verb; | ||
import org.scribe.oauth.OAuthService; | ||
import org.slim3.controller.Controller; | ||
import org.slim3.controller.Navigation; | ||
|
||
import com.aknow.a_know_home.util.PrivateConstants; | ||
|
||
public class GetImaCocoController extends Controller { | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public Navigation run() throws Exception { | ||
this.response.setContentType("application/json; charset=UTF-8"); | ||
|
||
DefaultApi10a api = new DefaultApi10a() { | ||
@Override | ||
public String getRequestTokenEndpoint() { | ||
return "https://www.hatena.com/oauth/initiate"; | ||
} | ||
|
||
public String getAuthorizationUrl(Token arg0) { | ||
return "https://www.hatena.ne.jp/oauth/authorize?oauth_token=" + arg0.getToken(); | ||
} | ||
|
||
@Override | ||
public String getAccessTokenEndpoint() { | ||
return "https://www.hatena.com/oauth/token"; | ||
} | ||
}; | ||
|
||
OAuthService service = new ServiceBuilder().provider(api) | ||
.apiKey(PrivateConstants.HATENA_API_KEY).apiSecret(PrivateConstants.HATENA_API_SECRET).scope("read_public").build(); | ||
|
||
Token accessToken = new Token(PrivateConstants.HATENA_ACCESS_TOKEN, PrivateConstants.HATENA_TOKEN_SECRET); | ||
|
||
OAuthRequest req = new OAuthRequest(Verb.GET, "http://c.hatena.com/api/v1/history.json?name=a-know&l=10"); | ||
|
||
service.signRequest(accessToken, req); | ||
|
||
Response res = null; | ||
int i = 0; | ||
while(res == null){ | ||
try{ | ||
res = req.send(); | ||
}catch(Exception e){ | ||
i++; | ||
if(i > 10){ | ||
throw e; | ||
} | ||
} | ||
} | ||
|
||
|
||
@SuppressWarnings("rawtypes") | ||
LinkedHashMap lmap = (LinkedHashMap) JSON.decode(res.getBody()); | ||
|
||
Object stats = JSON.decode(new URL("http://c.hatena.com/a-know/stats.json").openStream()); | ||
lmap.put("stats", stats); | ||
|
||
JSON.encode(lmap, this.response.getOutputStream()); | ||
|
||
return null; | ||
} | ||
} |
Oops, something went wrong.