Permalink
Browse files

init

  • Loading branch information...
0 parents commit a372220409cb4e337637dc248d41bf21ba3e2a6e fukaoi committed Sep 13, 2012
Showing with 732 additions and 0 deletions.
  1. +4 −0 README.md
  2. +83 −0 actions.js
  3. +53 −0 batch.js
  4. +48 −0 config.js
  5. +197 −0 config/jetty.xml
  6. +11 −0 config/log4j.properties
  7. +11 −0 create_member.sql
  8. +7 −0 main.js
  9. +95 −0 model.js
  10. +36 −0 public/stylesheets/page.css
  11. +97 −0 service.js
  12. +14 −0 skins/base.html
  13. +8 −0 skins/complete.html
  14. +13 −0 skins/email/batch.tpl
  15. +6 −0 skins/email/batchPart.tpl
  16. +19 −0 skins/email/confirm.tpl
  17. +5 −0 skins/error.html
  18. +20 −0 skins/index.html
  19. +5 −0 skins/notfound.html
@@ -0,0 +1,4 @@
+# it_study_search
+
+Programming web application of RingoJS(Server Side JavaScript)
+Japanese tech study reservation system
@@ -0,0 +1,83 @@
+var {Response} = require('ringo/webapp/response');
+var {Member} = require('./model.js');
+var {Service} = require('./service.js');
+
+/**
+ * index page
+ */
+exports.index = function (req) {
+ return Response.skin(module.resolve('skins/index.html'), {
+ title: 'IT勉強会サーチ',
+ headMessage: '検索したい勉強会キーワードと受け取るメールアドレスを入力してください'
+ });
+};
+
+/**
+ * confirm page (※POST Only)
+ */
+exports.confirm = {};
+exports.confirm.POST = function (req) {
+ Service.email = req.params['email'];
+ Service.keyword = req.params['keyword'];
+ if (Service.email === "" || Service.keyword === "") {
+ return Response.skin(module.resolve('skins/index.html'), {
+ title: 'エラー',
+ errorMessage: '入力した値に問題があります、再度入力してください'
+ });
+ }
+
+ if (Member.check() === false) {
+ return Response.skin(module.resolve('skins/index.html'), {
+ title: 'エラー',
+ errorMessage: '既に申し込み済みのメールが存在しております、' +
+ 'お手元のメールを確認の上そちらを先に登録完了ください'
+ });
+ }
+
+ var uid = Service.createUniqId();
+ Member.confirm(uid);
+ Service.sendMail(Service.email,
+ Service.textFormat.confirm(uid));
+ return Response.skin(module.resolve('skins/index.html'), {
+ title: '受付致しました',
+ headMessage: '入力いただいたメールアドレスに登録完了のURLを送信しました'
+ });
+};
+
+/**
+ * complete page
+ */
+exports.complete = {};
+exports.complete.GET = function(req) {
+ var uid = req.params['uid'];
+ if (uid === "") {
+ return Response.skin(module.resolve('skins/complete.html'), {
+ title: 'エラー',
+ errorMessage: 'URLに問題があります'});
+ }
+
+ Member.complete(uid);
+ return Response.skin(module.resolve('skins/complete.html'), {
+ title: '登録が完了しました',
+ headMessage: '今後、検索ワードにマッチした勉強会をメールでお知らせ致します'
+ });
+};
+
+/**
+ * withdraw page
+ */
+exports.withdraw = {};
+exports.withdraw.GET = function(req) {
+ var uid = req.params['uid'];
+ if (uid === "") {
+ return Response.skin(module.resolve('skins/complete.html'),
+ { title: 'エラー',
+ errorMessage: 'URLに問題があります'});
+ }
+
+ Member.withdraw(uid);
+ return Response.skin(module.resolve('skins/complete.html'), {
+ title: '退会が完了しました',
+ headMessage: '今後、IT 勉強会サーチメールは送信されなくなります'
+ });
+};
@@ -0,0 +1,53 @@
+var {Response} = require('ringo/webapp/response');
+var {Member} = require('./model.js');
+var config = require('./config.js');
+var {Service} = require('./service.js');
+
+var {DateTime} = com.google.gdata.data;
+var cservice = com.google.gdata.client.calendar.CalendarService("");
+var eventFeedUrl = java.net.URL(config.calendarUrl);
+var query = com.google.gdata.client.calendar.CalendarQuery(eventFeedUrl);
+var events = com.google.gdata.data.calendar.CalendarEventFeed().class;
+
+/**
+ * メイン処理
+ */
+var main = function(email, uid, keyword) {
+ var entry = "", text = "";
+ query.setFullTextQuery(keyword);
+ query.setMinimumStartTime(
+ DateTime.parseDateTime(Service.searchTerm.start()));
+ query.setMaximumStartTime(
+ DateTime.parseDateTime(Service.searchTerm.end()));
+
+ var resultFeed = cservice.query(query, events);
+ var count = resultFeed.getEntries().size();
+
+ if(count === 0) {return;}
+
+ for (var i = 0; i < count; i++) {
+ entry = resultFeed.getEntries().get(i);
+ text += Service.textFormat.batchPart(
+ entry.getTitle().getPlainText(),
+ Service.modifySummary(entry.getTextContent()
+ .getContent()
+ .getPlainText())
+ );
+ }
+ var textFormat = Service.textFormat.batch(uid, keyword, text);
+ Service.sendMail(email, textFormat);
+};
+
+/**
+ * mainファンクションを呼び出す
+ */
+if (require.main === module) {
+ try {
+ var results = Member.getBatchInfo();
+ for each(var result in results) {
+ main(result.email, result.uid, result.keyword);
+ }
+ } catch (error) {
+ print(error);
+ }
+}
@@ -0,0 +1,48 @@
+// URL routing. Using require() here to statically import modules will
+// improve performance, but may cause hard to debug cyclic module dependencies
+// in case any app module requires this module.
+exports.urls = [
+ ['/', './actions'],
+];
+
+// Middleware stack as an array of middleware factories. These will be
+// wrapped around the app with the first item in the array becoming the
+// outermost layer in the resulting app.
+exports.middleware = [
+ require('ringo/middleware/gzip').middleware,
+ require('ringo/middleware/etag').middleware,
+ require('ringo/middleware/static').middleware(module.resolve('public')),
+ // require('ringo/middleware/responselog').middleware,
+ require('ringo/middleware/error').middleware('skins/error.html'),
+ require('ringo/middleware/notfound').middleware('skins/notfound.html'),
+];
+
+// The JSGI application. This is a function that takes a request object
+// as argument and returns a response object.
+exports.app = require('ringo/webapp').handleRequest;
+
+// Standard skin macros and filters
+exports.macros = [
+ require('ringo/skin/macros'),
+ require('ringo/skin/filters'),
+];
+
+// Default character encoding and MIME type for this app
+exports.charset = 'UTF-8';
+exports.contentType = 'text/html';
+
+// App config
+exports.calendarUrl = 'http://www.google.com/calendar/feeds/fvijvohm91uifvd9hratehf65k%40group.calendar.google.com/public/basic';
+exports.email = {
+ from: 'it_study_search@fukaoi.org',
+ subject: 'IT勉強会サーチメール'
+};
+
+exports.durationDays = 60;
+exports.fqdn = 'http://localhost:8080';
+exports.db = {
+ url: 'jdbc:mysql://localhost/test',
+ driver: 'com.mysql.jdbc.Driver',
+ username: 'xxxxxxxx',
+ password: 'xxxxxxxx'
+};
@@ -0,0 +1,197 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
+
+<!-- =============================================================== -->
+<!-- Configure the Jetty Server -->
+<!-- -->
+<!-- Documentation of this file format can be found at: -->
+<!-- http://docs.codehaus.org/display/JETTY/jetty.xml -->
+<!-- -->
+<!-- =============================================================== -->
+
+
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+
+ <!-- =========================================================== -->
+ <!-- Server Thread Pool -->
+ <!-- =========================================================== -->
+ <Set name="ThreadPool">
+ <!-- Default queued blocking threadpool -->
+ <New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
+ <Set name="minThreads">8</Set>
+ <Set name="maxThreads">254</Set>
+ </New>
+
+ <!-- Optional Java 5 bounded threadpool with job queue -->
+ <!--
+ <New class="org.eclipse.jetty.util.thread.ExecutorThreadPool">
+ <Arg type="int">32</Arg>
+ <Arg type="int">256</Arg>
+ <Arg type="int">60000</Arg>
+ </New>
+ -->
+ </Set>
+
+
+
+ <!-- =========================================================== -->
+ <!-- Set connectors -->
+ <!-- =========================================================== -->
+ <!-- One of each type! -->
+ <!-- =========================================================== -->
+
+ <!-- Use this connector for many frequently idle connections
+ and for threadless continuations.
+ -->
+
+ <Call name="addConnector">
+ <Arg>
+ <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
+ <Set name="host"><Property name="host"/></Set>
+ <Set name="port"><Property name="port" default="8080"/></Set>
+ <Set name="maxIdleTime">300000</Set>
+ <Set name="Acceptors">8</Set>
+ <Set name="statsOn">false</Set>
+ <Set name="confidentialPort">8443</Set>
+ <Set name="lowResourcesConnections">20000</Set>
+ <Set name="lowResourcesMaxIdleTime">5000</Set>
+ </New>
+ </Arg>
+ </Call>
+
+ <!-- Use this connector if NIO is not available.
+ <Call name="addConnector">
+ <Arg>
+ <New class="org.eclipse.jetty.server.bio.SocketConnector">
+ <Set name="host"><Property name="host"/></Set>
+ <Set name="port"><Property name="port" default="8080"/></Set>
+ <Set name="maxIdleTime">50000</Set>
+ <Set name="lowResourceMaxIdleTime">1500</Set>
+ </New>
+ </Arg>
+ </Call>
+ -->
+
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+ <!-- To add a HTTPS SSL listener -->
+ <!-- see jetty-ssl.xml to add an ssl connector. use -->
+ <!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
+ <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
+
+ <!-- =========================================================== -->
+ <!-- Set up global session ID manager -->
+ <!-- =========================================================== -->
+ <Set name="sessionIdManager">
+ <New class="org.eclipse.jetty.server.session.HashSessionIdManager">
+ <Set name="workerName">node1</Set>
+ </New>
+ </Set>
+
+ <!-- =========================================================== -->
+ <!-- Set handler Collection Structure -->
+ <!-- =========================================================== -->
+ <Set name="handler">
+ <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
+ <Set name="handlers">
+ <Array type="org.eclipse.jetty.server.Handler">
+ <Item>
+ <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
+ </Item>
+ <Item>
+ <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
+ </Item>
+ </Array>
+ </Set>
+ </New>
+ </Set>
+
+ <!-- =========================================================== -->
+ <!-- Configure the webapp deployer. -->
+ <!-- A webapp deployer will deploy standard webapps discovered -->
+ <!-- in a directory at startup, without the need for additional -->
+ <!-- configuration files. It does not support hot deploy or -->
+ <!-- non standard contexts (see ContextDeployer above). -->
+ <!-- -->
+ <!-- This deployer is configured to deploy webapps from the -->
+ <!-- $JETTY_HOME/webapps directory -->
+ <!-- -->
+ <!-- Normally only one type of deployer need be used. -->
+ <!-- -->
+ <!-- =========================================================== -->
+ <!--
+ <Call name="addBean">
+ <Arg>
+ <New class="org.eclipse.jetty.deploy.WebAppDeployer">
+ <Set name="contexts"><Ref id="Contexts"/></Set>
+ <Set name="webAppDir"><SystemProperty name="jetty.home" default="."/>/webapps</Set>
+ <Set name="parentLoaderPriority">false</Set>
+ <Set name="extract">true</Set>
+ <Set name="allowDuplicates">false</Set>
+ <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
+ </New>
+ </Arg>
+ </Call>
+ -->
+
+ <!-- =========================================================== -->
+ <!-- Configure Authentication Login Service -->
+ <!-- Realms may be configured for the entire server here, or -->
+ <!-- they can be configured for a specific web app in a context -->
+ <!-- configuration (see $(jetty.home)/contexts/test.xml for an -->
+ <!-- example). -->
+ <!-- =========================================================== -->
+ <!--
+ <Call name="addBean">
+ <Arg>
+ <New class="org.eclipse.jetty.security.HashLoginService">
+ <Set name="name">Test Realm</Set>
+ <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
+ <Set name="refreshInterval">0</Set>
+ </New>
+ </Arg>
+ </Call>
+ -->
+
+ <!-- =========================================================== -->
+ <!-- Configure Request Log to log directory -->
+ <!-- =========================================================== -->
+ <!--
+ <Ref id="RequestLog">
+ <Set name="requestLog">
+ <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
+ <Set name="filename"><SystemProperty name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Set>
+ <Set name="filenameDateFormat">yyyy_MM_dd</Set>
+ <Set name="retainDays">90</Set>
+ <Set name="append">true</Set>
+ <Set name="extended">true</Set>
+ <Set name="logCookies">false</Set>
+ <Set name="LogTimeZone">CET</Set>
+ </New>
+ </Set>
+ </Ref>
+ -->
+
+ <!-- =========================================================== -->
+ <!-- Configure Request Log to standard error output (console) -->
+ <!-- =========================================================== -->
+ <!--
+ <Ref id="requestLog">
+ <Set name="requestLog">
+ <New id="requestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
+ <Set name="extended">true</Set>
+ <Set name="logCookies">false</Set>
+ <Set name="LogTimeZone">CET</Set>
+ </New>
+ </Set>
+ </Ref>
+ -->
+
+ <!-- =========================================================== -->
+ <!-- extra options -->
+ <!-- =========================================================== -->
+ <Set name="stopAtShutdown">true</Set>
+ <Set name="sendServerVersion">true</Set>
+ <Set name="sendDateHeader">true</Set>
+ <Set name="gracefulShutdown">1000</Set>
+
+</Configure>
Oops, something went wrong.

0 comments on commit a372220

Please sign in to comment.