aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--build.xml71
-rw-r--r--nbproject/ant-deploy.xml37
-rw-r--r--nbproject/build-impl.xml1090
-rw-r--r--nbproject/genfiles.properties8
-rw-r--r--nbproject/project.properties87
-rw-r--r--nbproject/project.xml48
-rw-r--r--src/conf/MANIFEST.MF2
-rw-r--r--src/java/Blogs.properties14
-rw-r--r--src/java/Blogs_ru.properties14
-rw-r--r--src/java/Chats.properties5
-rw-r--r--src/java/Chats_ru.properties5
-rw-r--r--src/java/Global.properties17
-rw-r--r--src/java/Global_ru.properties17
-rw-r--r--src/java/Login.properties6
-rw-r--r--src/java/Login_ru.properties6
-rw-r--r--src/java/Map.properties5
-rw-r--r--src/java/Map_ru.properties5
-rw-r--r--src/java/Photos.properties4
-rw-r--r--src/java/Photos_ru.properties4
-rw-r--r--src/java/User.properties16
-rw-r--r--src/java/User_ru.properties16
-rw-r--r--src/java/com/juick/http/www/Blogs.java217
-rw-r--r--src/java/com/juick/http/www/Chats.java77
-rw-r--r--src/java/com/juick/http/www/Login.java129
-rw-r--r--src/java/com/juick/http/www/Main.java173
-rw-r--r--src/java/com/juick/http/www/Map.java64
-rw-r--r--src/java/com/juick/http/www/NewMessage.java37
-rw-r--r--src/java/com/juick/http/www/PageTemplates.java377
-rw-r--r--src/java/com/juick/http/www/Photos.java100
-rw-r--r--src/java/com/juick/http/www/RootRedirects.java53
-rw-r--r--src/java/com/juick/http/www/User.java198
-rw-r--r--src/java/com/juick/http/www/UserThread.java298
-rw-r--r--src/java/com/juick/http/www/Utils.java112
-rw-r--r--web/META-INF/context.xml2
-rw-r--r--web/WEB-INF/web.xml16
36 files changed, 3333 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..d3bae3d4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+/build/
+/dist/
+/nbproject/private/ \ No newline at end of file
diff --git a/build.xml b/build.xml
new file mode 100644
index 00000000..94203053
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<!-- By default, only the Clean and Build commands use this build script. -->
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
+<!-- the Compile on Save feature is turned off for the project. -->
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
+<!-- in the project's Project Properties dialog box.-->
+<project name="com.juick.http.www" default="default" basedir=".">
+ <description>Builds, tests, and runs the project com.juick.http.www.</description>
+ <import file="nbproject/build-impl.xml"/>
+ <!--
+
+ There exist several targets which are by default empty and which can be
+ used for execution of your tasks. These targets are usually executed
+ before and after some main targets. They are:
+
+ -pre-init: called before initialization of project properties
+ -post-init: called after initialization of project properties
+ -pre-compile: called before javac compilation
+ -post-compile: called after javac compilation
+ -pre-compile-single: called before javac compilation of single file
+ -post-compile-single: called after javac compilation of single file
+ -pre-compile-test: called before javac compilation of JUnit tests
+ -post-compile-test: called after javac compilation of JUnit tests
+ -pre-compile-test-single: called before javac compilation of single JUnit test
+ -post-compile-test-single: called after javac compilation of single JUunit test
+ -pre-dist: called before archive building
+ -post-dist: called after archive building
+ -post-clean: called after cleaning build products
+ -pre-run-deploy: called before deploying
+ -post-run-deploy: called after deploying
+
+ Example of pluging an obfuscator after the compilation could look like
+
+ <target name="-post-compile">
+ <obfuscate>
+ <fileset dir="${build.classes.dir}"/>
+ </obfuscate>
+ </target>
+
+ For list of available properties check the imported
+ nbproject/build-impl.xml file.
+
+
+ Other way how to customize the build is by overriding existing main targets.
+ The target of interest are:
+
+ init-macrodef-javac: defines macro for javac compilation
+ init-macrodef-junit: defines macro for junit execution
+ init-macrodef-debug: defines macro for class debugging
+ do-dist: archive building
+ run: execution of project
+ javadoc-build: javadoc generation
+
+ Example of overriding the target for project execution could look like
+
+ <target name="run" depends="<PROJNAME>-impl.jar">
+ <exec dir="bin" executable="launcher.exe">
+ <arg file="${dist.jar}"/>
+ </exec>
+ </target>
+
+ Notice that overridden target depends on jar target and not only on
+ compile target as regular run target does. Again, for list of available
+ properties which you can use check the target you are overriding in
+ nbproject/build-impl.xml file.
+
+ -->
+</project>
diff --git a/nbproject/ant-deploy.xml b/nbproject/ant-deploy.xml
new file mode 100644
index 00000000..cbfe67c3
--- /dev/null
+++ b/nbproject/ant-deploy.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="-deploy-ant" basedir=".">
+ <target name="-init" if="deploy.ant.enabled">
+ <property file="${deploy.ant.properties.file}"/>
+ <tempfile property="temp.module.folder" prefix="tomcat" destdir="${java.io.tmpdir}"/>
+ <unwar src="${deploy.ant.archive}" dest="${temp.module.folder}">
+ <patternset includes="META-INF/context.xml"/>
+ </unwar>
+ <xmlproperty file="${temp.module.folder}/META-INF/context.xml"/>
+ <delete dir="${temp.module.folder}"/>
+ </target>
+ <target name="-check-credentials" if="deploy.ant.enabled" depends="-init">
+ <fail message="Tomcat password has to be passed as tomcat.password property.">
+ <condition>
+ <not>
+ <isset property="tomcat.password"/>
+ </not>
+ </condition>
+ </fail>
+ </target>
+ <target name="-deploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials">
+ <echo message="Deploying ${deploy.ant.archive} to ${Context(path)}"/>
+ <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
+ classpath="${tomcat.home}/lib/catalina-ant.jar"/>
+ <deploy url="${tomcat.url}/manager/text" username="${tomcat.username}"
+ password="${tomcat.password}" path="${Context(path)}"
+ war="${deploy.ant.archive}"/>
+ <property name="deploy.ant.client.url" value="${tomcat.url}${Context(path)}"/>
+ </target>
+ <target name="-undeploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials">
+ <echo message="Undeploying ${Context(path)}"/>
+ <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"
+ classpath="${tomcat.home}/lib/catalina-ant.jar"/>
+ <undeploy url="${tomcat.url}/manager/text" username="${tomcat.username}"
+ password="${tomcat.password}" path="${Context(path)}"/>
+ </target>
+</project>
diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
new file mode 100644
index 00000000..267f24af
--- /dev/null
+++ b/nbproject/build-impl.xml
@@ -0,0 +1,1090 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ *** GENERATED FROM project.xml - DO NOT EDIT ***
+ *** EDIT ../build.xml INSTEAD ***
+
+ For the purpose of easier reading the script
+ is divided into following sections:
+ - initialization
+ - compilation
+ - dist
+ - execution
+ - debugging
+ - javadoc
+ - junit compilation
+ - junit execution
+ - junit debugging
+ - cleanup
+
+ -->
+<project xmlns:webproject1="http://www.netbeans.org/ns/web-project/1" xmlns:webproject2="http://www.netbeans.org/ns/web-project/2" xmlns:webproject3="http://www.netbeans.org/ns/web-project/3" basedir=".." default="default" name="com.juick.http.www-impl">
+ <import file="ant-deploy.xml"/>
+ <fail message="Please build using Ant 1.7.1 or higher.">
+ <condition>
+ <not>
+ <antversion atleast="1.7.1"/>
+ </not>
+ </condition>
+ </fail>
+ <target depends="dist,javadoc" description="Build whole project." name="default"/>
+ <!--
+ INITIALIZATION SECTION
+ -->
+ <target name="-pre-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="-pre-init" name="-init-private">
+ <property file="nbproject/private/private.properties"/>
+ </target>
+ <target depends="-pre-init,-init-private" name="-init-user">
+ <property file="${user.properties.file}"/>
+ <!-- The two properties below are usually overridden -->
+ <!-- by the active platform. Just a fallback. -->
+ <property name="default.javac.source" value="1.4"/>
+ <property name="default.javac.target" value="1.4"/>
+ </target>
+ <target depends="-pre-init,-init-private,-init-user" name="-init-project">
+ <property file="nbproject/project.properties"/>
+ </target>
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" if="dist.ear.dir" name="-do-ear-init"/>
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
+ <condition property="have.tests">
+ <or>
+ <available file="${test.src.dir}"/>
+ </or>
+ </condition>
+ <condition property="have.sources">
+ <or>
+ <available file="${src.dir}"/>
+ </or>
+ </condition>
+ <condition property="netbeans.home+have.tests">
+ <and>
+ <isset property="netbeans.home"/>
+ <isset property="have.tests"/>
+ </and>
+ </condition>
+ <condition property="no.javadoc.preview">
+ <isfalse value="${javadoc.preview}"/>
+ </condition>
+ <property name="javac.compilerargs" value=""/>
+ <condition property="no.deps">
+ <and>
+ <istrue value="${no.dependencies}"/>
+ </and>
+ </condition>
+ <condition property="no.dist.ear.dir">
+ <not>
+ <isset property="dist.ear.dir"/>
+ </not>
+ </condition>
+ <property name="build.web.excludes" value="${build.classes.excludes}"/>
+ <condition property="do.compile.jsps">
+ <istrue value="${compile.jsps}"/>
+ </condition>
+ <condition property="do.debug.server">
+ <or>
+ <not>
+ <isset property="debug.server"/>
+ </not>
+ <istrue value="${debug.server}"/>
+ <and>
+ <not>
+ <istrue value="${debug.server}"/>
+ </not>
+ <not>
+ <istrue value="${debug.client}"/>
+ </not>
+ </and>
+ </or>
+ </condition>
+ <condition property="do.debug.client">
+ <istrue value="${debug.client}"/>
+ </condition>
+ <condition property="do.display.browser">
+ <istrue value="${display.browser}"/>
+ </condition>
+ <condition property="do.display.browser.debug">
+ <and>
+ <isset property="do.display.browser"/>
+ <not>
+ <isset property="do.debug.client"/>
+ </not>
+ </and>
+ </condition>
+ <available file="${conf.dir}/MANIFEST.MF" property="has.custom.manifest"/>
+ <available file="${persistence.xml.dir}/persistence.xml" property="has.persistence.xml"/>
+ <condition property="do.war.package.with.custom.manifest">
+ <isset property="has.custom.manifest"/>
+ </condition>
+ <condition property="do.war.package.without.custom.manifest">
+ <not>
+ <isset property="has.custom.manifest"/>
+ </not>
+ </condition>
+ <condition property="do.tmp.war.package.with.custom.manifest">
+ <and>
+ <isset property="has.custom.manifest"/>
+ <or>
+ <isfalse value="${directory.deployment.supported}"/>
+ <isset property="dist.ear.dir"/>
+ </or>
+ </and>
+ </condition>
+ <condition property="do.tmp.war.package.without.custom.manifest">
+ <and>
+ <not>
+ <isset property="has.custom.manifest"/>
+ </not>
+ <or>
+ <isfalse value="${directory.deployment.supported}"/>
+ <isset property="dist.ear.dir"/>
+ </or>
+ </and>
+ </condition>
+ <condition property="do.tmp.war.package">
+ <or>
+ <isfalse value="${directory.deployment.supported}"/>
+ <isset property="dist.ear.dir"/>
+ </or>
+ </condition>
+ <property name="build.meta.inf.dir" value="${build.web.dir}/META-INF"/>
+ <condition else="" property="application.args.param" value="${application.args}">
+ <and>
+ <isset property="application.args"/>
+ <not>
+ <equals arg1="${application.args}" arg2="" trim="true"/>
+ </not>
+ </and>
+ </condition>
+ <property name="source.encoding" value="${file.encoding}"/>
+ <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
+ <and>
+ <isset property="javadoc.encoding"/>
+ <not>
+ <equals arg1="${javadoc.encoding}" arg2=""/>
+ </not>
+ </and>
+ </condition>
+ <property name="javadoc.encoding.used" value="${source.encoding}"/>
+ <property name="includes" value="**"/>
+ <property name="excludes" value=""/>
+ <property name="runmain.jvmargs" value=""/>
+ <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
+ <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
+ <and>
+ <isset property="endorsed.classpath"/>
+ <length length="0" string="${endorsed.classpath}" when="greater"/>
+ </and>
+ </condition>
+ <condition else="false" property="jdkBug6558476">
+ <and>
+ <matches pattern="1\.[56]" string="${java.specification.version}"/>
+ <not>
+ <os family="unix"/>
+ </not>
+ </and>
+ </condition>
+ <property name="javac.fork" value="${jdkBug6558476}"/>
+ </target>
+ <target depends="init" name="-init-cos" unless="deploy.on.save">
+ <condition property="deploy.on.save" value="true">
+ <or>
+ <istrue value="${j2ee.deploy.on.save}"/>
+ <istrue value="${j2ee.compile.on.save}"/>
+ </or>
+ </condition>
+ </target>
+ <target name="-post-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
+ <fail unless="src.dir">Must set src.dir</fail>
+ <fail unless="test.src.dir">Must set test.src.dir</fail>
+ <fail unless="build.dir">Must set build.dir</fail>
+ <fail unless="build.web.dir">Must set build.web.dir</fail>
+ <fail unless="build.generated.dir">Must set build.generated.dir</fail>
+ <fail unless="dist.dir">Must set dist.dir</fail>
+ <fail unless="build.classes.dir">Must set build.classes.dir</fail>
+ <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
+ <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
+ <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
+ <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
+ <fail unless="dist.war">Must set dist.war</fail>
+ <condition property="missing.j2ee.server.home">
+ <and>
+ <matches pattern="j2ee.server.home" string="${j2ee.platform.classpath}"/>
+ <not>
+ <isset property="j2ee.server.home"/>
+ </not>
+ </and>
+ </condition>
+ <fail if="missing.j2ee.server.home">
+The Java EE server classpath is not correctly set up - server home directory is missing.
+Either open the project in the IDE and assign the server or setup the server classpath manually.
+For example like this:
+ ant -Dj2ee.server.home=&lt;app_server_installation_directory&gt;
+ </fail>
+ <fail unless="j2ee.platform.classpath">
+The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}.
+Either open the project in the IDE and assign the server or setup the server classpath manually.
+For example like this:
+ ant -Duser.properties.file=&lt;path_to_property_file&gt; (where you put the property "j2ee.platform.classpath" in a .properties file)
+or ant -Dj2ee.platform.classpath=&lt;server_classpath&gt; (where no properties file is used)
+ </fail>
+ </target>
+ <target name="-init-macrodef-property">
+ <macrodef name="property" uri="http://www.netbeans.org/ns/web-project/1">
+ <attribute name="name"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{name}" value="${@{value}}"/>
+ </sequential>
+ </macrodef>
+ </target>
+ <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
+ <macrodef name="javac" uri="http://www.netbeans.org/ns/web-project/2">
+ <attribute default="${src.dir}" name="srcdir"/>
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <attribute default="${javac.classpath}:${j2ee.platform.classpath}" name="classpath"/>
+ <attribute default="${javac.processorpath}" name="processorpath"/>
+ <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+ <attribute default="${includes}" name="includes"/>
+ <attribute default="${excludes}" name="excludes"/>
+ <attribute default="${javac.debug}" name="debug"/>
+ <attribute default="${empty.dir}" name="gensrcdir"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <property location="${build.dir}/empty" name="empty.dir"/>
+ <mkdir dir="${empty.dir}"/>
+ <mkdir dir="@{apgeneratedsrcdir}"/>
+ <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" srcdir="@{srcdir}" target="${javac.target}">
+ <src>
+ <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+ <include name="*"/>
+ </dirset>
+ </src>
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+ <compilerarg line="${javac.compilerargs}"/>
+ <compilerarg value="-processorpath"/>
+ <compilerarg path="@{processorpath}:${empty.dir}"/>
+ <compilerarg line="${ap.processors.internal}"/>
+ <compilerarg value="-s"/>
+ <compilerarg path="@{apgeneratedsrcdir}"/>
+ <compilerarg line="${ap.proc.none.internal}"/>
+ <customize/>
+ </javac>
+ </sequential>
+ </macrodef>
+ </target>
+ <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
+ <macrodef name="javac" uri="http://www.netbeans.org/ns/web-project/2">
+ <attribute default="${src.dir}" name="srcdir"/>
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <attribute default="${javac.classpath}:${j2ee.platform.classpath}" name="classpath"/>
+ <attribute default="${javac.processorpath}" name="processorpath"/>
+ <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+ <attribute default="${includes}" name="includes"/>
+ <attribute default="${excludes}" name="excludes"/>
+ <attribute default="${javac.debug}" name="debug"/>
+ <attribute default="${empty.dir}" name="gensrcdir"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <property location="${build.dir}/empty" name="empty.dir"/>
+ <mkdir dir="${empty.dir}"/>
+ <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" srcdir="@{srcdir}" target="${javac.target}">
+ <src>
+ <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+ <include name="*"/>
+ </dirset>
+ </src>
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+ <compilerarg line="${javac.compilerargs}"/>
+ <customize/>
+ </javac>
+ </sequential>
+ </macrodef>
+ </target>
+ <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
+ <macrodef name="depend" uri="http://www.netbeans.org/ns/web-project/2">
+ <attribute default="${src.dir}" name="srcdir"/>
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <attribute default="${javac.classpath}:${j2ee.platform.classpath}" name="classpath"/>
+ <sequential>
+ <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ </depend>
+ </sequential>
+ </macrodef>
+ <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/web-project/2">
+ <attribute default="${build.classes.dir}" name="destdir"/>
+ <sequential>
+ <fail unless="javac.includes">Must set javac.includes</fail>
+ <pathconvert pathsep="${line.separator}" property="javac.includes.binary">
+ <path>
+ <filelist dir="@{destdir}" files="${javac.includes}"/>
+ </path>
+ <globmapper from="*.java" to="*.class"/>
+ </pathconvert>
+ <tempfile deleteonexit="true" property="javac.includesfile.binary"/>
+ <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
+ <delete>
+ <files includesfile="${javac.includesfile.binary}"/>
+ </delete>
+ <delete file="${javac.includesfile.binary}"/>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-junit">
+ <macrodef name="junit" uri="http://www.netbeans.org/ns/web-project/2">
+ <attribute default="${includes}" name="includes"/>
+ <attribute default="${excludes}" name="excludes"/>
+ <attribute default="**" name="testincludes"/>
+ <sequential>
+ <junit dir="${basedir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${java.io.tmpdir}">
+ <batchtest todir="${build.test.results.dir}">
+ <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+ <filename name="@{testincludes}"/>
+ </fileset>
+ </batchtest>
+ <classpath>
+ <path path="${run.test.classpath}:${j2ee.platform.classpath}:${j2ee.platform.embeddableejb.classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="test-sys-prop."/>
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <formatter type="brief" usefile="false"/>
+ <formatter type="xml"/>
+ <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+ <jvmarg value="-ea"/>
+ <jvmarg line="${runmain.jvmargs}"/>
+ </junit>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-java">
+ <macrodef name="java" uri="http://www.netbeans.org/ns/web-project/1">
+ <attribute default="${main.class}" name="classname"/>
+ <attribute default="${debug.classpath}" name="classpath"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <java classname="@{classname}" fork="true">
+ <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+ <jvmarg line="${runmain.jvmargs}"/>
+ <classpath>
+ <path path="@{classpath}:${j2ee.platform.classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="run-sys-prop."/>
+ <mapper from="run-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <customize/>
+ </java>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-macrodef-nbjsdebug">
+ <macrodef name="nbjsdebugstart" uri="http://www.netbeans.org/ns/web-project/1">
+ <attribute default="${client.url}" name="webUrl"/>
+ <sequential>
+ <nbjsdebugstart urlPart="${client.urlPart}" webUrl="@{webUrl}"/>
+ </sequential>
+ </macrodef>
+ </target>
+ <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
+ <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/web-project/1">
+ <attribute default="${main.class}" name="name"/>
+ <attribute default="${debug.classpath}:${j2ee.platform.classpath}" name="classpath"/>
+ <sequential>
+ <nbjpdastart addressproperty="jpda.address" name="@{name}" transport="${debug-transport}">
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ </nbjpdastart>
+ </sequential>
+ </macrodef>
+ <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/web-project/1">
+ <attribute default="${build.classes.dir}" name="dir"/>
+ <sequential>
+ <nbjpdareload>
+ <fileset dir="@{dir}" includes="${fix.classes}">
+ <include name="${fix.includes}*.class"/>
+ </fileset>
+ </nbjpdareload>
+ </sequential>
+ </macrodef>
+ <macrodef name="nbjpdaappreloaded" uri="http://www.netbeans.org/ns/web-project/1">
+ <sequential>
+ <nbjpdaappreloaded/>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-debug-args">
+ <property name="version-output" value="java version &quot;${ant.java.version}"/>
+ <condition property="have-jdk-older-than-1.4">
+ <or>
+ <contains string="${version-output}" substring="java version &quot;1.0"/>
+ <contains string="${version-output}" substring="java version &quot;1.1"/>
+ <contains string="${version-output}" substring="java version &quot;1.2"/>
+ <contains string="${version-output}" substring="java version &quot;1.3"/>
+ </or>
+ </condition>
+ <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
+ <istrue value="${have-jdk-older-than-1.4}"/>
+ </condition>
+ <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
+ <os family="windows"/>
+ </condition>
+ <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
+ <isset property="debug.transport"/>
+ </condition>
+ </target>
+ <target depends="-init-debug-args" name="-init-macrodef-debug">
+ <macrodef name="debug" uri="http://www.netbeans.org/ns/web-project/1">
+ <attribute default="${main.class}" name="classname"/>
+ <attribute default="${debug.classpath}:${j2ee.platform.classpath}" name="classpath"/>
+ <attribute default="${application.args.param}" name="args"/>
+ <element name="customize" optional="true"/>
+ <sequential>
+ <java classname="@{classname}" fork="true">
+ <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+ <jvmarg line="${debug-args-line}"/>
+ <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+ <jvmarg line="${runmain.jvmargs}"/>
+ <classpath>
+ <path path="@{classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="run-sys-prop."/>
+ <mapper from="run-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <arg line="@{args}"/>
+ <customize/>
+ </java>
+ </sequential>
+ </macrodef>
+ </target>
+ <target name="-init-taskdefs">
+ <fail unless="libs.CopyLibs.classpath">
+The libs.CopyLibs.classpath property is not set up.
+This property must point to
+org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part
+of NetBeans IDE installation and is usually located at
+&lt;netbeans_installation&gt;/java&lt;version&gt;/ant/extra folder.
+Either open the project in the IDE and make sure CopyLibs library
+exists or setup the property manually. For example like this:
+ ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar
+ </fail>
+ <taskdef classpath="${libs.CopyLibs.classpath}" resource="org/netbeans/modules/java/j2seproject/copylibstask/antlib.xml"/>
+ </target>
+ <target name="-init-ap-cmdline-properties">
+ <property name="annotation.processing.enabled" value="true"/>
+ <property name="annotation.processing.processors.list" value=""/>
+ <property name="annotation.processing.run.all.processors" value="true"/>
+ <property name="javac.processorpath" value="${javac.classpath}"/>
+ <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
+ <condition property="ap.supported.internal" value="true">
+ <not>
+ <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
+ </not>
+ </condition>
+ </target>
+ <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
+ <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
+ <isfalse value="${annotation.processing.run.all.processors}"/>
+ </condition>
+ <condition else="" property="ap.proc.none.internal" value="-proc:none">
+ <isfalse value="${annotation.processing.enabled}"/>
+ </condition>
+ </target>
+ <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
+ <property name="ap.cmd.line.internal" value=""/>
+ </target>
+ <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-check" name="profile-init"/>
+ <target name="-profile-pre-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-profile-post-init">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="-profile-pre-init, init, -profile-post-init" name="-profile-init-check">
+ <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
+ <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
+ </target>
+ <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-java,-init-macrodef-nbjpda,-init-macrodef-nbjsdebug,-init-macrodef-debug,-init-taskdefs,-init-ap-cmdline" name="init"/>
+ <!--
+ COMPILATION SECTION
+ -->
+ <target depends="init" if="no.dist.ear.dir" name="deps-module-jar" unless="no.deps">
+ <ant antfile="${project.com_juick}/build.xml" inheritall="false" target="jar">
+ <property name="deploy.on.save" value="false"/>
+ </ant>
+ <ant antfile="${project.com_juick_server}/build.xml" inheritall="false" target="jar">
+ <property name="deploy.on.save" value="false"/>
+ </ant>
+ </target>
+ <target depends="init" if="dist.ear.dir" name="deps-ear-jar" unless="no.deps">
+ <ant antfile="${project.com_juick}/build.xml" inheritall="false" target="jar">
+ <property name="deploy.on.save" value="false"/>
+ </ant>
+ <ant antfile="${project.com_juick_server}/build.xml" inheritall="false" target="jar">
+ <property name="deploy.on.save" value="false"/>
+ </ant>
+ </target>
+ <target depends="init, deps-module-jar, deps-ear-jar" name="deps-jar" unless="no.deps"/>
+ <target depends="init,deps-jar" name="-pre-pre-compile">
+ <mkdir dir="${build.classes.dir}"/>
+ </target>
+ <target name="-pre-compile">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-copy-webdir">
+ <copy todir="${build.web.dir}">
+ <fileset dir="${web.docbase.dir}" excludes="${build.web.excludes},${excludes}" includes="${includes}"/>
+ </copy>
+ <copy todir="${build.web.dir}/WEB-INF">
+ <fileset dir="${webinf.dir}" excludes="${build.web.excludes}"/>
+ </copy>
+ </target>
+ <target depends="init, deps-jar, -pre-pre-compile, -pre-compile, -copy-manifest, -copy-persistence-xml, -copy-webdir, library-inclusion-in-archive,library-inclusion-in-manifest" if="have.sources" name="-do-compile">
+ <webproject2:javac destdir="${build.classes.dir}" gensrcdir="${build.generated.sources.dir}"/>
+ <copy todir="${build.classes.dir}">
+ <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ </copy>
+ </target>
+ <target if="has.custom.manifest" name="-copy-manifest">
+ <mkdir dir="${build.meta.inf.dir}"/>
+ <copy todir="${build.meta.inf.dir}">
+ <fileset dir="${conf.dir}" includes="MANIFEST.MF"/>
+ </copy>
+ </target>
+ <target if="has.persistence.xml" name="-copy-persistence-xml">
+ <mkdir dir="${build.web.dir}/WEB-INF/classes/META-INF"/>
+ <copy todir="${build.web.dir}/WEB-INF/classes/META-INF">
+ <fileset dir="${persistence.xml.dir}" includes="persistence.xml"/>
+ </copy>
+ </target>
+ <target name="-post-compile">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
+ <target name="-pre-compile-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
+ <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+ <webproject2:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}"/>
+ <copy todir="${build.classes.dir}">
+ <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ </copy>
+ </target>
+ <target name="-post-compile-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
+ <property name="jspc.schemas" value="/resources/schemas/"/>
+ <property name="jspc.dtds" value="/resources/dtds/"/>
+ <target depends="compile" description="Test compile JSP pages to expose compilation errors." if="do.compile.jsps" name="compile-jsps">
+ <mkdir dir="${build.generated.dir}/src"/>
+ <java classname="org.netbeans.modules.web.project.ant.JspC" failonerror="true" fork="true">
+ <arg value="-uriroot"/>
+ <arg file="${basedir}/${build.web.dir}"/>
+ <arg value="-d"/>
+ <arg file="${basedir}/${build.generated.dir}/src"/>
+ <arg value="-die1"/>
+ <arg value="-schemas ${jspc.schemas}"/>
+ <arg value="-dtds ${jspc.dtds}"/>
+ <arg value="-compilerSourceVM ${javac.source}"/>
+ <arg value="-compilerTargetVM ${javac.target}"/>
+ <arg value="-javaEncoding ${source.encoding}"/>
+ <arg value="-sysClasspath ${libs.jsp-compilation-syscp.classpath}"/>
+ <classpath path="${java.home}/../lib/tools.jar:${libs.jsp-compiler.classpath}:${libs.jsp-compilation.classpath}"/>
+ </java>
+ <mkdir dir="${build.generated.dir}/classes"/>
+ <webproject2:javac classpath="${build.classes.dir}:${libs.jsp-compilation.classpath}:${javac.classpath}:${j2ee.platform.classpath}" destdir="${build.generated.dir}/classes" srcdir="${build.generated.dir}/src"/>
+ </target>
+ <target depends="compile" if="jsp.includes" name="-do-compile-single-jsp">
+ <fail unless="javac.jsp.includes">Must select some files in the IDE or set javac.jsp.includes</fail>
+ <mkdir dir="${build.generated.dir}/src"/>
+ <java classname="org.netbeans.modules.web.project.ant.JspCSingle" failonerror="true" fork="true">
+ <arg value="-uriroot"/>
+ <arg file="${basedir}/${build.web.dir}"/>
+ <arg value="-d"/>
+ <arg file="${basedir}/${build.generated.dir}/src"/>
+ <arg value="-die1"/>
+ <arg value="-schemas ${jspc.schemas}"/>
+ <arg value="-dtds ${jspc.dtds}"/>
+ <arg value="-sysClasspath ${libs.jsp-compilation-syscp.classpath}"/>
+ <arg value="-jspc.files"/>
+ <arg path="${jsp.includes}"/>
+ <arg value="-compilerSourceVM ${javac.source}"/>
+ <arg value="-compilerTargetVM ${javac.target}"/>
+ <arg value="-javaEncoding ${source.encoding}"/>
+ <classpath path="${java.home}/../lib/tools.jar:${libs.jsp-compiler.classpath}:${libs.jsp-compilation.classpath}"/>
+ </java>
+ <mkdir dir="${build.generated.dir}/classes"/>
+ <webproject2:javac classpath="${build.classes.dir}:${libs.jsp-compilation.classpath}:${javac.classpath}:${j2ee.platform.classpath}" destdir="${build.generated.dir}/classes" srcdir="${build.generated.dir}/src">
+ <customize>
+ <patternset includes="${javac.jsp.includes}"/>
+ </customize>
+ </webproject2:javac>
+ </target>
+ <target name="compile-single-jsp">
+ <fail unless="jsp.includes">Must select a file in the IDE or set jsp.includes</fail>
+ <antcall target="-do-compile-single-jsp"/>
+ </target>
+ <!--
+ DIST BUILDING SECTION
+ -->
+ <target name="-pre-dist">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,compile-jsps,-pre-dist" if="do.war.package.without.custom.manifest" name="-do-dist-without-manifest">
+ <dirname file="${dist.war}" property="dist.jar.dir"/>
+ <mkdir dir="${dist.jar.dir}"/>
+ <jar compress="${jar.compress}" jarfile="${dist.war}">
+ <fileset dir="${build.web.dir}"/>
+ </jar>
+ </target>
+ <target depends="init,compile,compile-jsps,-pre-dist" if="do.war.package.with.custom.manifest" name="-do-dist-with-manifest">
+ <dirname file="${dist.war}" property="dist.jar.dir"/>
+ <mkdir dir="${dist.jar.dir}"/>
+ <jar compress="${jar.compress}" jarfile="${dist.war}" manifest="${build.meta.inf.dir}/MANIFEST.MF">
+ <fileset dir="${build.web.dir}"/>
+ </jar>
+ </target>
+ <target depends="init,compile,compile-jsps,-pre-dist" if="do.tmp.war.package.without.custom.manifest" name="-do-tmp-dist-without-manifest">
+ <dirname file="${dist.war}" property="dist.jar.dir"/>
+ <mkdir dir="${dist.jar.dir}"/>
+ <jar compress="${jar.compress}" jarfile="${dist.war}">
+ <fileset dir="${build.web.dir}"/>
+ </jar>
+ </target>
+ <target depends="init,compile,compile-jsps,-pre-dist" if="do.tmp.war.package.with.custom.manifest" name="-do-tmp-dist-with-manifest">
+ <dirname file="${dist.war}" property="dist.jar.dir"/>
+ <mkdir dir="${dist.jar.dir}"/>
+ <jar compress="${jar.compress}" jarfile="${dist.war}" manifest="${build.meta.inf.dir}/MANIFEST.MF">
+ <fileset dir="${build.web.dir}"/>
+ </jar>
+ </target>
+ <target depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest" name="do-dist"/>
+ <target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
+ <copyfiles files="${reference.com_juick.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${reference.com_juick_server.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+ <mkdir dir="${build.web.dir}/META-INF"/>
+ <manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
+ </target>
+ <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
+ <copyfiles files="${reference.com_juick.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+ <copyfiles files="${reference.com_juick_server.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+ </target>
+ <target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
+ <delete dir="${build.web.dir}/WEB-INF/lib"/>
+ </target>
+ <target depends="init,-clean-webinf-lib,compile,compile-jsps,-pre-dist,library-inclusion-in-manifest" if="do.tmp.war.package" name="do-ear-dist">
+ <dirname file="${dist.ear.war}" property="dist.jar.dir"/>
+ <mkdir dir="${dist.jar.dir}"/>
+ <jar compress="${jar.compress}" jarfile="${dist.ear.war}" manifest="${build.web.dir}/META-INF/MANIFEST.MF">
+ <fileset dir="${build.web.dir}"/>
+ </jar>
+ </target>
+ <target name="-post-dist">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-dist,do-dist,-post-dist" description="Build distribution (WAR)." name="dist"/>
+ <target depends="init,-clean-webinf-lib,-init-cos,compile,-pre-dist,do-ear-dist,-post-dist" description="Build distribution (WAR) to be packaged into an EAR." name="dist-ear"/>
+ <!--
+ EXECUTION SECTION
+ -->
+ <target depends="run-deploy,run-display-browser" description="Deploy to server and show in browser." name="run"/>
+ <target name="-pre-run-deploy">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-post-run-deploy">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target name="-pre-nbmodule-run-deploy">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- This target can be overriden by NetBeans modules. Don't override it directly, use -pre-run-deploy task instead. -->
+ </target>
+ <target name="-post-nbmodule-run-deploy">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- This target can be overriden by NetBeans modules. Don't override it directly, use -post-run-deploy task instead. -->
+ </target>
+ <target name="-run-deploy-am">
+ <!-- Task to deploy to the Access Manager runtime. -->
+ </target>
+ <target depends="init,-init-cos,compile,compile-jsps,-do-compile-single-jsp,-pre-dist,-do-tmp-dist-with-manifest,-do-tmp-dist-without-manifest,-pre-run-deploy,-pre-nbmodule-run-deploy,-run-deploy-nb,-init-deploy-ant,-deploy-ant,-run-deploy-am,-post-nbmodule-run-deploy,-post-run-deploy,-do-update-breakpoints" name="run-deploy"/>
+ <target if="netbeans.home" name="-run-deploy-nb">
+ <nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
+ </target>
+ <target name="-init-deploy-ant" unless="netbeans.home">
+ <property name="deploy.ant.archive" value="${dist.war}"/>
+ <property name="deploy.ant.docbase.dir" value="${web.docbase.dir}"/>
+ <property name="deploy.ant.resource.dir" value="${resource.dir}"/>
+ <property name="deploy.ant.enabled" value="true"/>
+ </target>
+ <target depends="dist,-run-undeploy-nb,-init-deploy-ant,-undeploy-ant" name="run-undeploy"/>
+ <target if="netbeans.home" name="-run-undeploy-nb">
+ <fail message="Undeploy is not supported from within the IDE"/>
+ </target>
+ <target depends="init,-pre-dist,dist,-post-dist" name="verify">
+ <nbverify file="${dist.war}"/>
+ </target>
+ <target depends="run-deploy,-init-display-browser,-display-browser-nb,-display-browser-cl" name="run-display-browser"/>
+ <target if="do.display.browser" name="-init-display-browser">
+ <condition property="do.display.browser.nb">
+ <isset property="netbeans.home"/>
+ </condition>
+ <condition property="do.display.browser.cl">
+ <isset property="deploy.ant.enabled"/>
+ </condition>
+ </target>
+ <target if="do.display.browser.nb" name="-display-browser-nb">
+ <nbbrowse url="${client.url}"/>
+ </target>
+ <target if="do.display.browser.cl" name="-get-browser" unless="browser">
+ <condition property="browser" value="rundll32">
+ <os family="windows"/>
+ </condition>
+ <condition else="" property="browser.args" value="url.dll,FileProtocolHandler">
+ <os family="windows"/>
+ </condition>
+ <condition property="browser" value="/usr/bin/open">
+ <os family="mac"/>
+ </condition>
+ <property environment="env"/>
+ <condition property="browser" value="${env.BROWSER}">
+ <isset property="env.BROWSER"/>
+ </condition>
+ <condition property="browser" value="/usr/bin/firefox">
+ <available file="/usr/bin/firefox"/>
+ </condition>
+ <condition property="browser" value="/usr/local/firefox/firefox">
+ <available file="/usr/local/firefox/firefox"/>
+ </condition>
+ <condition property="browser" value="/usr/bin/mozilla">
+ <available file="/usr/bin/mozilla"/>
+ </condition>
+ <condition property="browser" value="/usr/local/mozilla/mozilla">
+ <available file="/usr/local/mozilla/mozilla"/>
+ </condition>
+ <condition property="browser" value="/usr/sfw/lib/firefox/firefox">
+ <available file="/usr/sfw/lib/firefox/firefox"/>
+ </condition>
+ <condition property="browser" value="/opt/csw/bin/firefox">
+ <available file="/opt/csw/bin/firefox"/>
+ </condition>
+ <condition property="browser" value="/usr/sfw/lib/mozilla/mozilla">
+ <available file="/usr/sfw/lib/mozilla/mozilla"/>
+ </condition>
+ <condition property="browser" value="/opt/csw/bin/mozilla">
+ <available file="/opt/csw/bin/mozilla"/>
+ </condition>
+ </target>
+ <target depends="-get-browser" if="do.display.browser.cl" name="-display-browser-cl">
+ <fail unless="browser">
+ Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable.
+ </fail>
+ <property name="browse.url" value="${deploy.ant.client.url}${client.urlPart}"/>
+ <echo>Launching ${browse.url}</echo>
+ <exec executable="${browser}" spawn="true">
+ <arg line="${browser.args} ${browse.url}"/>
+ </exec>
+ </target>
+ <target depends="init,-init-cos,compile-single" name="run-main">
+ <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+ <webproject1:java classname="${run.class}"/>
+ </target>
+ <target depends="init,compile-test-single,-pre-test-run-single" name="run-test-with-main">
+ <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+ <webproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
+ </target>
+ <target depends="init" if="netbeans.home" name="-do-update-breakpoints">
+ <webproject1:nbjpdaappreloaded/>
+ </target>
+ <!--
+ DEBUGGING SECTION
+ -->
+ <target depends="init,-init-cos,compile,compile-jsps,-do-compile-single-jsp,-pre-dist,-do-tmp-dist-with-manifest,-do-tmp-dist-without-manifest" description="Debug project in IDE." if="netbeans.home" name="debug">
+ <nbstartserver debugmode="true"/>
+ <antcall target="connect-debugger"/>
+ <nbdeploy clientUrlPart="${client.urlPart}" debugmode="true" forceRedeploy="true"/>
+ <antcall target="debug-display-browser"/>
+ <antcall target="connect-client-debugger"/>
+ </target>
+ <target if="do.debug.server" name="connect-debugger" unless="is.debugged">
+ <nbjpdaconnect address="${jpda.address}" host="${jpda.host}" name="${name}" transport="${jpda.transport}">
+ <classpath>
+ <path path="${debug.classpath}:${j2ee.platform.classpath}"/>
+ </classpath>
+ <sourcepath>
+ <path path="${web.docbase.dir}"/>
+ </sourcepath>
+ </nbjpdaconnect>
+ </target>
+ <target if="do.display.browser.debug" name="debug-display-browser">
+ <nbbrowse url="${client.url}"/>
+ </target>
+ <target if="do.debug.client" name="connect-client-debugger">
+ <webproject1:nbjsdebugstart webUrl="${client.url}"/>
+ </target>
+ <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
+ <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+ <webproject1:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
+ </target>
+ <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
+ <target depends="init,compile,compile-jsps,-do-compile-single-jsp,debug" if="netbeans.home" name="debug-single"/>
+ <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
+ <webproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
+ </target>
+ <target depends="init" if="netbeans.home" name="-debug-start-debugger">
+ <webproject1:nbjpdastart name="${debug.class}"/>
+ </target>
+ <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
+ <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+ <webproject1:debug classname="${debug.class}"/>
+ </target>
+ <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single-main"/>
+ <target depends="init" name="-pre-debug-fix">
+ <fail unless="fix.includes">Must set fix.includes</fail>
+ <property name="javac.includes" value="${fix.includes}.java"/>
+ </target>
+ <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
+ <webproject1:nbjpdareload/>
+ </target>
+ <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
+ <!--
+ =================
+ PROFILING SECTION
+ =================
+ -->
+ <target description="Profile a J2EE project in the IDE." name="profile">
+ <condition else="start-profiled-server" property="profiler.startserver.target" value="start-profiled-server-extraargs">
+ <isset property="profiler.info.jvmargs.extra"/>
+ </condition>
+ <antcall target="${profiler.startserver.target}"/>
+ <antcall target="run"/>
+ <antcall target="start-loadgen"/>
+ </target>
+ <target name="start-profiled-server">
+ <nbstartprofiledserver forceRestart="${profiler.j2ee.serverForceRestart}" javaPlatform="${profiler.info.javaPlatform}" startupTimeout="${profiler.j2ee.serverStartupTimeout}">
+ <jvmarg value="${profiler.info.jvmargs.agent}"/>
+ <jvmarg value="${profiler.j2ee.agentID}"/>
+ </nbstartprofiledserver>
+ </target>
+ <target name="start-profiled-server-extraargs">
+ <nbstartprofiledserver forceRestart="${profiler.j2ee.serverForceRestart}" javaPlatform="${profiler.info.javaPlatform}" startupTimeout="${profiler.j2ee.serverStartupTimeout}">
+ <jvmarg value="${profiler.info.jvmargs.extra}"/>
+ <jvmarg value="${profiler.info.jvmargs.agent}"/>
+ <jvmarg value="${profiler.j2ee.agentID}"/>
+ </nbstartprofiledserver>
+ </target>
+ <target if="profiler.loadgen.path" name="start-loadgen">
+ <loadgenstart path="${profiler.loadgen.path}"/>
+ </target>
+ <!--
+ JAVADOC SECTION
+ -->
+ <target depends="init" if="have.sources" name="javadoc-build">
+ <mkdir dir="${dist.javadoc.dir}"/>
+ <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
+ <classpath>
+ <path path="${javac.classpath}:${j2ee.platform.classpath}"/>
+ </classpath>
+ <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+ <filename name="**/*.java"/>
+ </fileset>
+ <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+ <include name="**/*.java"/>
+ </fileset>
+ </javadoc>
+ <copy todir="${dist.javadoc.dir}">
+ <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+ <filename name="**/doc-files/**"/>
+ </fileset>
+ <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+ <include name="**/doc-files/**"/>
+ </fileset>
+ </copy>
+ </target>
+ <target depends="init,javadoc-build" if="netbeans.home" name="javadoc-browse" unless="no.javadoc.preview">
+ <nbbrowse file="${dist.javadoc.dir}/index.html"/>
+ </target>
+ <target depends="init,javadoc-build,javadoc-browse" description="Build Javadoc." name="javadoc"/>
+ <!--
+
+ JUNIT COMPILATION SECTION
+ -->
+ <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
+ <mkdir dir="${build.test.classes.dir}"/>
+ <property name="j2ee.platform.embeddableejb.classpath" value=""/>
+ </target>
+ <target name="-pre-compile-test">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test" if="have.tests" name="-do-compile-test">
+ <webproject2:javac classpath="${javac.test.classpath}:${j2ee.platform.classpath}:${j2ee.platform.embeddableejb.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+ <copy todir="${build.test.classes.dir}">
+ <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ </copy>
+ </target>
+ <target name="-post-compile-test">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
+ <target name="-pre-compile-test-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
+ <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+ <webproject2:javac classpath="${javac.test.classpath}:${j2ee.platform.classpath}:${j2ee.platform.embeddableejb.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" srcdir="${test.src.dir}"/>
+ <copy todir="${build.test.classes.dir}">
+ <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+ </copy>
+ </target>
+ <target name="-post-compile-test-single">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
+ <!--
+
+ JUNIT EXECUTION SECTION
+ -->
+ <target depends="init" if="have.tests" name="-pre-test-run">
+ <mkdir dir="${build.test.results.dir}"/>
+ </target>
+ <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
+ <webproject2:junit testincludes="**/*Test.java"/>
+ </target>
+ <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
+ <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+ </target>
+ <target depends="init" if="have.tests" name="test-report"/>
+ <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
+ <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
+ <target depends="init" if="have.tests" name="-pre-test-run-single">
+ <mkdir dir="${build.test.results.dir}"/>
+ </target>
+ <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
+ <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
+ <webproject2:junit excludes="" includes="${test.includes}"/>
+ </target>
+ <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
+ <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+ </target>
+ <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
+ <!--
+
+ JUNIT DEBUGGING SECTION
+ -->
+ <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
+ <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
+ <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
+ <delete file="${test.report.file}"/>
+ <!-- must exist, otherwise the XML formatter would fail -->
+ <mkdir dir="${build.test.results.dir}"/>
+ <webproject1:debug args="${test.class}" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}:${j2ee.platform.embeddableejb.classpath}">
+ <customize>
+ <arg value="showoutput=true"/>
+ <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
+ <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
+ </customize>
+ </webproject1:debug>
+ </target>
+ <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
+ <webproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
+ </target>
+ <target depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
+ <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
+ <webproject1:nbjpdareload dir="${build.test.classes.dir}"/>
+ </target>
+ <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
+ <!--
+ =========================
+ TESTS PROFILING SECTION
+ =========================
+ -->
+ <target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single">
+ <nbprofiledirect>
+ <classpath>
+ <path path="${run.test.classpath}"/>
+ <path path="${j2ee.platform.classpath}"/>
+ </classpath>
+ </nbprofiledirect>
+ <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true">
+ <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
+ <jvmarg value="${profiler.info.jvmargs.agent}"/>
+ <jvmarg line="${profiler.info.jvmargs}"/>
+ <test name="${profile.class}"/>
+ <classpath>
+ <path path="${run.test.classpath}"/>
+ <path path="${j2ee.platform.classpath}"/>
+ </classpath>
+ <syspropertyset>
+ <propertyref prefix="test-sys-prop."/>
+ <mapper from="test-sys-prop.*" to="*" type="glob"/>
+ </syspropertyset>
+ <formatter type="brief" usefile="false"/>
+ <formatter type="xml"/>
+ </junit>
+ </target>
+ <!--
+
+ CLEANUP SECTION
+ -->
+ <target depends="init" name="deps-clean" unless="no.deps">
+ <ant antfile="${project.com_juick}/build.xml" inheritall="false" target="clean"/>
+ <ant antfile="${project.com_juick_server}/build.xml" inheritall="false" target="clean"/>
+ </target>
+ <target depends="init" name="do-clean">
+ <condition property="build.dir.to.clean" value="${build.web.dir}">
+ <isset property="dist.ear.dir"/>
+ </condition>
+ <property name="build.dir.to.clean" value="${build.web.dir}"/>
+ <delete includeEmptyDirs="true" quiet="true">
+ <fileset dir="${build.dir.to.clean}/WEB-INF/lib"/>
+ </delete>
+ <delete dir="${build.dir}"/>
+ <available file="${build.dir.to.clean}/WEB-INF/lib" property="status.clean-failed" type="dir"/>
+ <delete dir="${dist.dir}"/>
+ </target>
+ <target depends="do-clean" if="status.clean-failed" name="check-clean">
+ <echo message="Warning: unable to delete some files in ${build.web.dir}/WEB-INF/lib - they are probably locked by the J2EE server. "/>
+ <echo level="info" message="To delete all files undeploy the module from Server Registry in Runtime tab and then use Clean again."/>
+ </target>
+ <target depends="init" if="netbeans.home" name="undeploy-clean">
+ <nbundeploy failOnError="false" startServer="false"/>
+ </target>
+ <target name="-post-clean">
+ <!-- Empty placeholder for easier customization. -->
+ <!-- You can override this target in the ../build.xml file. -->
+ </target>
+ <target depends="init,undeploy-clean,deps-clean,do-clean,check-clean,-post-clean" description="Clean build products." name="clean"/>
+ <target depends="clean" description="Clean build products." name="clean-ear"/>
+</project>
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
new file mode 100644
index 00000000..e8e9295a
--- /dev/null
+++ b/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=9ff506d8
+build.xml.script.CRC32=c93fa366
+build.xml.stylesheet.CRC32=651128d4@1.33.1.1
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=9ff506d8
+nbproject/build-impl.xml.script.CRC32=e315adae
+nbproject/build-impl.xml.stylesheet.CRC32=0cbf5bb7@1.33.1.1
diff --git a/nbproject/project.properties b/nbproject/project.properties
new file mode 100644
index 00000000..de13c257
--- /dev/null
+++ b/nbproject/project.properties
@@ -0,0 +1,87 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=true
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.web.dir}/WEB-INF/classes
+build.classes.excludes=**/*.java,**/*.form
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+build.web.dir=${build.dir}/web
+build.web.excludes=${build.classes.excludes}
+client.urlPart=
+compile.jsps=false
+conf.dir=${source.root}/conf
+debug.classpath=${build.classes.dir}:${javac.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+display.browser=true
+dist.dir=dist
+dist.ear.war=${dist.dir}/${war.ear.name}
+dist.javadoc.dir=${dist.dir}/javadoc
+dist.war=${dist.dir}/${war.name}
+endorsed.classpath=\
+ ${libs.javaee-endorsed-api-6.0.classpath}
+excludes=
+includes=**
+j2ee.compile.on.save=true
+j2ee.deploy.on.save=true
+j2ee.platform=1.6-web
+j2ee.platform.classpath=${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/ecj-3.7.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/annotations-api.jar
+j2ee.server.type=Tomcat
+jar.compress=false
+javac.classpath=\
+ ${reference.com_juick.jar}:\
+ ${reference.com_juick_server.jar}:\
+ ${libs.MySQLDriver.classpath}
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.debug=true
+javac.deprecation=false
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.6
+javac.target=1.6
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.preview=true
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+lib.dir=${web.docbase.dir}/WEB-INF/lib
+persistence.xml.dir=${conf.dir}
+platform.active=default_platform
+project.com_juick=../com.juick
+project.com_juick_server=../com.juick.server
+reference.com_juick.jar=${project.com_juick}/dist/com.juick.jar
+reference.com_juick_server.jar=${project.com_juick_server}/dist/com.juick.server.jar
+resource.dir=setup
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+# Space-separated list of JVM arguments used when running a class with a main method or a unit test
+# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value):
+runmain.jvmargs=
+source.encoding=UTF-8
+source.root=src
+src.dir=${source.root}/java
+test.src.dir=test
+war.content.additional=
+war.ear.name=com.juick.http.www.war
+war.name=com.juick.http.www.war
+web.docbase.dir=web
+webinf.dir=web/WEB-INF
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100644
index 00000000..78c0648d
--- /dev/null
+++ b/nbproject/project.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.web.project</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/web-project/3">
+ <name>com.juick.http.www</name>
+ <minimum-ant-version>1.6.5</minimum-ant-version>
+ <web-module-libraries>
+ <library dirs="200">
+ <file>${reference.com_juick.jar}</file>
+ <path-in-war>WEB-INF/lib</path-in-war>
+ </library>
+ <library dirs="200">
+ <file>${reference.com_juick_server.jar}</file>
+ <path-in-war>WEB-INF/lib</path-in-war>
+ </library>
+ <library dirs="200">
+ <file>${libs.MySQLDriver.classpath}</file>
+ </library>
+ </web-module-libraries>
+ <web-module-additional-libraries/>
+ <source-roots>
+ <root id="src.dir"/>
+ </source-roots>
+ <test-roots>
+ <root id="test.src.dir"/>
+ </test-roots>
+ </data>
+ <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
+ <reference>
+ <foreign-project>com_juick</foreign-project>
+ <artifact-type>jar</artifact-type>
+ <script>build.xml</script>
+ <target>jar</target>
+ <clean-target>clean</clean-target>
+ <id>jar</id>
+ </reference>
+ <reference>
+ <foreign-project>com_juick_server</foreign-project>
+ <artifact-type>jar</artifact-type>
+ <script>build.xml</script>
+ <target>jar</target>
+ <clean-target>clean</clean-target>
+ <id>jar</id>
+ </reference>
+ </references>
+ </configuration>
+</project>
diff --git a/src/conf/MANIFEST.MF b/src/conf/MANIFEST.MF
new file mode 100644
index 00000000..59499bce
--- /dev/null
+++ b/src/conf/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
diff --git a/src/java/Blogs.properties b/src/java/Blogs.properties
new file mode 100644
index 00000000..3b596f77
--- /dev/null
+++ b/src/java/Blogs.properties
@@ -0,0 +1,14 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Last\ messages=Last messages
+Lists=Lists
+Tags=Tags
+Search=Search
+My\ feed=My feed
+Private=Private
+Incoming=Incoming
+Recommended=Recommended
+All\ messages=All messages
+Popular=Popular
+With\ photos=With photos
diff --git a/src/java/Blogs_ru.properties b/src/java/Blogs_ru.properties
new file mode 100644
index 00000000..f5fe415f
--- /dev/null
+++ b/src/java/Blogs_ru.properties
@@ -0,0 +1,14 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Last\ messages=\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f
+Lists=\u0421\u043f\u0438\u0441\u043a\u0438
+Tags=\u0422\u0435\u0433\u0438
+Search=\u041f\u043e\u0438\u0441\u043a
+My\ feed=\u041c\u043e\u044f \u043b\u0435\u043d\u0442\u0430
+Private=\u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435
+Incoming=\u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0435
+Recommended=\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u0435
+All\ messages=\u0412\u0441\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f
+Popular=\u041f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435
+With\ photos=\u0421 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f\u043c\u0438
diff --git a/src/java/Chats.properties b/src/java/Chats.properties
new file mode 100644
index 00000000..e5596bac
--- /dev/null
+++ b/src/java/Chats.properties
@@ -0,0 +1,5 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Active\ chats=Active chats
+Users\ online=Users online
diff --git a/src/java/Chats_ru.properties b/src/java/Chats_ru.properties
new file mode 100644
index 00000000..6f144f69
--- /dev/null
+++ b/src/java/Chats_ru.properties
@@ -0,0 +1,5 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Active\ chats=\u0410\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0447\u0430\u0442\u044b
+Users\ online=\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u043d\u043b\u0430\u0439\u043d
diff --git a/src/java/Global.properties b/src/java/Global.properties
new file mode 100644
index 00000000..0883bec5
--- /dev/null
+++ b/src/java/Global.properties
@@ -0,0 +1,17 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Blogs=Blogs
+Chats=Chats
+Photos=Photos
+Map=Map
+Post=Post
+Blog=Blog
+Settings=Settings
+Logout=Logout
+Login=Login
+Contacts=Contacts
+Help=Help
+Older=Older
+Newer=Newer
+(replies)\ by=by
diff --git a/src/java/Global_ru.properties b/src/java/Global_ru.properties
new file mode 100644
index 00000000..81ba9c4f
--- /dev/null
+++ b/src/java/Global_ru.properties
@@ -0,0 +1,17 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Blogs=\u0411\u043b\u043e\u0433\u0438
+Chats=\u0427\u0430\u0442\u044b
+Photos=\u0424\u043e\u0442\u043e
+Map=\u041a\u0430\u0440\u0442\u0430
+Post=\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c
+Blog=\u0411\u043b\u043e\u0433
+Settings=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438
+Logout=\u0412\u044b\u0439\u0442\u0438
+Login=\u0412\u043e\u0439\u0442\u0438
+Contacts=\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b
+Help=\u0421\u043f\u0440\u0430\u0432\u043a\u0430
+Older=\u0421\u0442\u0430\u0440\u044b\u0435
+Newer=\u041d\u043e\u0432\u044b\u0435
+(replies)\ by=\u043e\u0442
diff --git a/src/java/Login.properties b/src/java/Login.properties
new file mode 100644
index 00000000..820b58f3
--- /dev/null
+++ b/src/java/Login.properties
@@ -0,0 +1,6 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Login=Login
+Username=Username
+Password=Password
diff --git a/src/java/Login_ru.properties b/src/java/Login_ru.properties
new file mode 100644
index 00000000..402e58eb
--- /dev/null
+++ b/src/java/Login_ru.properties
@@ -0,0 +1,6 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Login=\u0412\u0445\u043e\u0434
+Username=\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f
+Password=\u041f\u0430\u0440\u043e\u043b\u044c
diff --git a/src/java/Map.properties b/src/java/Map.properties
new file mode 100644
index 00000000..004e4d13
--- /dev/null
+++ b/src/java/Map.properties
@@ -0,0 +1,5 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Messages\ on\ map=Messages on map
+Popular\ places=Popular places
diff --git a/src/java/Map_ru.properties b/src/java/Map_ru.properties
new file mode 100644
index 00000000..633a1bcc
--- /dev/null
+++ b/src/java/Map_ru.properties
@@ -0,0 +1,5 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Messages\ on\ map=\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u0430\u0440\u0442\u0435
+Popular\ places=\u041f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430
diff --git a/src/java/Photos.properties b/src/java/Photos.properties
new file mode 100644
index 00000000..84624aad
--- /dev/null
+++ b/src/java/Photos.properties
@@ -0,0 +1,4 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Last\ photos\ and\ videos=Last photos and videos
diff --git a/src/java/Photos_ru.properties b/src/java/Photos_ru.properties
new file mode 100644
index 00000000..1933c3cf
--- /dev/null
+++ b/src/java/Photos_ru.properties
@@ -0,0 +1,4 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+Last\ photos\ and\ videos=\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0444\u043e\u0442\u043e \u0438 \u0432\u0438\u0434\u0435\u043e
diff --git a/src/java/User.properties b/src/java/User.properties
new file mode 100644
index 00000000..aa2e0bcb
--- /dev/null
+++ b/src/java/User.properties
@@ -0,0 +1,16 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+(Stats)\ I\ read=I read
+(Stats)\ My\ readers=My readers
+(Stats)\ Messages=Messages
+(Stats)\ Replies=Replies
+(Menu)\ Messages=Messages
+(Menu)\ Blog=Blog
+(Menu)\ Recommendations=Recommendations
+(Menu)\ Photos=Photos and videos
+(Menu)\ Tags=Tags
+(Menu)\ Search=Search
+Expand\ all=Expand all
+View\ as\ list=View as list
+View\ as\ tree=View as tree
diff --git a/src/java/User_ru.properties b/src/java/User_ru.properties
new file mode 100644
index 00000000..a5c6f3ef
--- /dev/null
+++ b/src/java/User_ru.properties
@@ -0,0 +1,16 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+
+(Stats)\ I\ read=\u042f \u0447\u0438\u0442\u0430\u044e
+(Stats)\ My\ readers=\u041c\u0435\u043d\u044f \u0447\u0438\u0442\u0430\u044e\u0442
+(Stats)\ Messages=\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439
+(Stats)\ Replies=\u041e\u0442\u0432\u0435\u0442\u043e\u0432
+(Menu)\ Messages=\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f
+(Menu)\ Blog=\u0411\u043b\u043e\u0433
+(Menu)\ Recommendations=\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438
+(Menu)\ Photos=\u0424\u043e\u0442\u043e \u0438 \u0432\u0438\u0434\u0435\u043e
+(Menu)\ Tags=\u0422\u0435\u0433\u0438
+(Menu)\ Search=\u041f\u043e\u0438\u0441\u043a
+Expand\ all=\u0420\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435
+View\ as\ list=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043a\u043e\u043c
+View\ as\ tree=\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e\u043c
diff --git a/src/java/com/juick/http/www/Blogs.java b/src/java/com/juick/http/www/Blogs.java
new file mode 100644
index 00000000..3b9b6882
--- /dev/null
+++ b/src/java/com/juick/http/www/Blogs.java
@@ -0,0 +1,217 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import com.juick.server.MessagesQueries;
+import com.juick.server.TagQueries;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Blogs {
+
+ protected void doGet(Connection sql, Connection sqlSearch, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ com.juick.User visitor = Utils.getVisitorUser(sql, request);
+ Locale locale = request.getLocale();
+ ResourceBundle rb = ResourceBundle.getBundle("Blogs", locale);
+
+ String title;
+ ArrayList<Integer> mids;
+
+ String paramShow = request.getParameter("show");
+
+ int paramTag = 0;
+ String paramTagStr = request.getParameter("tag");
+ if (paramTagStr != null && paramTagStr.length() < 64) {
+ paramTag = TagQueries.getTagID(sql, paramTagStr, false);
+ }
+
+ int paramBefore = 0;
+ String paramBeforeStr = request.getParameter("before");
+ if (paramBeforeStr != null) {
+ try {
+ paramBefore = Integer.parseInt(paramBeforeStr);
+ } catch (NumberFormatException e) {
+ }
+ }
+
+ String paramSearch = request.getParameter("search");
+ if (paramSearch != null && paramSearch.length() > 64) {
+ paramSearch = null;
+ }
+
+ if (paramShow == null) {
+ if (paramTag > 0) {
+ title = "*" + Utils.encodeHTML(paramTagStr);
+ mids = MessagesQueries.getTag(sql, paramTag, paramBefore);
+ } else if (paramSearch != null) {
+ title = rb.getString("Search") + ": " + Utils.encodeHTML(paramSearch);
+ mids = MessagesQueries.getSearch(sql, sqlSearch, Utils.encodeSphinx(paramSearch), paramBefore);
+ } else {
+ title = rb.getString("Last messages");
+ mids = MessagesQueries.getAll(sql, paramBefore);
+ }
+ } else if (paramShow.equals("my")) {
+ title = rb.getString("My feed");
+ mids = MessagesQueries.getMyFeed(sql, visitor.UID, paramBefore);
+ } else if (paramShow.equals("private")) {
+ title = rb.getString("Private");
+ mids = MessagesQueries.getPrivate(sql, visitor.UID, paramBefore);
+ } else if (paramShow.equals("incoming")) {
+ title = rb.getString("Incoming");
+ mids = MessagesQueries.getIncoming(sql, visitor.UID, paramBefore);
+ } else if (paramShow.equals("recommended")) {
+ title = rb.getString("Recommended");
+ mids = MessagesQueries.getRecommended(sql, visitor.UID, paramBefore);
+ } else if (paramShow.equals("top")) {
+ title = rb.getString("Popular");
+ mids = MessagesQueries.getPopular(sql, paramBefore);
+ } else if (paramShow.equals("photos")) {
+ title = rb.getString("With photos");
+ mids = MessagesQueries.getPhotos(sql, paramBefore);
+ } else {
+ response.sendError(404);
+ return;
+ }
+
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+ PageTemplates.pageHead(out, title, null);
+ PageTemplates.pageNavigation(out, locale, visitor);
+ PageTemplates.pageTitle(out, title);
+
+ out.println("<div id=\"wrapper\">");
+ out.println("<div id=\"content\">");
+ out.println("<ul>");
+
+ if (mids.size() > 0) {
+ PageTemplates.printMessages(out, sql, mids, locale);
+ }
+
+ out.println("</ul>");
+ out.println("<script type=\"text/javascript\">");
+ out.println("$(\"textarea\").autoResize();");
+ out.println("</script>");
+
+ if (mids.size() == 20) {
+ String nextpage = "?before=" + mids.get(mids.size() - 1);
+ if (paramShow != null) {
+ nextpage += "&show=" + paramShow;
+ }
+ if (paramTag > 0) {
+ nextpage += "&tag=" + URLEncoder.encode(paramTagStr, "UTF-8");
+ }
+ out.println("<p class=\"page\"><a href=\"" + nextpage + "\">Older →</a></p>");
+ }
+
+ out.println("</div>");
+
+ out.println("<div id=\"column\">");
+ out.println("<h2>" + rb.getString("Lists") + "</h2>");
+ if (visitor != null) {
+ out.println("<ul>");
+ out.println(" <li><a href=\"?show=my\">" + rb.getString("My feed") + "</a></li>");
+ out.println(" <li><a href=\"?show=private\">" + rb.getString("Private") + "</a></li>");
+ out.println(" <li><a href=\"?show=incoming\">" + rb.getString("Incoming") + "</a></li>");
+ out.println(" <li><a href=\"?show=recommended\">" + rb.getString("Recommended") + "</a></li>");
+ out.println("</ul>");
+ }
+ out.println("<ul>");
+ out.println(" <li><a href=\"?\">" + rb.getString("All messages") + "</a></li>");
+ out.println(" <li><a href=\"?show=top\">" + rb.getString("Popular") + "</a></li>");
+ out.println(" <li><a href=\"?show=photos\">" + rb.getString("With photos") + "</a></li>");
+ out.println("</ul>");
+ out.println("<h2>" + rb.getString("Tags") + "</h2>");
+ out.println("<p style=\"text-align: justify\">" + getTags(sql, 30) + "</p>");
+ out.println("<h2>" + rb.getString("Search") + "</h2>");
+ out.println("<form action=\"/\" id=\"search\"><p><input type=\"text\" name=\"search\" class=\"inp\"/></p></form>");
+ out.println("</div>");
+ out.println("</div>");
+
+ PageTemplates.pageFooter(out, locale);
+ } finally {
+ out.close();
+ }
+ }
+
+ private String getTags(Connection sql, int cnt) {
+ String ret = "";
+ com.juick.Tag tags[] = new com.juick.Tag[cnt];
+
+ int maxUsageCnt = 0;
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT tags.name AS name,COUNT(DISTINCT messages.user_id) AS cnt FROM (messages INNER JOIN messages_tags ON (messages.ts>TIMESTAMPADD(DAY,-3,NOW()) AND messages.message_id=messages_tags.message_id)) INNER JOIN tags ON messages_tags.tag_id=tags.tag_id GROUP BY tags.tag_id ORDER BY cnt DESC LIMIT ?");
+ stmt.setInt(1, cnt);
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ cnt = 0;
+ while (rs.next()) {
+ tags[cnt] = new com.juick.Tag();
+ tags[cnt].Name = rs.getString(1);
+ tags[cnt].UsageCnt = rs.getInt(2);
+ if (tags[cnt].UsageCnt > maxUsageCnt) {
+ maxUsageCnt = tags[cnt].UsageCnt;
+ }
+ cnt++;
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ Arrays.sort(tags, 0, cnt);
+
+ for (int i = 0; i < cnt; i++) {
+ String tag = Utils.encodeHTML(tags[i].Name);
+ try {
+ tag = "<a href=\"/?tag=" + URLEncoder.encode(tags[i].Name, "UTF-8") + "\">" + tag + "</a>";
+ } catch (UnsupportedEncodingException e) {
+ }
+
+ if (tags[i].UsageCnt > maxUsageCnt / 3 * 2) {
+ ret += "<big>" + tag + "</big> ";
+ } else if (tags[i].UsageCnt > maxUsageCnt / 3) {
+ ret += "<small>" + tag + "</small> ";
+ } else {
+ ret += tag + " ";
+ }
+ }
+
+ return ret;
+ }
+}
diff --git a/src/java/com/juick/http/www/Chats.java b/src/java/com/juick/http/www/Chats.java
new file mode 100644
index 00000000..3df37976
--- /dev/null
+++ b/src/java/com/juick/http/www/Chats.java
@@ -0,0 +1,77 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Chats {
+
+ protected void doGet(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ com.juick.User visitor = Utils.getVisitorUser(sql, request);
+ Locale locale = request.getLocale();
+ ResourceBundle rb = ResourceBundle.getBundle("Chats", locale);
+
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+ PageTemplates.pageHead(out, rb.getString("Active chats"), "");
+ PageTemplates.pageNavigation(out, locale, visitor);
+ PageTemplates.pageTitle(out, rb.getString("Active chats"));
+
+ out.println("<div id=\"wrapper\">");
+ out.println("<div id=\"content\"><ul id=\"chats\">");
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT chats.chat_id,chats.subject,COUNT(chat_users.user_id) AS cnt FROM chats INNER JOIN chat_users USING(chat_id) GROUP BY chat_id ORDER BY cnt DESC");
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ String chatid = Integer.toString(rs.getInt(1), Character.MAX_RADIX);
+ out.println("<li><b>" + Utils.encodeHTML(rs.getString(2)) + "</b><br/><i>" + rb.getString("Users online") + ": " + rs.getInt(3) + "</i><br/><a href=\"xmpp:" + chatid + "@chat.juick.com?join\">" + chatid + "@chat.juick.com</a></li>");
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ out.println("</ul></div>");
+ out.println("</div>");
+
+ PageTemplates.pageFooter(out, locale);
+ } finally {
+ out.close();
+ }
+ }
+}
diff --git a/src/java/com/juick/http/www/Login.java b/src/java/com/juick/http/www/Login.java
new file mode 100644
index 00000000..d03dd64d
--- /dev/null
+++ b/src/java/com/juick/http/www/Login.java
@@ -0,0 +1,129 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import javax.servlet.ServletException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Login {
+
+ protected void doGetLoginForm(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ com.juick.User visitor = Utils.getVisitorUser(sql, request);
+ Locale locale = request.getLocale();
+ ResourceBundle rb = ResourceBundle.getBundle("Login", locale);
+
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+ PageTemplates.pageHead(out, rb.getString("Login"), "");
+ PageTemplates.pageNavigation(out, locale, visitor);
+ PageTemplates.pageTitle(out, rb.getString("Login"));
+
+ out.println("<div id=\"wrapper\">");
+ out.println("<div id=\"content\">");
+ out.println("<form action=\"/login\" method=\"post\">");
+ out.println("<p>" + rb.getString("Username") + ": <input type=\"text\" name=\"username\"/></p>");
+ out.println("<p>" + rb.getString("Password") + ": <input type=\"password\" name=\"password\"/></p>");
+ out.println("<p><input type=\"submit\" value=\" OK \"/></p>");
+ out.println("</form>");
+ out.println("</div>");
+ out.println("</div>");
+
+ PageTemplates.pageFooter(out, locale);
+ } finally {
+ out.close();
+ }
+ }
+
+ protected void doGetLogin(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ String hash = request.getQueryString();
+ if (hash.length() > 32) {
+ response.sendError(400);
+ return;
+ }
+
+ if (com.juick.server.UserQueries.getUIDbyHash(sql, hash) > 0) {
+ Cookie c = new Cookie("hash", hash);
+ c.setDomain(".juick.com");
+ c.setMaxAge(0);
+ response.addCookie(c);
+
+ response.sendRedirect("/");
+ } else {
+ response.sendError(403);
+ }
+ }
+
+ protected void doPostLogin(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ String username = request.getParameter("username");
+ String password = request.getParameter("password");
+ if (username == null || password == null || username.length() > 32) {
+ response.sendError(400);
+ return;
+ }
+
+ int uid = com.juick.server.UserQueries.checkPassword(sql, username, password);
+ if (uid > 0) {
+ String hash = com.juick.server.UserQueries.getHashByUID(sql, uid);
+ Cookie c = new Cookie("hash", hash);
+ c.setDomain(".juick.com");
+ c.setMaxAge(0);
+ response.addCookie(c);
+
+ response.sendRedirect("/");
+ } else {
+ response.sendError(403);
+ }
+ }
+
+ protected void doGetLogout(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ int uid = Utils.getVisitorUID(sql, request);
+ if (uid > 0) {
+ PreparedStatement stmt = null;
+ try {
+ stmt = sql.prepareStatement("DELETE FROM logins WHERE user_id=?");
+ stmt.setInt(1, uid);
+ stmt.executeUpdate();
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(null, stmt);
+ }
+ }
+
+ Cookie c = new Cookie("hash", "-");
+ c.setDomain(".juick.com");
+ c.setMaxAge(0);
+ response.addCookie(c);
+
+ response.sendRedirect("/");
+ }
+}
diff --git a/src/java/com/juick/http/www/Main.java b/src/java/com/juick/http/www/Main.java
new file mode 100644
index 00000000..709c6588
--- /dev/null
+++ b/src/java/com/juick/http/www/Main.java
@@ -0,0 +1,173 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Properties;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+@WebServlet(name = "Main", urlPatterns = {"/"})
+public class Main extends HttpServlet {
+
+ Connection sql;
+ Connection sqlSearch;
+ Blogs blogs = new Blogs();
+ Chats chats = new Chats();
+ Photos photos = new Photos();
+ RootRedirects rootRedirects = new RootRedirects();
+ Map map = new Map();
+ Login login = new Login();
+ User pagesUser = new User();
+ UserThread pagesUserThread = new UserThread();
+ NewMessage pagesNewMessage = new NewMessage();
+
+ @Override
+ public void init() throws ServletException {
+ super.init();
+ try {
+ Properties conf = new Properties();
+ conf.load(new FileInputStream("/etc/juick/www.conf"));
+
+ Class.forName("com.mysql.jdbc.Driver");
+ sql = DriverManager.getConnection("jdbc:mysql://localhost/juick?autoReconnect=true&user=" + conf.getProperty("mysql_username", "") + "&password=" + conf.getProperty("mysql_password", ""));
+ sqlSearch = DriverManager.getConnection("jdbc:mysql://127.0.0.1:9306/juick?autoReconnect=true&characterEncoding=utf8&maxAllowedPacket=512000&relaxAutoCommit=true&user=root&password=");
+ } catch (Exception e) {
+ log(null, e);
+ }
+ }
+
+ @Override
+ public void destroy() {
+ super.destroy();
+ if (sql != null) {
+ try {
+ sql.close();
+ } catch (SQLException e) {
+ log(null, e);
+ }
+ }
+ }
+
+ /**
+ * Handles the HTTP <code>GET</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ if (request.getCharacterEncoding() == null) {
+ request.setCharacterEncoding("UTF-8");
+ }
+ String uri = request.getRequestURI();
+ if (uri.equals("/")) {
+ blogs.doGet(sql, sqlSearch, request, response);
+ } else if (uri.equals("/chats")) {
+ chats.doGet(sql, request, response);
+ } else if (uri.equals("/photos")) {
+ photos.doGet(sql, request, response);
+ } else if (uri.equals("/map")) {
+ map.doGet(sql, request, response);
+ } else if (uri.equals("/post")) {
+ pagesNewMessage.doGetNewMessage(sql, request, response);
+ } else if (uri.equals("/login")) {
+ if (request.getQueryString() == null) {
+ login.doGetLoginForm(sql, request, response);
+ } else {
+ login.doGetLogin(sql, request, response);
+ }
+ } else if (uri.equals("/logout")) {
+ login.doGetLogout(sql, request, response);
+ } else if (uri.equals("/settings")) {
+ //TODO settings
+ } else if (uri.matches("^/\\d+$")) {
+ rootRedirects.doGetPostID(sql, request, response);
+ } else if (uri.matches("^/[^/]$")) {
+ rootRedirects.doGetUsername(sql, request, response);
+ } else if (uri.matches("^/.+/.*")) {
+ String uriparts[] = uri.split("/");
+ com.juick.User user = com.juick.server.UserQueries.getUserByNick(sql, uriparts[1]);
+ if (user != null && user.UName.equals(uriparts[1])) {
+ if (uriparts.length == 2) { // http://juick.com/username/
+ pagesUser.doGetBlog(sql, sqlSearch, request, response, user);
+ } else if (uriparts[2].equals("info")) {
+ pagesUser.doGetInfo(sql, request, response, user);
+ } else {
+ int mid = 0;
+ try {
+ mid = Integer.parseInt(uriparts[2]);
+ } catch (NumberFormatException e) {
+ }
+ if (mid > 0) {
+ com.juick.User author = com.juick.server.MessagesQueries.getMessageAuthor(sql, mid);
+ if (author != null) {
+ if (!author.UName.equals(user.UName)) {
+ Utils.sendPermanentRedirect(response, "/" + author.UName + "/" + mid);
+ } else {
+ pagesUserThread.doGetThread(sql, request, response, user, mid);
+ }
+ } else {
+ response.sendError(404);
+ }
+ } else {
+ response.sendError(404);
+ }
+ }
+ } else if (user != null) {
+ Utils.sendPermanentRedirect(response, "/" + user.UName + "/" + (uriparts.length > 2 ? uriparts[2] : ""));
+ } else {
+ response.sendError(404);
+ }
+ } else {
+ response.sendError(404);
+ }
+ }
+
+ /**
+ * Handles the HTTP <code>POST</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ String uri = request.getRequestURI();
+ if (uri.equals("/post")) {
+ pagesNewMessage.doPostNewMessage(sql, request, response);
+ } else if (uri.equals("/login")) {
+ login.doPostLogin(sql, request, response);
+ } else if (uri.equals("/settings")) {
+ } else {
+ response.sendError(405);
+ }
+ }
+}
diff --git a/src/java/com/juick/http/www/Map.java b/src/java/com/juick/http/www/Map.java
new file mode 100644
index 00000000..1bc625b8
--- /dev/null
+++ b/src/java/com/juick/http/www/Map.java
@@ -0,0 +1,64 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Map {
+
+ protected void doGet(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ com.juick.User visitor = Utils.getVisitorUser(sql, request);
+ Locale locale = request.getLocale();
+ ResourceBundle rb = ResourceBundle.getBundle("Map", locale);
+
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+ PageTemplates.pageHead(out, rb.getString("Messages on map"), "<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAVVtPtxkw4soCEHg44FsNChRB4OFYjAXt73He16Zkp6a_0tPs2RTU6i6UlcMs4QvPBYvIY8rWvcxqOg\" type=\"text/javascript\"></script>"
+ + "<script src=\"http://static.juick.com/mc.js\" type=\"text/javascript\"></script>"
+ + "<script src=\"http://static.juick.com/map.js?2010111500\" type=\"text/javascript\"></script>");
+ PageTemplates.pageNavigation(out, locale, visitor);
+ PageTemplates.pageTitle(out, rb.getString("Messages on map"));
+
+ out.println("<div id=\"wrapper\">");
+ out.println("<div id=\"geomap\" style=\"height: 400px; margin: 1em 0.5em\"></div>");
+ out.println("<div id=\"content\"><ul id=\"messages\"></ul></div>");
+ out.println("<div id=\"column\"><h2>" + rb.getString("Popular places") + "</h2><ul id=\"places\"></ul></div>");
+ out.println("</div>");
+ out.println("<script type=\"text/javascript\">");
+ out.println("$(document).ready(mapInit);");
+ out.println("$(window).unload(GUnload);");
+ out.println("</script>");
+
+ PageTemplates.pageFooter(out, locale);
+ } finally {
+ out.close();
+ }
+ }
+}
diff --git a/src/java/com/juick/http/www/NewMessage.java b/src/java/com/juick/http/www/NewMessage.java
new file mode 100644
index 00000000..8a92b475
--- /dev/null
+++ b/src/java/com/juick/http/www/NewMessage.java
@@ -0,0 +1,37 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import java.io.IOException;
+import java.sql.Connection;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class NewMessage {
+
+ protected void doGetNewMessage(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ }
+
+ protected void doPostNewMessage(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ }
+}
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
new file mode 100644
index 00000000..94561dfd
--- /dev/null
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -0,0 +1,377 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class PageTemplates {
+
+ public static void pageHead(PrintWriter out, String title, String headers) {
+ out.println("<!DOCTYPE html>");
+ out.println("<html>");
+ out.println("<head>");
+ out.println(" <meta charset=\"utf-8\"/>");
+ out.println(" <title>" + title + "</title>");
+ out.println(" <link rel=\"stylesheet\" href=\"http://static.juick.com/style3.css\"/>");
+ out.println(" <link rel=\"icon\" type=\"image/png\" href=\"http://static.juick.com/favicon.png\"/>");
+ out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js\"></script>");
+ out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js\"></script>");
+ out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js\"></script>");
+ out.println(" <script type=\"text/javascript\" src=\"http://static.juick.com/scripts3.js\"></script>");
+ out.println(" <script type=\"text/javascript\" src=\"http://static.juick.com/js/jquery.autoresize.js\"></script>");
+ if (headers != null) {
+ out.println(headers);
+ }
+ out.println("</head>");
+ out.println();
+ out.println("<body>");
+ }
+
+ public static void pageNavigation(PrintWriter out, Locale loc, com.juick.User user) {
+ ResourceBundle rb = ResourceBundle.getBundle("Global", loc);
+ out.println("<div id=\"header\">");
+ out.println("<div id=\"logo\"><a href=\"/?show=my\"><img src=\"http://static.juick.com/logo3.png\" width=\"120\" height=\"40\" alt=\"Juick\" border=\"0\"/></a></div>");
+ out.println(" <ul id=\"nav\">");
+ out.println(" <li><a href=\"/\">" + rb.getString("Blogs") + "</a></li>");
+ out.println(" <li><a href=\"/chats\">" + rb.getString("Chats") + "</a></li>");
+ out.println(" <li><a href=\"/photos\">" + rb.getString("Photos") + "</a></li>");
+ out.println(" <li><a href=\"/map\">" + rb.getString("Map") + "</a></li>");
+ out.println(" </ul>");
+ out.println(" <ul id=\"nav-right\">");
+ if (user != null) {
+ out.println(" <li><a href=\"/post\">" + rb.getString("Post") + "</a></li>");
+ out.println(" <li><a href=\"#\" onclick=\"$('#nav-menu').toggle('blind'); return false\"><img src=\"http://i.juick.com/as/" + user.UID + ".png\" alt=\"@\"/>" + user.UName + "</a><ul id=\"nav-menu\">");
+ out.println(" <li><a href=\"/" + user.UName + "/\">" + rb.getString("Blog") + "</a></li>");
+ out.println(" <li><a href=\"/settings\">" + rb.getString("Settings") + "</a></li>");
+ out.println(" <li><a href=\"/logout\">" + rb.getString("Logout") + "</a></li>");
+ out.println(" </ul></li>");
+ } else {
+ out.println(" <li><a href=\"/login\">" + rb.getString("Login") + "</a></li>");
+ }
+ out.println(" </ul>");
+ out.println("</div>");
+ }
+
+ public static void pageTitle(PrintWriter out, String title) {
+ out.println("<div id=\"title\">");
+ out.println(" <h1>" + title + "</h1>");
+ out.println("</div>");
+ }
+
+ public static void pageUserTitle(PrintWriter out, Connection sql, Locale loc, com.juick.User user, com.juick.User visitor) {
+ ResourceBundle rb = ResourceBundle.getBundle("User", loc);
+
+ // Full name and description
+ String fullname = null;
+ String description = null;
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT fullname,descr FROM usersinfo WHERE user_id=?");
+ stmt.setInt(1, user.UID);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ fullname = rs.getString(1) + " (" + user.UName + ")";
+ description = rs.getString(2);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ if (fullname == null) {
+ fullname = user.UName;
+ }
+ if (description == null) {
+ description = "";
+ }
+
+ // I read
+ int iread = 0;
+ try {
+ stmt = sql.prepareStatement("SELECT COUNT(*) FROM subscr_users WHERE suser_id=?");
+ stmt.setInt(1, user.UID);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ iread = rs.getInt(1);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ // My readers
+ int myreaders = 0;
+ try {
+ stmt = sql.prepareStatement("SELECT COUNT(*) FROM subscr_users WHERE user_id=?");
+ stmt.setInt(1, user.UID);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ myreaders = rs.getInt(1);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ // Messages
+ int messages = 0;
+ try {
+ stmt = sql.prepareStatement("SELECT COUNT(*) FROM messages WHERE user_id=?");
+ stmt.setInt(1, user.UID);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ messages = rs.getInt(1);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ // Replies
+ int replies = 0;
+ try {
+ stmt = sql.prepareStatement("SELECT COUNT(*) FROM replies WHERE user_id=?");
+ stmt.setInt(1, user.UID);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ replies = rs.getInt(1);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ out.println("<div id=\"title\"><div id=\"title-container\">");
+ out.println(" <div id=\"title-av\"><a href=\"/" + user.UName + "/\"><img src=\"http://i.juick.com/a/" + user.UID + ".png\" width=\"96\" height=\"96\" alt=\"" + user.UName + "\"/></a></div>");
+ out.println(" <div id=\"title-stats\"><ul>");
+ out.println(" <li>" + rb.getString("(Stats) I read") + ": " + iread + "</li>");
+ out.println(" <li>" + rb.getString("(Stats) My readers") + ": " + myreaders + "</li>");
+ out.println(" <li>" + rb.getString("(Stats) Messages") + ": " + messages + "</li>");
+ out.println(" <li>" + rb.getString("(Stats) Replies") + ": " + replies + "</li>");
+ out.println(" </ul></div>");
+ out.println(" <div id=\"title-username\"><h1>" + fullname + "</h1><p>" + description + "</p></div>");
+ out.println("</div></div>");
+ out.println();
+ }
+
+ public static void pageFooter(PrintWriter out, Locale loc) {
+ ResourceBundle rb = ResourceBundle.getBundle("Global", loc);
+ out.println("<div id=\"fwrapper\"><div id=\"footer\">");
+ out.println(" <div id=\"footer-right\"><a href=\"/help/contacts\">" + rb.getString("Contacts") + "</a> &#183; <a href=\"/help/\">" + rb.getString("Help") + "</a></div>");
+ out.println(" <div id=\"footer-left\">juick.com &copy; 2008-2011</div>");
+ out.println("</div>");
+ }
+
+ public static String formatTags(String tags) {
+ String ret = "";
+ String tagsarr[] = tags.split(" ");
+ for (int i = 0; i < tagsarr.length; i++) {
+ String tag = tagsarr[i];
+ tag = tag.replaceAll("<", "&lt;");
+ tag = tag.replaceAll(">", "&gt;");
+ try {
+ ret += " *<a href=\"/?tag=" + URLEncoder.encode(tagsarr[i], "utf-8") + "\">" + tag + "</a>";
+ } catch (UnsupportedEncodingException e) {
+ }
+ }
+
+ return ret;
+ }
+
+ public static String formatDate(int minsago, String fulldate, Locale loc) {
+ if (minsago < 1) {
+ return "now";
+ } else if (minsago < 60) {
+ return minsago + " minute" + ((minsago % 10 == 1) ? "" : "s") + " ago";
+ } else if (minsago < 1440) {
+ int hours = (minsago / 60);
+ return hours + " hour" + ((hours % 10 == 1) ? "" : "s") + " ago";
+ } else if (minsago < 20160) {
+ int days = (minsago / 1440);
+ return days + " day" + ((days % 10 == 1) ? "" : "s") + " ago";
+ } else {
+ return fulldate;
+ }
+ }
+
+ public static String formatReplies(int replies, Locale loc) {
+ return replies + " repl" + (replies % 10 == 1 ? "y" : "ies");
+ }
+
+ public static String formatMessage(String msg) {
+ msg = msg.replaceAll("&", "&amp;");
+ msg = msg.replaceAll("<", "&lt;");
+ msg = msg.replaceAll(">", "&gt;");
+
+ // --
+ // &mdash;
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A))\\-\\-?((?=\\s)|(?=\\Z))", "$1&mdash;$2");
+
+ // http://juick.com/last?page=2
+ // <a href="http://juick.com/last?page=2" rel="nofollow">juick.com</a>
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A))((?:ht|f)tps?://(?:www\\.)?([^\\/\\s\\n\\\"]+)/?[^\\s\\n\\\"]*)", "$1<a href=\"$2\" rel=\"nofollow\">$3</a>");
+
+ // #12345
+ // <a href="http://juick.com/12345">#12345</a>
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A)|(?<=[[:punct:]]))#(\\d+)((?=\\s)|(?=\\Z)|(?=\\))|(?=\\.)|(?=\\,))", "$1<a href=\"http://juick.com/$2\">#$2</a>$3");
+
+ // #12345/65
+ // <a href="http://juick.com/12345#65">#12345/65</a>
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A)|(?<=[[:punct:]]))#(\\d+)/(\\d+)((?=\\s)|(?=\\Z)|(?=[[:punct:]]))", "$1<a href=\"http://juick.com/$2#$3\">#$2/$3</a>$4");
+
+ // *bold*
+ // <b>bold</b>
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A)|(?<=[[:punct:]]))\\*([^\\*\\n<>]+)\\*((?=\\s)|(?=\\Z)|(?=[[:punct:]]))", "$1<b>$2</b>$3");
+
+ // /italic/
+ // <i>italic</i>
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A))/([^\\/\\n<>]+)/((?=\\s)|(?=\\Z)|(?=[[:punct:]]))", "$1<i>$2</i>$3");
+
+ // _underline_
+ // <span class="u">underline</span>
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A))_([^\\_\\n<>]+)_((?=\\s)|(?=\\Z)|(?=[[:punct:]]))", "$1<span class=\"u\">$2</span>$3");
+
+ // /12
+ // <a href="#12">/12</a>
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A))\\/(\\d+)((?=\\s)|(?=\\Z)|(?=[[:punct:]]))", "$1<a href=\"#$2\">/$2</a>$3");
+
+ // @username@jabber.org
+ // <a href="http://juick.com/username@jabber.org/">@username@jabber.org</a>
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A))@([\\w\\-\\|\\.]+@[\\w\\-\\.]+)((?=\\s)|(?=\\Z)|(?=[[:punct:]]))", "$1<a href=\"http://juick.com/$2/\">@$2</a>$3");
+
+ // @username
+ // <a href="http://juick.com/username@jabber.org/">@username@jabber.org</a>
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A))@([\\w\\-]+)((?=\\s)|(?=\\Z)|(?=[[:punct:]]))", "$1<a href=\"http://juick.com/$2/\">@$2</a>$3");
+
+ // (http://juick.com/last?page=2)
+ // (<a href="http://juick.com/last?page=2" rel="nofollow">juick.com</a>)
+ msg = msg.replaceAll("((?<=\\s)|(?<=\\A))([\\(\\[\\{]|&lt;)((?:ht|f)tps?://(?:www\\.)?([^\\/\\s\\n\\\"\\)\\!]+)/?[^\\s]*)([\\)\\]\\}]|&gt;)", "$1$2<a href=\"$3\" rel=\"nofollow\">$4</a>$5");
+
+ // > citate
+ msg = msg.replaceAll("(?:(?<=\\n)|(?<=\\A))&gt;\\s(.*)(\\n|(?=\\Z))", "<blockquote>$1</blockquote>");
+ msg = msg.replaceAll("</blockquote><blockquote>", "\n");
+
+ msg = msg.replaceAll("\n", "<br/>\n");
+ return msg;
+ }
+
+ public static void printMessages(PrintWriter out, Connection sql, ArrayList<Integer> mids, Locale locale) {
+ ResourceBundle rb = ResourceBundle.getBundle("Global", locale);
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT STRAIGHT_JOIN messages.message_id,messages.user_id,users.nick,messages_txt.tags,messages.readonly,messages.privacy,messages_txt.txt,TIMESTAMPDIFF(MINUTE,messages.ts,NOW()),messages.ts,messages.replies,messages_txt.repliesby,messages.attach,messages.place_id,places.name,messages.lat,messages.lon FROM ((messages INNER JOIN messages_txt ON messages.message_id=messages_txt.message_id) INNER JOIN users ON messages.user_id=users.id) LEFT JOIN places ON messages.place_id=places.place_id WHERE messages.message_id IN (" + Utils.convertArray2String(mids) + ") ORDER BY messages.message_id DESC");
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ int mid = rs.getInt(1);
+ int uid = rs.getInt(2);
+ String uname = rs.getString(3);
+ String tags = rs.getString(4);
+ String txt = rs.getString(7);
+ // timediff
+ // timestamp
+ // replies
+ // 11 repliesby
+ // attach
+ // pid
+ // pname
+ // lat
+ // lon
+
+ tags = (tags != null) ? formatTags(tags) : "";
+ if (rs.getInt(5) == 1) {
+ tags += " *readonly";
+ }
+ switch (rs.getInt(6)) {
+ case 2:
+ tags += " *public";
+ break;
+ case -1:
+ tags += " *friends";
+ break;
+ case -2:
+ tags += " *private";
+ break;
+ }
+
+ txt = formatMessage(txt);
+
+ if (mid == mids.get(0)) {
+ out.println(" <li class=\"msg\" style=\"border: 0\">");
+ } else {
+ out.println(" <li class=\"msg\">");
+ }
+
+ if (rs.getString(12) != null) {
+ if (rs.getString(12).equals("jpg")) {
+ out.println(" <div class=\"msg-media\"><img src=\"http://i.juick.com/photos-512/" + mid + ".jpg\" alt=\"\"/></div>");
+ } else {
+ out.println(" <div class=\"msg-media\"><div id=\"video-" + mid + "\"><b>Attachment: <a href=\"http://i.juick.com/video/" + mid + ".mp4\">Video</a></b></div></div>");
+ out.println(" <script type=\"text/javascript\">");
+ out.println(" inlinevideo(" + mid + ");");
+ out.println(" </script>");
+ }
+ }
+
+ out.println(" <div class=\"msg-avatar\"><a href=\"/" + uname + "/\"><img src=\"http://i.juick.com/a/" + uid + ".png\"></a></div>");
+ out.println(" <div class=\"msg-ts\"><a href=\"/" + uname + "/" + mid + "\">" + formatDate(rs.getInt(8), rs.getString(9), locale) + "</a><div class=\"msg-menu\"><a href=\"#\" onclick=\"$('#msg-menu-" + mid + "').toggle('blind'); return false\"><img src=\"http://static.juick.com/message-menu-icon.png\"></a><ul id=\"msg-menu-" + mid + "\">");
+ out.println(" <li><a href=\"#\" onclick=\"return false\">Under construction</a></li>");
+ out.println(" </ul></div></div>");
+ out.println(" <div class=\"msg-header\"><a href=\"/" + uname + "/\">@" + uname + "</a>:" + tags + "</div>");
+ out.println(" <div class=\"msg-txt\">" + txt + "</div>");
+
+ if (rs.getInt(10) > 0) {
+ String repliesby = rs.getString(11);
+ if (repliesby == null) {
+ repliesby = "...";
+ }
+ out.println(" <div class=\"msg-comments\"><a href=\"/" + uname + "/" + mid + "\">" + formatReplies(rs.getInt(10), locale) + "</a> " + rb.getString("(replies) by") + " " + repliesby + "</div>");
+ } else {
+ out.println(" <form action=\"/post\" method=\"POST\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"mid\" value=\"" + mid + "\"/>");
+ out.println(" <div class=\"msg-comment\"><textarea name=\"body\" rows=\"1\" placeholder=\"Add a comment...\" onkeypress=\"postformListener(this.form,event)\"></textarea></div>");
+ out.println(" </form>");
+ }
+ out.println(" </li>");
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ }
+}
diff --git a/src/java/com/juick/http/www/Photos.java b/src/java/com/juick/http/www/Photos.java
new file mode 100644
index 00000000..7a202625
--- /dev/null
+++ b/src/java/com/juick/http/www/Photos.java
@@ -0,0 +1,100 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Photos {
+
+ protected void doGet(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ com.juick.User visitor = Utils.getVisitorUser(sql, request);
+ Locale locale = request.getLocale();
+ ResourceBundle rb = ResourceBundle.getBundle("Photos", locale);
+
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+ PageTemplates.pageHead(out, rb.getString("Last photos and videos"), "<script type=\"text/javascript\" src=\"http://static.juick.com/js/jquery.onImagesLoad.min.js\"></script>"
+ + "<script type=\"text/javascript\" src=\"http://static.juick.com/js/gallery.js\"></script>"
+ + "<script type=\"text/javascript\" src=\"http://static.juick.com/js/jquery.fancybox-1.3.4.js\"></script>"
+ + "<link rel=\"stylesheet\" href=\"http://static.juick.com/fancybox/jquery.fancybox-1.3.4.css\"/>");
+ PageTemplates.pageNavigation(out, locale, visitor);
+ PageTemplates.pageTitle(out, rb.getString("Last photos and videos"));
+
+ out.println("<div id=\"wrapper\">");
+ out.println("<div id=\"spinner\" style=\"text-align: center\">Loading...</div>");
+ out.println("<ul id=\"gallery\" style=\"display: none\">");
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT messages.message_id,messages.attach,users.nick FROM messages INNER JOIN users ON messages.user_id=users.id WHERE messages.attach IS NOT NULL ORDER BY message_id DESC LIMIT 20");
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ if (rs.getString(2).equals("jpg")) {
+ out.println("<li class=\"galleryitem\"><a href=\"/" + rs.getString(3) + "/" + rs.getInt(1) + "\" title=\"@" + rs.getString(3) + "\"><img src=\"http://i.juick.com/photos-512/" + rs.getInt(1) + ".jpg\" alt=\"\"></a></li>");
+ } else {
+ out.println("<li class=\"galleryitem\"><a href=\"/" + rs.getString(3) + "/" + rs.getInt(1) + "\" title=\"@" + rs.getString(3) + "\"><img src=\"http://i.juick.com/thumbs/" + rs.getInt(1) + ".jpg\" alt=\"\"></a></li>");
+ }
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ out.println("</ul>");
+ out.println("</div>");
+ out.println("<script type=\"text/javascript\">");
+ out.println("$('#gallery').onImagesLoad({selectorCallback: galleryResize});");
+ out.println("$('.galleryitem a').click(function() {");
+ out.println(" $.fancybox({");
+ out.println(" 'href': $(this).children('img').attr('src'),");
+ out.println(" 'link': this.href,");
+ out.println(" 'title': this.title,");
+ out.println(" 'orig': this,");
+ out.println(" 'transitionIn': 'elastic',");
+ out.println(" 'transitionOut': 'none',");
+ out.println(" 'easingIn': 'easeOutBack',");
+ out.println(" 'easingOut': 'easeInBack'");
+ out.println(" });");
+ out.println(" return false;");
+ out.println("});");
+ out.println("</script>");
+
+ PageTemplates.pageFooter(out, locale);
+ } finally {
+ out.close();
+ }
+ }
+}
diff --git a/src/java/com/juick/http/www/RootRedirects.java b/src/java/com/juick/http/www/RootRedirects.java
new file mode 100644
index 00000000..d4e17972
--- /dev/null
+++ b/src/java/com/juick/http/www/RootRedirects.java
@@ -0,0 +1,53 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import java.io.IOException;
+import java.sql.Connection;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class RootRedirects {
+
+ protected void doGetPostID(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ String strID = request.getRequestURI().substring(1);
+ int mid = Integer.parseInt(strID);
+ if (mid > 0) {
+ com.juick.User author = com.juick.server.MessagesQueries.getMessageAuthor(sql, mid);
+ if (author != null) {
+ Utils.sendPermanentRedirect(response, "/" + author.UName + "/" + mid);
+ return;
+ }
+ }
+ response.sendError(404);
+ }
+
+ protected void doGetUsername(Connection sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ com.juick.User user = com.juick.server.UserQueries.getUserByNick(sql, request.getRequestURI().substring(1));
+ if (user != null) {
+ Utils.sendPermanentRedirect(response, "/" + user.UName + "/");
+ } else {
+ response.sendError(404);
+ }
+ }
+}
diff --git a/src/java/com/juick/http/www/User.java b/src/java/com/juick/http/www/User.java
new file mode 100644
index 00000000..fefe1174
--- /dev/null
+++ b/src/java/com/juick/http/www/User.java
@@ -0,0 +1,198 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import com.juick.server.MessagesQueries;
+import com.juick.server.TagQueries;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class User {
+
+ protected void doGetBlog(Connection sql, Connection sqlSearch, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException {
+ com.juick.User visitor = Utils.getVisitorUser(sql, request);
+ Locale locale = request.getLocale();
+ ResourceBundle rb = ResourceBundle.getBundle("User", locale);
+
+ String title = "@" + user.UName + " - ";
+ ArrayList<Integer> mids;
+
+ String paramShow = request.getParameter("show");
+
+ int paramTag = 0;
+ String paramTagStr = request.getParameter("tag");
+ if (paramTagStr != null && paramTagStr.length() < 64) {
+ paramTag = TagQueries.getTagID(sql, paramTagStr, false);
+ }
+
+ int paramBefore = 0;
+ String paramBeforeStr = request.getParameter("before");
+ if (paramBeforeStr != null) {
+ try {
+ paramBefore = Integer.parseInt(paramBeforeStr);
+ } catch (NumberFormatException e) {
+ }
+ }
+
+ String paramSearch = request.getParameter("search");
+ if (paramSearch != null && paramSearch.length() > 64) {
+ paramSearch = null;
+ }
+
+ if (paramShow == null) {
+ if (paramTag > 0) {
+ title += "*" + Utils.encodeHTML(paramTagStr);
+ mids = MessagesQueries.getUserTag(sql, user.UID, paramTag, paramBefore);
+ } else if (paramSearch != null) {
+ title += rb.getString("(Menu) Search") + ": " + Utils.encodeHTML(paramSearch);
+ mids = MessagesQueries.getUserSearch(sql, sqlSearch, user.UID, Utils.encodeSphinx(paramSearch), paramBefore);
+ } else {
+ title += rb.getString("(Menu) Blog");
+ mids = MessagesQueries.getUserBlog(sql, user.UID, paramBefore);
+ }
+ } else if (paramShow.equals("recomm")) {
+ title += rb.getString("(Menu) Recommendations");
+ mids = MessagesQueries.getUserRecommendations(sql, user.UID, paramBefore);
+ } else if (paramShow.equals("photos")) {
+ title += rb.getString("(Menu) Photos");
+ mids = MessagesQueries.getUserPhotos(sql, user.UID, paramBefore);
+ } else {
+ response.sendError(404);
+ return;
+ }
+
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+ PageTemplates.pageHead(out, title, null);
+ PageTemplates.pageNavigation(out, locale, visitor);
+ PageTemplates.pageUserTitle(out, sql, locale, user, visitor);
+
+ out.println("<div id=\"wrapper\">");
+ out.println("<div id=\"content\">");
+ out.println("<ul>");
+
+ if (mids.size() > 0) {
+ PageTemplates.printMessages(out, sql, mids, locale);
+ }
+
+ out.println("</ul>");
+ out.println("<script type=\"text/javascript\">");
+ out.println("$(\"textarea\").autoResize();");
+ out.println("</script>");
+
+ if (mids.size() == 20) {
+ String nextpage = "?before=" + mids.get(19);
+ if (paramShow != null) {
+ nextpage += "&show=" + paramShow;
+ }
+ if (paramTag > 0) {
+ nextpage += "&tag=" + URLEncoder.encode(paramTagStr, "UTF-8");
+ }
+ out.println("<p class=\"page\"><a href=\"" + nextpage + "\">Older →</a></p>");
+ }
+
+ out.println("</div>");
+
+ out.println("<div id=\"column\">");
+ out.println("<h2>" + rb.getString("(Menu) Messages") + "</h2>");
+ out.println("<ul>");
+ out.println(" <li><a href=\"?\">" + rb.getString("(Menu) Blog") + "</a></li>");
+ out.println(" <li><a href=\"?show=recomm\">" + rb.getString("(Menu) Recommendations") + "</a></li>");
+ out.println(" <li><a href=\"?show=photos\">" + rb.getString("(Menu) Photos") + "</a></li>");
+ out.println("</ul>");
+ out.println("<h2>" + rb.getString("(Menu) Tags") + "</h2>");
+ pageUserTags(out, sql, user, visitor, 15);
+ out.println("<h2>" + rb.getString("(Menu) Search") + "</h2>");
+ out.println("<form action=\"./\" id=\"search\"><p><input type=\"text\" name=\"search\" class=\"inp\"/></p></form>");
+ out.println("</div>");
+ out.println("</div>");
+
+ PageTemplates.pageFooter(out, locale);
+ } finally {
+ out.close();
+ }
+ }
+
+ protected void doGetInfo(Connection sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException {
+ }
+
+ public static void pageUserTags(PrintWriter out, Connection sql, com.juick.User user, com.juick.User visitor, int cnt) {
+ com.juick.Tag tags[] = new com.juick.Tag[cnt];
+
+ int maxUsageCnt = 0;
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT tags.name AS name,COUNT(DISTINCT messages_tags.message_id) AS cnt FROM (messages INNER JOIN messages_tags ON (messages.message_id=messages_tags.message_id)) INNER JOIN tags ON messages_tags.tag_id=tags.tag_id WHERE messages.user_id=? GROUP BY messages_tags.tag_id ORDER BY cnt DESC LIMIT ?");
+ stmt.setInt(1, user.UID);
+ stmt.setInt(2, cnt);
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ cnt = 0;
+ while (rs.next()) {
+ tags[cnt] = new com.juick.Tag();
+ tags[cnt].Name = rs.getString(1);
+ tags[cnt].UsageCnt = rs.getInt(2);
+ if (tags[cnt].UsageCnt > maxUsageCnt) {
+ maxUsageCnt = tags[cnt].UsageCnt;
+ }
+ cnt++;
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ Arrays.sort(tags, 0, cnt);
+
+ for (int i = 0; i < cnt; i++) {
+ String tag = Utils.encodeHTML(tags[i].Name);
+ try {
+ tag = "<a href=\"?tag=" + URLEncoder.encode(tags[i].Name, "UTF-8") + "\" title=\"" + tags[i].UsageCnt + "\">" + tag + "</a>";
+ } catch (UnsupportedEncodingException e) {
+ }
+
+ if (tags[i].UsageCnt > maxUsageCnt / 3 * 2) {
+ out.print("<big>" + tag + "</big> ");
+ } else if (tags[i].UsageCnt > maxUsageCnt / 3) {
+ out.print("<small>" + tag + "</small> ");
+ } else {
+ out.print(tag + " ");
+ }
+ }
+ }
+}
diff --git a/src/java/com/juick/http/www/UserThread.java b/src/java/com/juick/http/www/UserThread.java
new file mode 100644
index 00000000..6688e964
--- /dev/null
+++ b/src/java/com/juick/http/www/UserThread.java
@@ -0,0 +1,298 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import com.juick.server.UserQueries;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class UserThread {
+
+ protected void doGetThread(Connection sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user, int MID) throws ServletException, IOException {
+ com.juick.User visitor = Utils.getVisitorUser(sql, request);
+ Locale locale = request.getLocale();
+ ResourceBundle rb = ResourceBundle.getBundle("User", locale);
+
+ boolean listview = false;
+ String paramView = request.getParameter("view");
+ if (paramView != null) {
+ if (paramView.equals("list")) {
+ listview = true;
+ if (visitor != null) {
+ UserQueries.setUserOptionInt(sql, visitor.UID, "repliesview", 1);
+ }
+ } else if (paramView.equals("tree") && visitor != null) {
+ UserQueries.setUserOptionInt(sql, visitor.UID, "repliesview", 0);
+ }
+ } else if (visitor != null && UserQueries.getUserOptionInt(sql, visitor.UID, "repliesview", 0) == 1) {
+ listview = true;
+ }
+
+ String title = "@" + user.UName + " - #" + MID;
+
+ response.setContentType("text/html; charset=UTF-8");
+ PrintWriter out = response.getWriter();
+ try {
+ PageTemplates.pageHead(out, title, null);
+ PageTemplates.pageNavigation(out, locale, visitor);
+ PageTemplates.pageUserTitle(out, sql, locale, user, visitor);
+
+ out.println("<div id=\"wrapper\">");
+ out.println("<div id=\"content\" style=\"margin-left: 0; width: 100%\">");
+
+ out.println("<ul>");
+ printMessage(out, sql, MID, locale);
+ out.println("</ul>");
+
+ out.println("<div class=\"title2\">");
+ out.print(" <div class=\"title2-right\">");
+ if (listview) {
+ out.print("<a href=\"?view=tree\">" + rb.getString("View as tree") + "</a>");
+ } else {
+ out.print("<a href=\"#\" onclick=\"$('#replies>li').show(); $('#replies .msg-comments').hide(); return false\">" + rb.getString("Expand all") + "</a> &#183; <a href=\"?view=list\">" + rb.getString("View as list") + "</a>");
+ }
+ out.print("</div>");
+ out.println(" <h2>Replies</h2>");
+ out.println("</div>");
+
+ out.println("<ul id=\"replies\">");
+ printReplies(out, sql, MID, locale, listview);
+ out.println("</ul>");
+
+ out.println("<script type=\"text/javascript\">");
+ out.println("$(\"textarea\").autoResize();");
+ out.println("</script>");
+
+ out.println("</div>");
+
+ out.println("</div>");
+
+ PageTemplates.pageFooter(out, locale);
+ } finally {
+ out.close();
+ }
+ }
+
+ public static void printMessage(PrintWriter out, Connection sql, int mid, Locale locale) {
+ ResourceBundle rb = ResourceBundle.getBundle("Global", locale);
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT STRAIGHT_JOIN messages.message_id,messages.user_id,users.nick,messages_txt.tags,messages.readonly,messages.privacy,messages_txt.txt,TIMESTAMPDIFF(MINUTE,messages.ts,NOW()),messages.ts,messages.replies,messages.attach,messages.place_id,places.name,messages.lat,messages.lon FROM ((messages INNER JOIN messages_txt ON messages.message_id=messages_txt.message_id) INNER JOIN users ON messages.user_id=users.id) LEFT JOIN places ON messages.place_id=places.place_id WHERE messages.message_id=?");
+ stmt.setInt(1, mid);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ int uid = rs.getInt(2);
+ String uname = rs.getString(3);
+ String tags = rs.getString(4);
+ String txt = rs.getString(7);
+ // timediff
+ // timestamp
+ // replies
+ // attach
+ // pid
+ // pname
+ // lat
+ // lon
+
+ tags = (tags != null) ? PageTemplates.formatTags(tags) : "";
+ if (rs.getInt(5) == 1) {
+ tags += " *readonly";
+ }
+ switch (rs.getInt(6)) {
+ case 2:
+ tags += " *public";
+ break;
+ case -1:
+ tags += " *friends";
+ break;
+ case -2:
+ tags += " *private";
+ break;
+ }
+
+ txt = PageTemplates.formatMessage(txt);
+
+ out.println(" <li class=\"msg\" style=\"border: 0\">");
+
+ if (rs.getString(11) != null) {
+ if (rs.getString(11).equals("jpg")) {
+ out.println(" <div class=\"msg-media\"><img src=\"http://i.juick.com/photos-512/" + mid + ".jpg\" alt=\"\"/></div>");
+ } else {
+ out.println(" <div class=\"msg-media\"><div id=\"video-" + mid + "\"><b>Attachment: <a href=\"http://i.juick.com/video/" + mid + ".mp4\">Video</a></b></div></div>");
+ out.println(" <script type=\"text/javascript\">");
+ out.println(" inlinevideo(" + mid + ");");
+ out.println(" </script>");
+ }
+ }
+
+ out.println(" <div class=\"msg-avatar\"><a href=\"/" + uname + "/\"><img src=\"http://i.juick.com/a/" + uid + ".png\"></a></div>");
+ out.println(" <div class=\"msg-ts\"><a href=\"/" + uname + "/" + mid + "\">" + PageTemplates.formatDate(rs.getInt(8), rs.getString(9), locale) + "</a><div class=\"msg-menu\"><a href=\"#\" onclick=\"$('#msg-menu-" + mid + "').toggle('blind'); return false\"><img src=\"http://static.juick.com/message-menu-icon.png\"></a><ul id=\"msg-menu-" + mid + "\">");
+ out.println(" <li><a href=\"#\" onclick=\"return false\">Under construction</a></li>");
+ out.println(" </ul></div></div>");
+ out.println(" <div class=\"msg-header\"><a href=\"/" + uname + "/\">@" + uname + "</a>:" + tags + "</div>");
+ out.println(" <div class=\"msg-txt\">" + txt + "</div>");
+ out.println(" </li>");
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ }
+
+ public static void printReplies(PrintWriter out, Connection sql, int mid, Locale locale, boolean listview) {
+ ArrayList<com.juick.Message> replies = new ArrayList<com.juick.Message>();
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT replies.reply_id,replies.replyto,replies.user_id,users.nick,replies.txt,TIMESTAMPDIFF(MINUTE,replies.ts,NOW()),replies.ts,replies.attach FROM replies INNER JOIN users ON replies.user_id=users.id WHERE replies.message_id=? ORDER BY replies.reply_id ASC");
+ stmt.setInt(1, mid);
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ com.juick.Message msg = new com.juick.Message();
+ msg.MID = mid;
+ msg.RID = rs.getInt(1);
+ msg.ReplyTo = rs.getInt(2);
+ msg.User = new com.juick.User();
+ msg.User.UID = rs.getInt(3);
+ msg.User.UName = rs.getString(4);
+ msg.Text = PageTemplates.formatMessage(rs.getString(5));
+ msg.MinutesAgo = rs.getInt(6);
+ msg.TimestampString = rs.getString(7);
+ msg.AttachmentType = rs.getString(8);
+
+ replies.add(msg);
+
+ if (msg.ReplyTo > 0) {
+ boolean added = false;
+ for (int i = 0; i < replies.size(); i++) {
+ if (replies.get(i).RID == msg.ReplyTo) {
+ replies.get(i).childs.add(msg);
+ added = true;
+ break;
+ }
+ }
+ if (!added) {
+ msg.ReplyTo = 0;
+ }
+ }
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ if (listview) {
+ printList(out, replies, locale);
+ } else {
+ printTree(out, replies, 0, 0, locale);
+ }
+
+ for (int i = 0; i < replies.size(); i++) {
+ replies.get(i).cleanupChilds();
+ }
+ replies.clear();
+ }
+
+ public static void printTree(PrintWriter out, ArrayList<com.juick.Message> replies, int ReplyTo, int margin, Locale locale) {
+ for (int i = 0; i < replies.size(); i++) {
+ com.juick.Message msg = replies.get(i);
+ if (msg.ReplyTo == ReplyTo) {
+
+ out.print(" <li id=\"" + msg.RID + "\" class=\"msg\" style=\"");
+ if (i == 0) {
+ out.print("border: 0;");
+ }
+ if (margin > 0) {
+ out.print("margin-left: " + margin + "px;display:none;");
+ }
+ out.println("\">");
+ if (msg.AttachmentType != null) {
+ if (msg.AttachmentType.equals("jpg")) {
+ out.println(" <div class=\"msg-media\"><img src=\"http://i.juick.com/photos-512/" + msg.MID + "-" + msg.RID + ".jpg\" alt=\"\"/></div>");
+ } else {
+ out.println(" <div class=\"msg-media\"><div id=\"video-" + msg.MID + "-" + msg.RID + "\"><b>Attachment: <a href=\"http://i.juick.com/video/" + msg.MID + "-" + msg.RID + ".mp4\">Video</a></b></div></div>");
+ out.println(" <script type=\"text/javascript\">");
+ out.println(" inlinevideo('" + msg.MID + "-" + msg.RID + "');");
+ out.println(" </script>");
+ }
+ }
+ out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"http://i.juick.com/a/" + msg.User.UID + ".png\"></a></div>");
+ out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "#" + msg.RID + "\">" + PageTemplates.formatDate(msg.MinutesAgo, msg.TimestampString, locale) + "</a><div class=\"msg-menu\"><a href=\"#\" onclick=\"return msgMenu(" + msg.MID + ")\"><img src=\"http://static.juick.com/message-menu-icon.png\"></a><ul id=\"msg-menu-" + msg.MID + "\">");
+ out.println(" <li><a href=\"#\" onclick=\"return false\">Under construction</a></li>");
+ out.println(" </ul></div></div>");
+ out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:</div>");
+ out.println(" <div class=\"msg-txt\">" + msg.Text + "</div>");
+ if (ReplyTo == 0) {
+ int childs = msg.getChildsCount() - 1;
+ if (childs > 0) {
+ out.println(" <div class=\"msg-comments\"><a href=\"#\" onclick=\"return showMoreReplies(" + msg.RID + ")\">" + PageTemplates.formatReplies(childs, locale) + " more</a></div>");
+ }
+ }
+ out.println(" </li>");
+
+ printTree(out, replies, msg.RID, margin + 20, locale);
+ }
+ }
+ }
+
+ public static void printList(PrintWriter out, ArrayList<com.juick.Message> replies, Locale locale) {
+ for (int i = 0; i < replies.size(); i++) {
+ com.juick.Message msg = replies.get(i);
+
+ out.print(" <li id=\"" + msg.RID + "\" class=\"msg\"" + (i == 0 ? " style=\"border: 0\"" : "") + ">");
+ if (msg.AttachmentType != null) {
+ if (msg.AttachmentType.equals("jpg")) {
+ out.println(" <div class=\"msg-media\"><img src=\"http://i.juick.com/photos-512/" + msg.MID + "-" + msg.RID + ".jpg\" alt=\"\"/></div>");
+ } else {
+ out.println(" <div class=\"msg-media\"><div id=\"video-" + msg.MID + "-" + msg.RID + "\"><b>Attachment: <a href=\"http://i.juick.com/video/" + msg.MID + "-" + msg.RID + ".mp4\">Video</a></b></div></div>");
+ out.println(" <script type=\"text/javascript\">");
+ out.println(" inlinevideo('" + msg.MID + "-" + msg.RID + "');");
+ out.println(" </script>");
+ }
+ }
+ out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"http://i.juick.com/a/" + msg.User.UID + ".png\"></a></div>");
+ out.println(" <div class=\"msg-ts\"><a href=\"/" + msg.User.UName + "/" + msg.MID + "#" + msg.RID + "\">" + PageTemplates.formatDate(msg.MinutesAgo, msg.TimestampString, locale) + "</a><div class=\"msg-menu\"><a href=\"#\" onclick=\"return msgMenu(" + msg.MID + ")\"><img src=\"http://static.juick.com/message-menu-icon.png\"></a><ul id=\"msg-menu-" + msg.MID + "\">");
+ out.println(" <li><a href=\"#\" onclick=\"return false\">Under construction</a></li>");
+ out.println(" </ul></div></div>");
+ out.println(" <div class=\"msg-header\"><a href=\"/" + msg.User.UName + "/\">@" + msg.User.UName + "</a>:</div>");
+ out.println(" <div class=\"msg-txt\">" + msg.Text + "</div>");
+ out.println(" </li>");
+ }
+ }
+}
diff --git a/src/java/com/juick/http/www/Utils.java b/src/java/com/juick/http/www/Utils.java
new file mode 100644
index 00000000..cfa4484d
--- /dev/null
+++ b/src/java/com/juick/http/www/Utils.java
@@ -0,0 +1,112 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.juick.http.www;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Utils {
+
+ public static String getCookie(HttpServletRequest request, String name) {
+ Cookie cookies[] = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; i < cookies.length; i++) {
+ if (cookies[i].getName().equals(name)) {
+ return cookies[i].getValue();
+ }
+ }
+ }
+ return null;
+ }
+
+ public static com.juick.User getVisitorUser(Connection sql, HttpServletRequest request) {
+ String hash = getCookie(request, "hash");
+ if (hash != null) {
+ return com.juick.server.UserQueries.getUserByHash(sql, hash);
+ } else {
+ return null;
+ }
+ }
+
+ public static int getVisitorUID(Connection sql, HttpServletRequest request) {
+ Cookie cookies[] = request.getCookies();
+ if (cookies != null) {
+ for (int i = 0; i < cookies.length; i++) {
+ if (cookies[i].getName().equals("hash")) {
+ String hash = cookies[i].getValue();
+ return com.juick.server.UserQueries.getUIDbyHash(sql, hash);
+ }
+ }
+ }
+ return 0;
+ }
+
+ public static void sendPermanentRedirect(HttpServletResponse response, String location) {
+ response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
+ response.setHeader("Location", location);
+ }
+
+ public static void finishSQL(ResultSet rs, Statement stmt) {
+ if (rs != null) {
+ try {
+ rs.close();
+ } catch (SQLException e) {
+ }
+ }
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ public static String convertArray2String(ArrayList<Integer> mids) {
+ String q = "";
+ for (int i = 0; i < mids.size(); i++) {
+ if (i > 0) {
+ q += ",";
+ }
+ q += mids.get(i);
+ }
+ return q;
+ }
+
+ public static String encodeHTML(String str) {
+ String ret = str;
+ ret = ret.replaceAll("<", "&lt;");
+ ret = ret.replaceAll(">", "&gt;");
+ return str;
+ }
+
+ public static String encodeSphinx(String str) {
+ String ret = str;
+ ret = ret.replaceAll("@", "\\\\@");
+ return ret;
+ }
+}
diff --git a/web/META-INF/context.xml b/web/META-INF/context.xml
new file mode 100644
index 00000000..5bee3dc3
--- /dev/null
+++ b/web/META-INF/context.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Context antiJARLocking="true" path=""/>
diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml
new file mode 100644
index 00000000..16e4d30f
--- /dev/null
+++ b/web/WEB-INF/web.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+ <servlet>
+ <servlet-name>Main</servlet-name>
+ <servlet-class>com.juick.http.www.Main</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Main</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+ <session-config>
+ <session-timeout>
+ 30
+ </session-timeout>
+ </session-config>
+</web-app>