Memories
|
|
@ -0,0 +1,3 @@
|
|||
# Udiary
|
||||
|
||||
This project is recovered from my old computer. It is not a complete project. Also would never be upgraded. Its kept as a good memories of my childhood. I open source it just for education purposes.
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-shared-configuration>
|
||||
<!--
|
||||
This file contains additional configuration written by modules in the NetBeans IDE.
|
||||
The configuration is intended to be shared among all the users of project and
|
||||
therefore it is assumed to be part of version control checkout.
|
||||
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
|
||||
-->
|
||||
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
|
||||
<!--
|
||||
Properties that influence various parts of the IDE, especially code formatting and the like.
|
||||
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
|
||||
That way multiple projects can share the same settings (useful for formatting rules for example).
|
||||
Any value defined here will override the pom.xml file value but is only applicable to the current project.
|
||||
-->
|
||||
<org-netbeans-modules-html-editor-lib.default-html-public-id>-//W3C//DTD HTML 4.01 Frameset//EN</org-netbeans-modules-html-editor-lib.default-html-public-id>
|
||||
</properties>
|
||||
</project-shared-configuration>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<actions>
|
||||
<action>
|
||||
<actionName>CUSTOM-clean package</actionName>
|
||||
<displayName>clean package</displayName>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
<goal>package</goal>
|
||||
</goals>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>CUSTOM-appengine:devserver</actionName>
|
||||
<displayName>appengine:devserver</displayName>
|
||||
<goals>
|
||||
<goal>appengine:devserver</goal>
|
||||
</goals>
|
||||
</action>
|
||||
</actions>
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>war</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<groupId>com.urrsm.sng</groupId>
|
||||
<artifactId>udiary</artifactId>
|
||||
|
||||
<!-- [START set_versions] -->
|
||||
<properties>
|
||||
<appengine.app.version>1.0</appengine.app.version>
|
||||
<appengine.sdk.version>1.9.48</appengine.sdk.version>
|
||||
|
||||
<objectify.version>5.1.21</objectify.version>
|
||||
<guava.version>18.0</guava.version>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<prerequisites>
|
||||
<maven>3.3.9</maven>
|
||||
</prerequisites>
|
||||
<!-- [END set_versions] -->
|
||||
|
||||
<dependencies>
|
||||
<!-- Compile/runtime dependencies -->
|
||||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-api-1.0-sdk</artifactId>
|
||||
<version>${appengine.sdk.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jstl</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- [START Objectify_Dependencies] -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.objectify</groupId>
|
||||
<artifactId>objectify</artifactId>
|
||||
<version>${objectify.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- [END Objectify_Dependencies] -->
|
||||
|
||||
<!-- Test Dependencies -->
|
||||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-testing</artifactId>
|
||||
<version>${appengine.sdk.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-api-stubs</artifactId>
|
||||
<version>${appengine.sdk.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.oauth-client</groupId>
|
||||
<artifactId>google-oauth-client-servlet</artifactId>
|
||||
<version>1.22.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.oauth-client</groupId>
|
||||
<artifactId>google-oauth-client-appengine</artifactId>
|
||||
<version>1.22.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.api-client</groupId>
|
||||
<artifactId>google-api-client</artifactId>
|
||||
<version>1.22.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.apis</groupId>
|
||||
<artifactId>google-api-services-oauth2</artifactId>
|
||||
<version>v2-rev127-1.22.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.apis</groupId>
|
||||
<artifactId>google-api-services-drive</artifactId>
|
||||
<version>v3-rev76-1.22.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.4.9</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.json</groupId>
|
||||
<artifactId>javax.json-api</artifactId>
|
||||
<version>1.1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>javax.json</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!-- for hot reload of the web application-->
|
||||
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>versions-maven-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>display-dependency-updates</goal>
|
||||
<goal>display-plugin-updates</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<version>3.2</version>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<archiveClasses>true</archiveClasses>
|
||||
<webResources>
|
||||
<!-- in order to interpolate version from pom into appengine-web.xml -->
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
|
||||
<filtering>true</filtering>
|
||||
<targetPath>WEB-INF</targetPath>
|
||||
</resource>
|
||||
</webResources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.google.appengine</groupId>
|
||||
<artifactId>appengine-maven-plugin</artifactId>
|
||||
<version>${appengine.sdk.version}</version>
|
||||
<configuration>
|
||||
<enableJarClasses>false</enableJarClasses>
|
||||
<!-- Comment in the below snippet to bind to all IPs instead of just localhost -->
|
||||
<!-- address>0.0.0.0</address>
|
||||
<port>8080</port -->
|
||||
<!-- Comment in the below snippet to enable local debugging with a remote debugger
|
||||
like those included with Eclipse or IntelliJ -->
|
||||
<!-- jvmFlags>
|
||||
<jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag>
|
||||
</jvmFlags -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
$.ajax({
|
||||
url: "/drive",
|
||||
type: "post",
|
||||
dataType : "json",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({cmd: "list"}),
|
||||
success: function(r){
|
||||
console.log(r);
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1,402 @@
|
|||
package com.urrsm.sng.udiary;
|
||||
|
||||
import com.google.api.client.auth.oauth2.Credential;
|
||||
import com.google.api.client.auth.oauth2.StoredCredential;
|
||||
import com.google.api.client.extensions.appengine.datastore.AppEngineDataStoreFactory;
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl;
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest;
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse;
|
||||
import com.google.api.client.http.HttpTransport;
|
||||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
import com.google.api.client.util.store.DataStore;
|
||||
import com.google.api.client.util.store.DataStoreFactory;
|
||||
import com.google.api.services.oauth2.Oauth2;
|
||||
import com.google.api.services.oauth2.model.Userinfoplus;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Collection;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Object that manages credentials associated with this Drive application and
|
||||
* its users. Performs all OAuth 2.0 authorization, authorization code
|
||||
* upgrades, and token storage/retrieval.
|
||||
*
|
||||
* @author vicfryzel@google.com (Vic Fryzel)
|
||||
*/
|
||||
public class CredentialMediator
|
||||
{
|
||||
|
||||
/**
|
||||
* The HTTP request used to make a request to this Drive application.
|
||||
* Required so that we can manage a session for the active user, and keep
|
||||
* track of their email address which is used to identify their credentials.
|
||||
* We also need this in order to access a bunch of request parameters like
|
||||
* {@code state} and {@code code}.
|
||||
*/
|
||||
private HttpServletRequest request;
|
||||
|
||||
/**
|
||||
* Scopes for which to request authorization.
|
||||
*/
|
||||
private Collection<String> scopes;
|
||||
|
||||
/**
|
||||
* Loaded data from war/WEB-INF/client_secrets.json.
|
||||
*/
|
||||
private GoogleClientSecrets secrets;
|
||||
|
||||
/**
|
||||
* DataStore of StoredCredentials.
|
||||
*/
|
||||
private DataStore<StoredCredential> credentialsStore;
|
||||
|
||||
/**
|
||||
* JsonFactory to use in parsing JSON.
|
||||
*/
|
||||
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
|
||||
|
||||
/**
|
||||
* HttpTransport to use for external requests.
|
||||
*/
|
||||
private static final HttpTransport TRANSPORT = new NetHttpTransport();
|
||||
|
||||
/**
|
||||
* Key of session variable to store user IDs.
|
||||
*/
|
||||
private static final String USER_ID_KEY = "userId";
|
||||
|
||||
/**
|
||||
* Key of session variable to store user email addresses.
|
||||
*/
|
||||
private static final String EMAIL_KEY = "emailAddress";
|
||||
|
||||
/**
|
||||
* Creates a new CredentialsManager for the given HTTP request.
|
||||
*
|
||||
* @param request Request in which session credentials are stored.
|
||||
* @param clientSecretsStream Stream of client_secrets.json.
|
||||
* @throws InvalidClientSecretsException
|
||||
*/
|
||||
public CredentialMediator(HttpServletRequest request,InputStream clientSecretsStream, Collection<String> scopes)throws InvalidClientSecretsException, IOException
|
||||
{
|
||||
this.request = request;
|
||||
this.scopes = scopes;
|
||||
DataStoreFactory dataStoreFactory = new AppEngineDataStoreFactory();
|
||||
credentialsStore = StoredCredential.getDefaultDataStore(dataStoreFactory);
|
||||
try
|
||||
{
|
||||
secrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(clientSecretsStream));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new InvalidClientSecretsException("client_secrets.json is missing or invalid.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Client information parsed from client_secrets.json.
|
||||
*/
|
||||
protected GoogleClientSecrets getClientSecrets()
|
||||
{
|
||||
return secrets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an empty GoogleCredential, configured with appropriate
|
||||
* HttpTransport, JsonFactory, and client information.
|
||||
*/
|
||||
private Credential buildEmptyCredential()
|
||||
{
|
||||
return new GoogleCredential.Builder()
|
||||
.setClientSecrets(this.secrets)
|
||||
.setTransport(TRANSPORT)
|
||||
.setJsonFactory(JSON_FACTORY)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves stored credentials for the provided email address.
|
||||
*
|
||||
* @param userId User's Google ID.
|
||||
* @return Stored GoogleCredential if found, {@code null} otherwise.
|
||||
*/
|
||||
private StoredCredential getStoredCredential(String userId)throws IOException
|
||||
{
|
||||
if(credentialsStore.containsKey(userId))
|
||||
{
|
||||
return credentialsStore.get(userId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes stored credentials for the provided email address.
|
||||
*
|
||||
* @param userId User's Google ID.
|
||||
*/
|
||||
private void deleteStoredCredential(String userId)throws IOException
|
||||
{
|
||||
if(userId != null)
|
||||
{
|
||||
credentialsStore.delete(userId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exchange an authorization code for a credential.
|
||||
*
|
||||
* @param authorizationCode Authorization code to exchange for OAuth 2.0
|
||||
* credentials.
|
||||
* @return Credential representing the upgraded authorizationCode.
|
||||
* @throws CodeExchangeException An error occurred.
|
||||
*/
|
||||
private Credential exchangeCode(String authorizationCode)throws CodeExchangeException
|
||||
{
|
||||
// Talk to Google and upgrade the given authorization code to an access
|
||||
// token and hopefully a refresh token.
|
||||
try
|
||||
{
|
||||
GoogleTokenResponse response =
|
||||
new GoogleAuthorizationCodeTokenRequest(
|
||||
TRANSPORT,
|
||||
JSON_FACTORY,
|
||||
secrets.getWeb().getClientId(),
|
||||
secrets.getWeb().getClientSecret(),
|
||||
authorizationCode,
|
||||
secrets.getWeb().getRedirectUris().get(0)).execute();
|
||||
|
||||
return buildEmptyCredential().setFromTokenResponse(response);
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new CodeExchangeException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a request to the UserInfo API to retrieve user e-mail address
|
||||
* associated with the given credential.
|
||||
*
|
||||
* @param credential Credential to authorize the request.
|
||||
* @return User's e-mail address.
|
||||
* @throws NoUserIdException An error occurred, and the retrieved email
|
||||
* address was null.
|
||||
*/
|
||||
private Userinfoplus getUserInfo(Credential credential)throws NoUserIdException
|
||||
{
|
||||
Userinfoplus userInfo = null;
|
||||
|
||||
// Create a user info service, and make a request to get the user's info.
|
||||
Oauth2 userInfoService = new Oauth2.Builder(TRANSPORT, JSON_FACTORY, credential).build();
|
||||
try
|
||||
{
|
||||
userInfo = userInfoService.userinfo().get().execute();
|
||||
if(userInfo == null)
|
||||
{
|
||||
throw new NoUserIdException();
|
||||
}
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the authorization URL to authorize the user with the given
|
||||
* email address.
|
||||
*
|
||||
* @param emailAddress User's e-mail address.
|
||||
* @return Authorization URL to redirect the user to.
|
||||
*/
|
||||
private String getAuthorizationUrl(String emailAddress)
|
||||
{
|
||||
// Generate an authorization URL based on our client settings,
|
||||
// the user's email address, and the state parameter, if present.
|
||||
GoogleAuthorizationCodeRequestUrl urlBuilder =
|
||||
new GoogleAuthorizationCodeRequestUrl(
|
||||
secrets.getWeb().getClientId(),
|
||||
secrets.getWeb().getRedirectUris().get(0),
|
||||
scopes)
|
||||
.setAccessType("offline")
|
||||
.setApprovalPrompt("force");
|
||||
// Propagate through the current state parameter, so that when the
|
||||
// user gets redirected back to our app, they see the file(s) they
|
||||
// were originally supposed to see before we realized we weren't
|
||||
// authorized.
|
||||
if(request.getParameter("state") != null)
|
||||
{
|
||||
urlBuilder.set("state", request.getParameter("state"));
|
||||
}
|
||||
if(emailAddress != null)
|
||||
{
|
||||
urlBuilder.set("user_id", emailAddress);
|
||||
}
|
||||
return urlBuilder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the credential of the active session.
|
||||
*/
|
||||
public void deleteActiveCredential()throws IOException
|
||||
{
|
||||
String userId = (String) request.getSession().getAttribute(USER_ID_KEY);
|
||||
this.deleteStoredCredential(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve credentials using the provided authorization code.
|
||||
*
|
||||
* This function exchanges the authorization code for an access token and
|
||||
* queries the UserInfo API to retrieve the user's e-mail address. If a
|
||||
* refresh token has been retrieved along with an access token, it is stored
|
||||
* in the application database using the user's e-mail address as key. If no
|
||||
* refresh token has been retrieved, the function checks in the application
|
||||
* database for one and returns it if found or throws a
|
||||
* NoRefreshTokenException with the authorization URL to redirect the user
|
||||
* to.
|
||||
*
|
||||
* @return Credential containing an access and refresh token.
|
||||
* @throws NoRefreshTokenException No refresh token could be retrieved from
|
||||
* the available sources.
|
||||
*/
|
||||
public Credential getActiveCredential()throws NoRefreshTokenException,IOException
|
||||
{
|
||||
String userId = (String) request.getSession().getAttribute(USER_ID_KEY);
|
||||
System.out.println("Session="+request.getSession().getId()+" : isCookie="+request.isRequestedSessionIdFromCookie()+" : isURL="+request.isRequestedSessionIdFromURL()+" :isNew="+request.getSession().isNew());
|
||||
System.out.println("UserID="+userId);
|
||||
StoredCredential strdCredentials = null;
|
||||
Credential credentials = null;
|
||||
try
|
||||
{
|
||||
// Only bother looking for a Credential if the user has an existing
|
||||
// session with their email address stored.
|
||||
if(userId != null)
|
||||
{
|
||||
strdCredentials = this.getStoredCredential(userId);
|
||||
credentials = buildEmptyCredential().setAccessToken(strdCredentials.getAccessToken());
|
||||
if(strdCredentials.getRefreshToken() != null)
|
||||
credentials = credentials.setRefreshToken(strdCredentials.getRefreshToken());
|
||||
credentials = credentials.setExpirationTimeMilliseconds(strdCredentials.getExpirationTimeMilliseconds());
|
||||
System.out.println("Storedcrdentials="+((credentials!=null)?credentials.getAccessToken():credentials));
|
||||
}
|
||||
// No Credential was stored for the current user or no refresh token is
|
||||
// available.
|
||||
// If an authorizationCode is present, upgrade it into an
|
||||
// access token and hopefully a refresh token.
|
||||
if((strdCredentials == null || strdCredentials.getRefreshToken() == null) && (request.getParameter("code") != null))
|
||||
{
|
||||
credentials = exchangeCode(request.getParameter("code"));
|
||||
System.out.println("crdentials="+((credentials!=null)?credentials.getAccessToken():credentials));
|
||||
strdCredentials = new StoredCredential(credentials);
|
||||
if(credentials != null)
|
||||
{
|
||||
Userinfoplus userInfo = getUserInfo(credentials);
|
||||
userId = userInfo.getId();
|
||||
request.getSession().setAttribute(USER_ID_KEY, userId);
|
||||
request.getSession().setAttribute(EMAIL_KEY, userInfo.getEmail());
|
||||
// Sometimes we won't get a refresh token after upgrading a code.
|
||||
// This won't work for our app, because the user can land directly
|
||||
// at our app without first visiting Google Drive. Therefore,
|
||||
// only bother to store the Credential if it has a refresh token.
|
||||
// If it doesn't, we'll get one below.
|
||||
if(strdCredentials.getRefreshToken() != null)
|
||||
{
|
||||
credentialsStore.set(userId, strdCredentials);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(strdCredentials == null || strdCredentials.getRefreshToken() == null)
|
||||
{
|
||||
// No refresh token has been retrieved.
|
||||
// Start a "fresh" OAuth 2.0 flow so that we can get a refresh token.
|
||||
String email = (String) request.getSession().getAttribute(EMAIL_KEY);
|
||||
String authorizationUrl = getAuthorizationUrl(email);
|
||||
throw new NoRefreshTokenException(authorizationUrl);
|
||||
}
|
||||
}
|
||||
catch(CodeExchangeException e)
|
||||
{
|
||||
// The code the user arrived here with was bad. This pretty much never
|
||||
// happens. In a production application, we'd either redirect the user
|
||||
// somewhere like a home page, or show them a vague error mentioning
|
||||
// that they probably didn't arrive to our app from Google Drive.
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(NoUserIdException e)
|
||||
{
|
||||
// This is bad because it means the user either denied us access
|
||||
// to their email address, or we couldn't fetch it for some reason.
|
||||
// This is unrecoverable. In a production application, we'd show the
|
||||
// user a message saying that we need access to their email address
|
||||
// to work.
|
||||
e.printStackTrace();
|
||||
}
|
||||
return credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when no refresh token has been found.
|
||||
*/
|
||||
public static class NoRefreshTokenException extends Exception
|
||||
{
|
||||
|
||||
/**
|
||||
* Authorization URL to which to redirect the user.
|
||||
*/
|
||||
private String authorizationUrl;
|
||||
|
||||
/**
|
||||
* Construct a NoRefreshTokenException.
|
||||
*
|
||||
* @param authorizationUrl The authorization URL to redirect the user to.
|
||||
*/
|
||||
public NoRefreshTokenException(String authorizationUrl)
|
||||
{
|
||||
this.authorizationUrl = authorizationUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Authorization URL to which to redirect the user.
|
||||
*/
|
||||
public String getAuthorizationUrl()
|
||||
{
|
||||
return authorizationUrl;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when client_secrets.json is missing or invalid.
|
||||
*/
|
||||
public static class InvalidClientSecretsException extends Exception
|
||||
{
|
||||
/**
|
||||
* Construct an InvalidClientSecretsException with a message.
|
||||
*
|
||||
* @param message Message to escalate.
|
||||
*/
|
||||
public InvalidClientSecretsException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when no email address could be retrieved.
|
||||
*/
|
||||
private static class NoUserIdException extends Exception{}
|
||||
|
||||
/**
|
||||
* Exception thrown when a code exchange has failed.
|
||||
*/
|
||||
private static class CodeExchangeException extends Exception {}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.urrsm.sng.udiary;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.http.util.ByteArrayBuffer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
*/
|
||||
public class DataURIFactory
|
||||
{
|
||||
private final int SIZE_LIMIT = 0xe1000;
|
||||
|
||||
public String convertToDataURL(URL url) throws ConnectionFailedException,UnAcceptableFileTypeException,UnAcceptableFileSizeException,IOException
|
||||
{
|
||||
//Open The connection to the URL provided.
|
||||
URLConnection conn = null;
|
||||
try
|
||||
{
|
||||
conn = url.openConnection();
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
throw new ConnectionFailedException("There was problem while opening connection to the URL.");
|
||||
}
|
||||
//Solving Appengine problems with URLConnection
|
||||
conn.setReadTimeout(60000);//I don't what value to set yet.
|
||||
conn.setConnectTimeout(60000);
|
||||
//Filter the content type to 'image' only.
|
||||
String contType = conn.getContentType();
|
||||
if(!contType.startsWith("image")) throw new UnAcceptableFileTypeException("URL:"+url+";\nContent-Type:"+contType+";\nThe requested URL is not of an Image file.");
|
||||
//Filter the file size length.
|
||||
int length = conn.getContentLength();
|
||||
if( length==-1 || length > SIZE_LIMIT) throw new UnAcceptableFileSizeException("URL:"+url+";\nContent-Type:"+contType+";\nContent-Size"+length+"bytes;\nDue to limitations with the server, only file of "+SIZE_LIMIT+"bytes and less are allowed.");
|
||||
//Start downloading the file in a buffer(in RAM).
|
||||
BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
|
||||
ByteArrayBuffer baf = new ByteArrayBuffer(500);//Taking initial buffer capacity as 500 bytes.
|
||||
int data = -1;//initial data as -1 not as 0 because while reading data(bytes) from a stream -1 means empty or no more data.
|
||||
while((data = bis.read()) != -1) baf.append((byte)data);
|
||||
String encoded = Base64.encodeBase64String(baf.toByteArray());
|
||||
baf = null;//Now making baf=null, a trick to clear it's allocations in RAM.
|
||||
return "data:"+contType+";base64,"+encoded;
|
||||
}
|
||||
|
||||
public class ConnectionFailedException extends Exception
|
||||
{
|
||||
public ConnectionFailedException(String msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
public class UnAcceptableFileTypeException extends Exception
|
||||
{
|
||||
public UnAcceptableFileTypeException(String msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
public class UnAcceptableFileSizeException extends Exception
|
||||
{
|
||||
public UnAcceptableFileSizeException(String msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package com.urrsm.sng.udiary;
|
||||
|
||||
|
||||
import com.urrsm.sng.udiary.DataURIFactory.ConnectionFailedException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
*/
|
||||
public class DataURLServlet extends HttpServlet
|
||||
{
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
String url = request.getParameterValues("url")[0];
|
||||
response.setContentType("text/plain");
|
||||
PrintWriter out = response.getWriter();
|
||||
try
|
||||
{
|
||||
String dataurl = new DataURIFactory().convertToDataURL(new URL(url));
|
||||
out.println(dataurl);
|
||||
dataurl=null;//trick to clear RAM.
|
||||
}
|
||||
catch(ConnectionFailedException | DataURIFactory.UnAcceptableFileSizeException | DataURIFactory.UnAcceptableFileTypeException | IOException ex)
|
||||
{
|
||||
response.sendError(500, ex+"\n"+ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* 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 {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "This servlet downloads and converts images to their DataURI\n"
|
||||
+ "which can be further utilised by any other web app or client side scripts\n"
|
||||
+ "such as JavaScript which faces many troubles for getting datauris of images of out domains.\n"
|
||||
+ "Usage: Ask me a request (GET/POST) through\n"
|
||||
+ "\thttp://udatauri.appspot.com/getdatauri?url=<URL of any image here.>\n"
|
||||
+ "The URL should not be from a local domain(ex: localhost,192...,...) the URL.\n"
|
||||
+ "The URL should be accessible from anywhere.\n"
|
||||
+ "Don't forget to follow all rules of assigning values to parameters in a URL.(Ex: %26 for '&',%20 for ' ',...\n"
|
||||
+ "There is a limit to the file size of the images (i.e 900KB) because of limitations\n"
|
||||
+ "of appengine resources for free qota.";
|
||||
}// </editor-fold>
|
||||
}
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
package com.urrsm.sng.udiary;
|
||||
|
||||
import com.google.api.client.auth.oauth2.Credential;
|
||||
import com.google.api.services.drive.Drive;
|
||||
import com.google.api.services.drive.model.File;
|
||||
import com.google.api.services.drive.model.FileList;
|
||||
import com.urrsm.sng.udiary.model.UDiary;
|
||||
import com.urrsm.sng.util.ResumableUpload;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringReader;
|
||||
import java.util.Collections;
|
||||
import java.util.Scanner;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArrayBuilder;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonObjectBuilder;
|
||||
import javax.json.JsonReader;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
*/
|
||||
public class DriveServlet extends HttpServlet
|
||||
{
|
||||
private final String HOME_FOLDER = "UDiary";
|
||||
public File homeDir;
|
||||
public File confFile;
|
||||
/**
|
||||
* Processes requests for both HTTP
|
||||
* <code>GET</code> and
|
||||
* <code>POST</code> methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
String reqparam = null;
|
||||
InputStream stream = request.getInputStream();
|
||||
Scanner s = new Scanner(stream, "UTF-8").useDelimiter("\\A");
|
||||
reqparam = s.hasNext() ? s.next() : "";
|
||||
|
||||
response.setContentType("application/json");
|
||||
|
||||
PrintWriter out = response.getWriter();
|
||||
Drive drive = ServletToolkit.getDriveService(request, response);
|
||||
if(drive==null)return;
|
||||
homeDir = getHomeDir(request, response, drive);
|
||||
|
||||
JsonReader read = Json.createReader(new StringReader(reqparam));
|
||||
|
||||
JsonObject reqjson = read.readObject();
|
||||
|
||||
String cmd = reqjson.getString("cmd");
|
||||
|
||||
if(cmd.contains("listdiaries"))
|
||||
{
|
||||
JsonArrayBuilder jsonab = Json.createArrayBuilder();
|
||||
|
||||
FileList filelist = ListDiaries(drive);
|
||||
|
||||
out.println("{'diaries':['Diary']}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private File getHomeDir(HttpServletRequest request, HttpServletResponse response, Drive drive)throws IOException
|
||||
{
|
||||
FileList files = drive.files().list()
|
||||
.setQ("name = '"+HOME_FOLDER+"' and mimeType = 'application/vnd.google-apps.folder' and 'root' in parents")
|
||||
.execute();
|
||||
if(files.getFiles().isEmpty())return createHome(request, response, drive);
|
||||
for(File file:files.getFiles())
|
||||
{
|
||||
System.out.println("[DRIVE:LIST] Listsing home dir:\n"+file.getName()+"\t"+file.getId());
|
||||
FileList childs = drive.files().list()
|
||||
.setQ("name = 'udiary-main.json' and '"+file.getId()+"' in parents")
|
||||
.execute();
|
||||
if(childs.getFiles().isEmpty())return createHome(request, response, drive);
|
||||
confFile = childs.getFiles().get(0);
|
||||
return file;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private File createHome(HttpServletRequest request, HttpServletResponse response, Drive drive)throws IOException
|
||||
{
|
||||
String id = drive.files().get("root").setFields("id").execute().getId();
|
||||
File homedata = new File();
|
||||
homedata.setName(HOME_FOLDER);
|
||||
homedata.setParents(Collections.singletonList(id));
|
||||
homedata.setMimeType("application/vnd.google-apps.folder");
|
||||
File home = drive.files().create(homedata).setFields("id").execute();
|
||||
|
||||
String udiaryjsonbody = new UDiary().createJson();
|
||||
File udiaryjson = new File();
|
||||
udiaryjson.setName("udiary-main.json");
|
||||
udiaryjson.setSize((long)udiaryjsonbody.length());
|
||||
udiaryjson.setMimeType("text/json");
|
||||
udiaryjson.setParents(Collections.singletonList(home.getId()));
|
||||
|
||||
ResumableUpload rsm = new ResumableUpload();
|
||||
Credential credential = ServletToolkit.getCredential(request, response);
|
||||
String conf[] = rsm.requestUploadUrl(request, response, drive, credential, udiaryjson);
|
||||
|
||||
if(conf[0] != null)
|
||||
{
|
||||
try {
|
||||
rsm.uploadString(request, response, conf[0], credential, udiaryjson, udiaryjsonbody);
|
||||
this.confFile = drive.files().get(conf[1]).execute();
|
||||
} catch (ResumableUpload.UploadFileException ex) {
|
||||
Logger.getLogger(DriveServlet.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("[DRIVE:CREATED] "+home.getName()+"\t"+home.getId());
|
||||
|
||||
return home;
|
||||
}
|
||||
|
||||
// List diaries
|
||||
private FileList ListDiaries(Drive drive) throws IOException
|
||||
{
|
||||
FileList filelist = drive.files().list().setQ("'"+homeDir.getId()+"' in parents and mimeType = 'application/vnd.google-apps.folder'").execute();
|
||||
|
||||
return filelist;
|
||||
}
|
||||
|
||||
// Diary Config
|
||||
private JsonObject getConfig(Drive drive, File diary) throws IOException
|
||||
{
|
||||
FileList files = drive.files().list().setQ("name = 'config.cfg' and '"+diary.getId()+"' in parents").execute();
|
||||
|
||||
if(!files.getFiles().isEmpty())
|
||||
{
|
||||
File diaryconf = files.getFiles().get(0);
|
||||
|
||||
InputStream in = drive.files().export(diaryconf.getId(), diaryconf.getMimeType()).executeMediaAsInputStream();
|
||||
|
||||
Scanner s = new Scanner(in);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while(s.hasNext())
|
||||
{
|
||||
sb.append(s.nextLine());
|
||||
}
|
||||
System.out.println(sb.toString());
|
||||
//return read.readObject();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* 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 {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.urrsm.sng.udiary;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
*/
|
||||
public class LogoutServlet extends HttpServlet
|
||||
{
|
||||
@Override
|
||||
public void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException
|
||||
{
|
||||
HttpSession session = req.getSession(false);
|
||||
if(session!=null)
|
||||
{
|
||||
session.invalidate();
|
||||
}
|
||||
req.getSession();
|
||||
resp.sendRedirect("/");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
package com.urrsm.sng.udiary;
|
||||
|
||||
import com.google.api.client.auth.oauth2.Credential;
|
||||
import com.google.api.client.http.HttpTransport;
|
||||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
import com.google.api.services.drive.Drive;
|
||||
import com.google.api.services.oauth2.Oauth2;
|
||||
import com.google.api.services.oauth2.model.Userinfoplus;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
*/
|
||||
public class ServletToolkit
|
||||
{
|
||||
private static final Collection<String> SCOPE = Arrays.asList(
|
||||
"https://www.googleapis.com/auth/drive",
|
||||
"https://www.googleapis.com/auth/userinfo.email",
|
||||
"https://www.googleapis.com/auth/userinfo.profile");//DriveScopes.DRIVE);
|
||||
private static final String CLIENT_SECRETS_FILE_PATH = "/WEB-INF/classes/client_id.json";
|
||||
private static final HttpTransport TRANSPORT = new NetHttpTransport();
|
||||
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
|
||||
|
||||
private static CredentialMediator getCredentialMediator(HttpServletRequest request, HttpServletResponse response, String redirectURL)
|
||||
{
|
||||
CredentialMediator credentialMediator = null;
|
||||
try
|
||||
{
|
||||
credentialMediator = new CredentialMediator(request, request.getSession().getServletContext().getResourceAsStream(CLIENT_SECRETS_FILE_PATH), SCOPE);
|
||||
credentialMediator.getActiveCredential();
|
||||
}
|
||||
catch (CredentialMediator.NoRefreshTokenException ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(redirectURL==null)response.sendRedirect(response.encodeURL(ex.getAuthorizationUrl()));
|
||||
else response.sendRedirect(redirectURL);
|
||||
return null;
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
ioe.printStackTrace();
|
||||
sendError(response,500,"Failed to redirect for authorization.");
|
||||
throw new RuntimeException("Failed to redirect for authorization.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
credentialMediator = null;
|
||||
}
|
||||
}
|
||||
catch (CredentialMediator.InvalidClientSecretsException ex)
|
||||
{
|
||||
String message = String.format("This application is not properly configured: %s", ex.getMessage());
|
||||
sendError(response, 500, message);
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
String message = String.format("Error while loading the Credentials: %s", ex.getMessage());
|
||||
sendError(response, 500, message);
|
||||
credentialMediator = null;
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
return credentialMediator;
|
||||
}
|
||||
|
||||
public static Credential getCredential(HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
CredentialMediator mediator = getCredentialMediator(request, response,null);
|
||||
if(mediator != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return mediator.getActiveCredential();
|
||||
}
|
||||
catch (CredentialMediator.NoRefreshTokenException ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
response.sendRedirect(response.encodeURL(ex.getAuthorizationUrl()));
|
||||
return null;
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
ioe.printStackTrace();
|
||||
throw new RuntimeException("Failed to redirect for authorization.");
|
||||
}
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
String message = String.format("Error while loading the Credentials: %s", ioe.getMessage());
|
||||
sendError(response, 500, message);
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getClientId(HttpServletRequest request, HttpServletResponse response, String redirectURL)
|
||||
{
|
||||
CredentialMediator cm = getCredentialMediator(request ,response,redirectURL);
|
||||
if(cm != null)return cm.getClientSecrets().getWeb().getClientId();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Oauth2 getOauth2Service(HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
Credential credential = getCredential(request, response);
|
||||
if(credential!=null)return new Oauth2.Builder(TRANSPORT, JSON_FACTORY, credential)
|
||||
.setApplicationName("UDiary").build();// Remind to change this
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Drive getDriveService(HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
Credential credential = getCredential(request, response);
|
||||
if(credential!=null)return new Drive.Builder(TRANSPORT, JSON_FACTORY, getCredential(request, response))
|
||||
.setApplicationName("UDiary").build();//Remind to change this.
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Userinfoplus getUserInfo(HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
Userinfoplus userInfo = null;
|
||||
Oauth2 userInfoService = getOauth2Service(request,response);
|
||||
if(userInfoService==null)return null;
|
||||
try
|
||||
{
|
||||
userInfo = userInfoService.userinfo().get().execute();
|
||||
if(userInfo == null)
|
||||
{
|
||||
throw new RuntimeException("UserInfo is Null");
|
||||
}
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public static void sendError(HttpServletResponse resp, int code, String message)
|
||||
{
|
||||
try {
|
||||
resp.sendError(code, message);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,195 @@
|
|||
package com.urrsm.sng.udiary;
|
||||
|
||||
import com.google.api.client.auth.oauth2.Credential;
|
||||
import com.google.api.client.http.HttpTransport;
|
||||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.client.json.jackson2.JacksonFactory;
|
||||
import com.google.api.services.drive.Drive;
|
||||
import com.google.api.services.oauth2.Oauth2;
|
||||
import com.google.api.services.oauth2.model.Userinfoplus;
|
||||
import com.urrsm.sng.udiary.CredentialMediator.InvalidClientSecretsException;
|
||||
import com.urrsm.sng.udiary.CredentialMediator.NoRefreshTokenException;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
*/
|
||||
public class SkeletonServlet extends HttpServlet
|
||||
{
|
||||
|
||||
private final Collection<String> SCOPE = Arrays.asList(
|
||||
"https://www.googleapis.com/auth/drive",
|
||||
"https://www.googleapis.com/auth/userinfo.email",
|
||||
"https://www.googleapis.com/auth/userinfo.profile");//DriveScopes.DRIVE);
|
||||
private final String CLIENT_SECRETS_FILE_PATH = "/WEB-INF/classes/client_id.json";
|
||||
private static final HttpTransport TRANSPORT = new NetHttpTransport();
|
||||
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
|
||||
|
||||
@Override
|
||||
public void init() throws ServletException
|
||||
{
|
||||
}
|
||||
|
||||
protected void sendError(HttpServletResponse resp, int code, String message)
|
||||
{
|
||||
try {
|
||||
resp.sendError(code, message);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
}
|
||||
|
||||
private CredentialMediator getCredentialMediator(HttpServletRequest request, HttpServletResponse response, String redirectURL)
|
||||
{
|
||||
CredentialMediator credentialMediator = null;
|
||||
try
|
||||
{
|
||||
credentialMediator = new CredentialMediator(request, request.getSession().getServletContext().getResourceAsStream(CLIENT_SECRETS_FILE_PATH), SCOPE);
|
||||
credentialMediator.getActiveCredential();
|
||||
}
|
||||
catch (NoRefreshTokenException ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(redirectURL==null)response.sendRedirect(response.encodeURL(ex.getAuthorizationUrl()));
|
||||
else response.sendRedirect(redirectURL);
|
||||
return null;
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
ioe.printStackTrace();
|
||||
sendError(response,500,"Failed to redirect for authorization.");
|
||||
throw new RuntimeException("Failed to redirect for authorization.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
credentialMediator = null;
|
||||
}
|
||||
}
|
||||
catch (InvalidClientSecretsException ex)
|
||||
{
|
||||
String message = String.format("This application is not properly configured: %s", ex.getMessage());
|
||||
sendError(response, 500, message);
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
String message = String.format("Error while loading the Credentials: %s", ex.getMessage());
|
||||
sendError(response, 500, message);
|
||||
credentialMediator = null;
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
return credentialMediator;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
protected Credential getCredential(HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
CredentialMediator mediator = getCredentialMediator(request, response,null);
|
||||
if(mediator != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return mediator.getActiveCredential();
|
||||
}
|
||||
catch (NoRefreshTokenException ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
response.sendRedirect(response.encodeURL(ex.getAuthorizationUrl()));
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
ioe.printStackTrace();
|
||||
throw new RuntimeException("Failed to redirect for authorization.");
|
||||
}
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
String message = String.format("Error while loading the Credentials: %s", ioe.getMessage());
|
||||
sendError(response, 500, message);
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
protected Oauth2 getOauth2Service(HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
Credential credential = getCredential(request, response);
|
||||
if(credential!=null)return new Oauth2.Builder(TRANSPORT, JSON_FACTORY, credential).build();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
protected Drive getDriveService(HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
Credential credential = getCredential(request, response);
|
||||
if(credential!=null)return new Drive.Builder(TRANSPORT, JSON_FACTORY, getCredential(request, response)).build();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
protected Userinfoplus getUserInfo(HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
Userinfoplus userInfo = null;
|
||||
Oauth2 userInfoService = getOauth2Service(request,response);
|
||||
if(userInfoService==null)return null;
|
||||
try
|
||||
{
|
||||
userInfo = userInfoService.userinfo().get().execute();
|
||||
if(userInfo == null)
|
||||
{
|
||||
throw new RuntimeException("UserInfo is Null");
|
||||
}
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param redirectURL
|
||||
* @return
|
||||
*/
|
||||
protected String getClientId(HttpServletRequest request, HttpServletResponse response, String redirectURL)
|
||||
{
|
||||
CredentialMediator cm = getCredentialMediator(request ,response,redirectURL);
|
||||
if(cm != null)return cm.getClientSecrets().getWeb().getClientId();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.urrsm.sng.udiary;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
*/
|
||||
public class StartServlet extends SkeletonServlet
|
||||
{
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
//Overriding JSSESIONID and changing cookie expire time to 10days.
|
||||
Cookie cookie = new Cookie("JSESSIONID", request.getSession().getId());
|
||||
cookie.setMaxAge(0xd2f00);
|
||||
response.addCookie(cookie);
|
||||
//Check if the request is for sign in
|
||||
String reqStr = request.getParameter("sign");
|
||||
String clientID = null;
|
||||
if(reqStr!=null)
|
||||
clientID = this.getClientId(request, response, null);//then go for signin
|
||||
else
|
||||
clientID = this.getClientId(request, response, "/index.jsp");//else go to index.jsp
|
||||
if(clientID==null) return;//If clientID is null, it means no credentials. So, redirect to OAuth or index.jsp without further executing.
|
||||
//Now, if you have correct credentials(i.e you had signin successfully so you need to go to shelf.jsp
|
||||
//So, Set the attributes of the session here.
|
||||
|
||||
//[START Attributes]
|
||||
request.setAttribute("clientID", clientID);
|
||||
//[END Attributes]
|
||||
|
||||
//Now, redirecting user to shelf.jsp preserving the attributes of session
|
||||
request.getRequestDispatcher("/shelf.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "This Servlet decides and redirects the client to the start page.";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.urrsm.sng.udiary;
|
||||
|
||||
|
||||
import com.google.api.client.json.Json;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Scanner;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author piyush
|
||||
*/
|
||||
public class ThemeServlet extends HttpServlet {
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
String reqparam = null;
|
||||
InputStream stream = request.getInputStream();
|
||||
Scanner s = new Scanner(stream, "UTF-8").useDelimiter("\\A");
|
||||
reqparam = s.hasNext() ? s.next() : "";
|
||||
|
||||
PrintWriter out = response.getWriter();
|
||||
|
||||
}
|
||||
|
||||
public String getThemes()
|
||||
{
|
||||
//Ur
|
||||
return null;
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* 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 {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
package com.urrsm.sng.udiary.model;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
*/
|
||||
public class DiaryConfig
|
||||
{
|
||||
private String name;
|
||||
private String date;
|
||||
private String datePublicKey;
|
||||
private String dateSignature;
|
||||
private String comment;
|
||||
private String theme;
|
||||
private ArrayList<String> pages;
|
||||
|
||||
public DiaryConfig(String name, String date, String datePublicKey, String dateSignature, String comment, String theme, ArrayList<String> pages)
|
||||
{
|
||||
this.name = name;
|
||||
this.date = date;
|
||||
this.datePublicKey = datePublicKey;
|
||||
this.dateSignature = dateSignature;
|
||||
this.comment = comment;
|
||||
this.theme = theme;
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDate()
|
||||
{
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public String getDatePublicKey()
|
||||
{
|
||||
return this.datePublicKey;
|
||||
}
|
||||
|
||||
public String getDateSignature()
|
||||
{
|
||||
return this.dateSignature;
|
||||
}
|
||||
|
||||
public String getComment()
|
||||
{
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public String getTheme()
|
||||
{
|
||||
return this.theme;
|
||||
}
|
||||
|
||||
public ArrayList<String> getpages()
|
||||
{
|
||||
return this.pages;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDate(String date)
|
||||
{
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public void setDatePublicKey(String datePublicKey)
|
||||
{
|
||||
this.datePublicKey = datePublicKey;
|
||||
}
|
||||
|
||||
public void setDateSignature(String dateSignature)
|
||||
{
|
||||
this.dateSignature = dateSignature;
|
||||
}
|
||||
|
||||
public void setComment(String comment)
|
||||
{
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public void setTheme(String theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public void setpages(ArrayList<String> pages)
|
||||
{
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public String createJson()
|
||||
{
|
||||
return(new Gson().toJson(this));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.urrsm.sng.udiary.model;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
*/
|
||||
public class UDiary
|
||||
{
|
||||
public UDiary()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public String createJson()
|
||||
{
|
||||
return(new Gson().toJson(this));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
package com.urrsm.sng.util;
|
||||
|
||||
import com.google.api.client.auth.oauth2.Credential;
|
||||
import com.google.api.services.drive.Drive;
|
||||
import com.google.api.services.drive.model.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPatch;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author piyush
|
||||
*/
|
||||
public class ResumableUpload
|
||||
{
|
||||
public static final int CHUNK_LIMIT = 262144; // = (256*1024)
|
||||
|
||||
public static final int OK = 200;
|
||||
public static final int CREATED = 201;
|
||||
public static final int INCOMPLETE = 308;
|
||||
|
||||
public File file = null;
|
||||
|
||||
/**
|
||||
* This function returns url to which file is to be uploaded
|
||||
* @param request HttpServletRequest
|
||||
* @param response HttpServletResponse
|
||||
* @param credential google credential for AccessToken
|
||||
* @param jsonStructure It will be used to get structure of file it should contain
|
||||
* 1) MimeType of file
|
||||
* 2) Size of file
|
||||
* 3) Name of file
|
||||
* @return {SessionUri, fileid}
|
||||
* @throws MalformedURLException
|
||||
* @throws IOException
|
||||
*/
|
||||
public String[] requestUploadUrl(HttpServletRequest request, HttpServletResponse response, Drive drive, Credential credential, File jsonStructure) throws MalformedURLException, IOException
|
||||
{
|
||||
long size = jsonStructure.getSize();
|
||||
jsonStructure.setSize(null);
|
||||
File tmpfile = drive.files().create(jsonStructure).execute();
|
||||
jsonStructure.setSize(size);
|
||||
jsonStructure.setId(tmpfile.getId());
|
||||
return new String[]{
|
||||
this.requestUpdateUrl(request, response, credential, jsonStructure),
|
||||
jsonStructure.getId()};
|
||||
}
|
||||
|
||||
public String requestUpdateUrl(HttpServletRequest request, HttpServletResponse response, Credential credential, com.google.api.services.drive.model.File jsonStructure) throws MalformedURLException, IOException
|
||||
{
|
||||
HttpClient resp = HttpClients.custom().build();
|
||||
HttpPatch patch = new org.apache.http.client.methods.HttpPatch("https://www.googleapis.com/upload/drive/v3/files/"+jsonStructure.getId()+"?uploadType=resumable");
|
||||
|
||||
patch.setHeader("Authorization", "Bearer " + credential.getAccessToken());
|
||||
patch.setHeader("X-Upload-Content-Type", jsonStructure.getMimeType());
|
||||
patch.setHeader("X-Upload-Content-Length", String.valueOf(jsonStructure.getSize()));
|
||||
patch.setHeader("Content-Type", "application/json; charset=UTF-8");
|
||||
|
||||
StringEntity params =new StringEntity("{"
|
||||
+ "'name':'"+jsonStructure.getName()+"'"
|
||||
+ "}");
|
||||
|
||||
patch.setEntity(params);
|
||||
|
||||
HttpResponse exe = resp.execute(patch);
|
||||
|
||||
String sessionUri = null;
|
||||
|
||||
if (exe.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK) {
|
||||
sessionUri = exe.getFirstHeader("location").toString();
|
||||
}
|
||||
|
||||
return sessionUri.split(" ")[1];
|
||||
}
|
||||
|
||||
public File getFile()
|
||||
{
|
||||
return this.file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads String packet
|
||||
* @param request HttpServletRequest
|
||||
* @param response HttpServletResponse
|
||||
* @param sessionUri Last Session Url
|
||||
* @param jsonStructure It will be used to get structure of file it should contain
|
||||
* 1) MimeType of file
|
||||
* 2) Size of file
|
||||
* 3) Name of file
|
||||
* @param packet Text to upload
|
||||
* @param chunkStart offset of start of chunk
|
||||
* @param uploadBytes length of packet must be greater than CHUNK_LIMIT except last packet
|
||||
* @return Response Code
|
||||
* @throws MalformedURLException
|
||||
* @throws IOException
|
||||
*/
|
||||
public int uploadStringPacket(HttpServletRequest request, HttpServletResponse response, String sessionUri, com.google.api.services.drive.model.File jsonStructure, String packet, long chunkStart, long uploadBytes) throws MalformedURLException, IOException
|
||||
{
|
||||
URL url1 = new URL(sessionUri);
|
||||
HttpURLConnection req1 = (HttpURLConnection) url1.openConnection();
|
||||
|
||||
req1.setRequestMethod("PUT");
|
||||
req1.setDoOutput(true);
|
||||
req1.setDoInput(true);
|
||||
req1.setConnectTimeout(10000);
|
||||
|
||||
req1.setRequestProperty("Content-Type", jsonStructure.getMimeType());
|
||||
req1.setRequestProperty("Content-Length", String.valueOf(uploadBytes));
|
||||
req1.setRequestProperty("Content-Range", "bytes " + chunkStart + "-" + (chunkStart + uploadBytes -1) + "/" + jsonStructure.getSize());
|
||||
|
||||
byte[] buffer = packet.substring((int)chunkStart, (int)(chunkStart + uploadBytes)).getBytes();
|
||||
|
||||
OutputStream outputStream1 = req1.getOutputStream();
|
||||
outputStream1.write(buffer);
|
||||
outputStream1.close();
|
||||
|
||||
req1.connect();
|
||||
|
||||
return req1.getResponseCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload java.io.File packet
|
||||
* @param request HttpServletRequest
|
||||
* @param response HttpServletResponse
|
||||
* @param sessionUri Last Session Url
|
||||
* @param jsonStructure It will be used to get structure of file it should contain
|
||||
* 1) MimeType of file
|
||||
* 2) Size of file
|
||||
* 3) Name of file
|
||||
* @param file File to upload
|
||||
* @param chunkStart offset of start of chunk
|
||||
* @param uploadBytes length of packet must be greater than CHUNK_LIMIT except last packet
|
||||
* @return Response Code
|
||||
* @throws MalformedURLException
|
||||
* @throws IOException
|
||||
*/
|
||||
public int uploadFilePacket(HttpServletRequest request, HttpServletResponse response, String sessionUri, com.google.api.services.drive.model.File jsonStructure, java.io.File file, long chunkStart, long uploadBytes) throws MalformedURLException, IOException
|
||||
{
|
||||
URL url1 = new URL(sessionUri);
|
||||
HttpURLConnection req1 = (HttpURLConnection) url1.openConnection();
|
||||
|
||||
req1.setRequestMethod("PUT");
|
||||
req1.setDoOutput(true);
|
||||
req1.setDoInput(true);
|
||||
req1.setConnectTimeout(10000);
|
||||
|
||||
req1.setRequestProperty("Content-Type", jsonStructure.getMimeType());
|
||||
req1.setRequestProperty("Content-Length", String.valueOf(uploadBytes));
|
||||
req1.setRequestProperty("Content-Range", "bytes " + chunkStart + "-" + (chunkStart + uploadBytes -1) + "/" + jsonStructure.getSize());
|
||||
|
||||
OutputStream outstream = req1.getOutputStream();
|
||||
|
||||
byte[] buffer = new byte[(int) uploadBytes];
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
fileInputStream.getChannel().position(chunkStart);
|
||||
if (fileInputStream.read(buffer, 0, (int) uploadBytes) == -1);
|
||||
fileInputStream.close();
|
||||
|
||||
outstream.write(buffer);
|
||||
outstream.close();
|
||||
|
||||
req1.connect();
|
||||
|
||||
return req1.getResponseCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload File
|
||||
* Upload java.io.File packet
|
||||
* @param request HttpServletRequest
|
||||
* @param response HttpServletResponse
|
||||
* @param credential google credential for AccessToken
|
||||
* @param jsonStructure It will be used to get structure of file it should contain
|
||||
* 1) MimeType of file
|
||||
* 2) Size of file
|
||||
* 3) Name of file
|
||||
* @param file File to upload
|
||||
* @throws IOException
|
||||
*/
|
||||
public void uploadFile(HttpServletRequest request, HttpServletResponse response, Drive drive, Credential credential, com.google.api.services.drive.model.File jsonStructure, java.io.File file) throws IOException, UploadFileException
|
||||
{
|
||||
String sessionUrl = requestUploadUrl(request, response, drive, credential, jsonStructure)[0];
|
||||
|
||||
for(long i = 1, j = CHUNK_LIMIT;i <= jsonStructure.getSize(); i+= CHUNK_LIMIT)
|
||||
{
|
||||
if(i+CHUNK_LIMIT >= jsonStructure.getSize())
|
||||
{
|
||||
j = jsonStructure.getSize() - i + 1;
|
||||
}
|
||||
int responseCode = uploadFilePacket(request, response, sessionUrl, jsonStructure, file, i-1, j);
|
||||
if(!(responseCode == OK || responseCode == CREATED || responseCode == INCOMPLETE)) throw new UploadFileException(responseCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Upload String
|
||||
* @param request HttpServletRequest
|
||||
* @param response HttpServletResponse
|
||||
* @param credential google credential for AccessToken
|
||||
* @param jsonStructure It will be used to get structure of file it should contain
|
||||
* 1) MimeType of file
|
||||
* 2) Size of file
|
||||
* 3) Name of file
|
||||
* @param text Text to upload
|
||||
* @throws IOException
|
||||
*/
|
||||
public void uploadString(HttpServletRequest request, HttpServletResponse response, String sessionUrl, Credential credential, com.google.api.services.drive.model.File jsonStructure, String text) throws IOException, UploadFileException
|
||||
{
|
||||
for(long i = 1, j = CHUNK_LIMIT;i <= jsonStructure.getSize();i += CHUNK_LIMIT)
|
||||
{
|
||||
if(i+CHUNK_LIMIT >= jsonStructure.getSize())
|
||||
{
|
||||
j = jsonStructure.getSize() - i + 1;
|
||||
}
|
||||
int responseCode = uploadStringPacket(request, response, sessionUrl, jsonStructure, text, i-1, j);
|
||||
if(!(responseCode == OK || responseCode == CREATED || responseCode == INCOMPLETE)) throw new UploadFileException(responseCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when there is a problem while uploading file
|
||||
*/
|
||||
public class UploadFileException extends Exception
|
||||
{
|
||||
public UploadFileException()
|
||||
{
|
||||
super("Unable to upload file!");
|
||||
}
|
||||
|
||||
public UploadFileException(int responsecode)
|
||||
{
|
||||
super("Unable to upload file! ResponseCode: "+responsecode);
|
||||
}
|
||||
|
||||
public UploadFileException(String msg, int responsecode)
|
||||
{
|
||||
super(msg+responsecode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"web":{"client_id":"","project_id":"","auth_uri":"","token_uri":"","auth_provider_x509_cert_url":"","client_secret":"","redirect_uris":[""]}}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Page Not Found</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
|
||||
* {
|
||||
line-height: 1.2;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
html {
|
||||
color: #888;
|
||||
display: table;
|
||||
font-family: sans-serif;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
margin: 2em auto;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #555;
|
||||
font-size: 2em;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 auto;
|
||||
width: 280px;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 280px) {
|
||||
|
||||
body, p {
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.5em;
|
||||
margin: 0 0 0.3em;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Page Not Found</h1>
|
||||
<p>Sorry, but the page you were trying to view does not exist.</p>
|
||||
</body>
|
||||
</html>
|
||||
<!-- IE needs 512+ bytes: http://blogs.msdn.com/b/ieinternals/archive/2010/08/19/http-error-pages-in-internet-explorer.aspx -->
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Context path="/udiary"/>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
|
||||
<application>udiary-urrsmsng</application>
|
||||
<version>${appengine.app.version}</version>
|
||||
<threadsafe>true</threadsafe>
|
||||
<sessions-enabled>true</sessions-enabled>
|
||||
|
||||
<system-properties>
|
||||
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
|
||||
</system-properties>
|
||||
</appengine-web-app>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
# A default java.util.logging configuration.
|
||||
# (All App Engine logging is through java.util.logging by default).
|
||||
#
|
||||
# To use this configuration, copy it into your application's WEB-INF
|
||||
# folder and add the following to your appengine-web.xml:
|
||||
#
|
||||
# <system-properties>
|
||||
# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
|
||||
# </system-properties>
|
||||
#
|
||||
|
||||
# Set the default logging level for all loggers to WARNING
|
||||
.level = WARNING
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app version="2.5" 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_2_5.xsd">
|
||||
<!-- [START Welcome file] -->
|
||||
<servlet>
|
||||
<servlet-name>ThemeServlet</servlet-name>
|
||||
<servlet-class>com.urrsm.sng.udiary.ThemeServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>DriveServlet</servlet-name>
|
||||
<url-pattern>/drive</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>ThemeServlet</servlet-name>
|
||||
<url-pattern>/theme</url-pattern>
|
||||
</servlet-mapping>
|
||||
<welcome-file-list>
|
||||
<welcome-file>start</welcome-file>
|
||||
</welcome-file-list>
|
||||
<!-- [END Welcome file] -->
|
||||
<!-- [START standard_mappings] -->
|
||||
<servlet>
|
||||
<servlet-name>Start</servlet-name>
|
||||
<servlet-class>com.urrsm.sng.udiary.StartServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>DriveServlet</servlet-name>
|
||||
<servlet-class>com.urrsm.sng.udiary.DriveServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>DataURLServlet</servlet-name>
|
||||
<servlet-class>com.urrsm.sng.udiary.DataURLServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>Start</servlet-name>
|
||||
<url-pattern>/start</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet>
|
||||
<servlet-name>Logout</servlet-name>
|
||||
<servlet-class>com.urrsm.sng.udiary.LogoutServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>Logout</servlet-name>
|
||||
<url-pattern>/logout</url-pattern>
|
||||
</servlet-mapping>
|
||||
<!-- [END standard_mappings] -->
|
||||
<jsp-config>
|
||||
<jsp-property-group>
|
||||
<url-pattern>*.jsp</url-pattern>
|
||||
<trim-directive-whitespaces>true</trim-directive-whitespaces>
|
||||
</jsp-property-group>
|
||||
</jsp-config>
|
||||
</web-app>
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
<%-- Now, this is netbean's enemy. --%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
|
||||
<!doctype html>
|
||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
|
||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
|
||||
<!--[if IE 8]> <html class="no-js lt-ie9" lang=""> <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang=""> <!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>UDiary</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<style>
|
||||
body {
|
||||
padding-top: 50px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="js/vendor/modernizr-2.8.3-respond-1.4.2.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class=" navbar navbar-fixed-top deft-navbar">
|
||||
<div class=" container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"><img src="img/menu.png"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span>
|
||||
<a class=" navbar-brand" href="#"><nobr><img width="40px" height="29px" src="img/icon.png">UDiary</nobr></a>
|
||||
<sup><i class="coats ">Storing Great Ideas!</i></sup>
|
||||
</span>
|
||||
</div>
|
||||
<div id="navbar" class="navbar-collapse collapse navbar-right">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a class="label" href="/">Home</a></li>
|
||||
<li><a class="label" href="/contact.jsp">Contact Us</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Main jumbotron for a primary marketing message or call to action -->
|
||||
<div class="jumbotron">
|
||||
<h2 align="center" class=" heading2">About Us</h2>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-10">
|
||||
<img align="right" src="img/icon.png" width="280" height="203" alt="icon"/>
|
||||
<h3>What is UDiary?</h3>
|
||||
<p>UDiary is a project launched by <a href="http://urrsmsng.blogspot.com">urrsm.sng</a> where people can create notes, ideas, daily diaries, etc in an attractive way online. It stores all your diary/notes' data on your google drive and it is safe to use as it converts your notes to secret code to protect the data. It's online text editor(modified nicedit) is very lightweight and interactive. It also supports mini drawing tools with smiley insertions. Therefore, it is a better place to be creative, to store your daily and too keep memories.</p>
|
||||
<br>
|
||||
<h3>What is <a href="http://urrsmsng.blogspot.com">urrsm.sng</a>?</h3>
|
||||
<img src="img/Symboll.png" width="114" height="104" alt="Symboll"/>
|
||||
<p><a href="http://urrsmsng.blogspot.com">urrsm.sng</a> is an emerging software developers' company in India.</p>
|
||||
<br><br>
|
||||
<h3>Message from Aurthor</h3>
|
||||
<div style="float: right; border: #000 dashed 1px; box-shadow: 1px 1px 2px; border-radius: 5px;"><img src="img/Piyush.png" width="200" height="178" alt="Piyush" style="border-radius: 5px; "/><div align="center">Piyush Raj Mishra</div></div>
|
||||
<nobr>Hi everyone,</nobr><br>
|
||||
<p>At first I would like to thank you for visiting our site and using this online diary (if you haven't yet, give it a try you'll love it). I would like to thank my parents, brother who hung lamp for me on my whole journey, friends and colleagues who gave me ideas , my well prayers and everyone who uses UDiary.</p>
|
||||
<p>I would like to specially like to thank <a href="http://nicedit.com/">nicedit</a>'s developers for their such a nice and lightweight html editor, without which this development would not be possible. And <a href="http://www.slax.org">slax</a>'s developer for such a good & light but complete linux distro, which helped me do all perfectly(without any hangs/freezes while I was running all heavy) in limited space and RAM. At last I'd like to thank all the developers who's javascript/CSS libraries I have used. </p>
|
||||
<p>UDiary is just an idea of storing diaries & notes online to reduce use of paper, make it accessible from and device(phone, PDA, tab, pc). I think using UDiary will reduce the use of paper & cost of diaries and will change the life style of people. </p>
|
||||
<br>
|
||||
<h3>Support us by donating</h3>
|
||||
<p>We are preparing to improve UDiary. Since google app engine require some amount of money to provide webspace and other features, therefore we need some donations. Please support our work by donating <img style="resize: none; width: 20px; height: 20px; background-image: url(emoji/e1.png); background-repeat: no-repeat; display:inline-block; background-position: -60px -260px;" draggable="false">.</p>
|
||||
<div class="btn" style="background-color: yellow; width:150px; height:40px; border: #000 solid 1px;">Bit Coin</div>
|
||||
<div class="btn" style="background-color: white; width:150px; height:40px; border: #000 solid 1px;">PayPal</div>
|
||||
<div class="btn" style="background-color: lightskyblue; width:150px; height:40px; border: #000 solid 1px;">Paytm</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<footer>
|
||||
<center>
|
||||
<p style=" width: 300px; border: #f0ad4e thin dashed;">Created by <a href="http://urrsmsng.blogspot.com/">urrsm.sng</a></p>
|
||||
</center>
|
||||
</footer>
|
||||
<!-- /container -->
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js"></script>
|
||||
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.2.js"><\/script>')</script>
|
||||
|
||||
<script src="js/vendor/bootstrap.min.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
|
||||
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
|
||||
<script>
|
||||
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
|
||||
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
|
||||
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
|
||||
e.src='//www.google-analytics.com/analytics.js';
|
||||
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
|
||||
ga('create','UA-XXXXX-X','auto');ga('send','pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 27 KiB |
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Please read: http://msdn.microsoft.com/en-us/library/ie/dn455106.aspx -->
|
||||
<browserconfig>
|
||||
<msapplication>
|
||||
<tile>
|
||||
<square70x70logo src="tile.png"/>
|
||||
<square150x150logo src="tile.png"/>
|
||||
<wide310x150logo src="tile-wide.png"/>
|
||||
<square310x310logo src="tile.png"/>
|
||||
</tile>
|
||||
</msapplication>
|
||||
</browserconfig>
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
<%-- Now, this is netbean's enemy. --%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
|
||||
<!doctype html>
|
||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
|
||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
|
||||
<!--[if IE 8]> <html class="no-js lt-ie9" lang=""> <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang=""> <!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>UDiary</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<!-- Stylesheet Start -->
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<style>
|
||||
body {
|
||||
padding-top: 50px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<!-- Stylesheet End -->
|
||||
|
||||
<script src="js/vendor/modernizr-2.8.3-respond-1.4.2.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class=" navbar navbar-fixed-top deft-navbar">
|
||||
<div class=" container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"><img src="img/menu.png"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span>
|
||||
<a class=" navbar-brand" href="#"><nobr><img width="40px" height="29px" src="img/icon.png">UDiary</nobr></a>
|
||||
<sup><i class="coats ">Storing Great Ideas!</i></sup>
|
||||
</span>
|
||||
</div>
|
||||
<div id="navbar" class="navbar-collapse collapse navbar-right">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a class="label" href="/">Home</a></li>
|
||||
<li><a class="label" href="/about.jsp">About Us</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Main jumbotron for a primary marketing message or call to action -->
|
||||
<div class="jumbotron">
|
||||
<h2 align="center" class=" heading2">Contact Us</h2>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-10">
|
||||
<h3>Feedback:</h3>
|
||||
<form>
|
||||
<h4 style="float: left; padding-right: 40px; " data-toggle="tooltip" title="Required">Name <sup style="color:red">*</sup></h4>
|
||||
<input style="width: 300px;" class="form-control" data-toggle="tooltip" title="Required" required><br>
|
||||
<h4 style="float: left; padding-right: 44px; " data-toggle="tooltip" title="Required">Email <sup style="color:red">*</sup></h4>
|
||||
<input type="email" style="width: 300px;" class="form-control" data-toggle="tooltip" title="Required" required><br>
|
||||
<h4 style="float: left; padding-right: 24px; ">Feedback</h4>
|
||||
<textarea style="width: 500px; height: 300px;" class="form-control"></textarea><br>
|
||||
<input type="submit" class="btn btn-success" value="Submit"><br>
|
||||
</form>
|
||||
<hr>
|
||||
<h3>Contacts:</h3>
|
||||
<span><b>email : </b><i><a href="mailto:piyush.raj.kit@gmail.com?Subject=Feedback" target="_top">piyush.raj.kit@gmail.com</a></i></span><br>
|
||||
<span><b>site : </b><i><a href="http://urrsmsng.blogspot.com">urrsmsng.blogspot.com</a></i></span><br>
|
||||
<span><b>facebook : </b><i><a href="https://facebook.com/urrsm.sng/">facebook.com/urrsm.sng</a></i></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<footer>
|
||||
<center>
|
||||
<p style=" width: 300px; border: #f0ad4e thin dashed;">Created by <a href="http://urrsmsng.blogspot.com/">urrsm.sng</a></p>
|
||||
</center>
|
||||
</footer>
|
||||
<!-- /container --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js"></script>
|
||||
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.2.js"><\/script>')</script>
|
||||
|
||||
<script src="js/vendor/bootstrap.min.js"></script>
|
||||
|
||||
<script src="js/main.js"></script>
|
||||
|
||||
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
|
||||
<script>
|
||||
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
|
||||
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
|
||||
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
|
||||
e.src='//www.google-analytics.com/analytics.js';
|
||||
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
|
||||
ga('create','UA-XXXXX-X','auto');ga('send','pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
|
||||
<cross-domain-policy>
|
||||
<!-- Read this: www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html -->
|
||||
|
||||
<!-- Most restrictive policy: -->
|
||||
<site-control permitted-cross-domain-policies="none"/>
|
||||
|
||||
<!-- Least restrictive policy: -->
|
||||
<!--
|
||||
<site-control permitted-cross-domain-policies="all"/>
|
||||
<allow-access-from domain="*" to-ports="*" secure="false"/>
|
||||
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
|
||||
-->
|
||||
</cross-domain-policy>
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
|
||||
|
||||
@media screen and (max-width: 880px ) and (min-width: 840px){
|
||||
|
||||
.workspacebase{
|
||||
padding-top: 85px;
|
||||
}
|
||||
.sidenav{
|
||||
padding-top: 118px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 840px ) and (min-width: 459px){
|
||||
.workspacebase{
|
||||
padding-top: 105px;
|
||||
}
|
||||
.sidenav{
|
||||
padding-top: 140px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 459px ) and (min-width: 290px){
|
||||
.workspacebase{
|
||||
padding-top: 125px;
|
||||
}
|
||||
.sidenav{
|
||||
padding-top: 162px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 290px ) and (min-width: 0px){
|
||||
.actionbar{
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.workspacebase{
|
||||
padding-top: 135px;
|
||||
}
|
||||
.sidenav{
|
||||
padding-top: 172px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 290px ) and (min-width: 287px){
|
||||
.actionbar{
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.workspacebase{
|
||||
padding-top: 135px;
|
||||
}
|
||||
.sidenav{
|
||||
padding-top: 172px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 287px ) and (min-width: 260px){
|
||||
.actionbar{
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.workspacebase{
|
||||
padding-top: 157px;
|
||||
}
|
||||
.sidenav{
|
||||
padding-top: 194px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 260px ) and (min-width: 243px){
|
||||
.actionbar{
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.workspacebase{
|
||||
padding-top: 167px;
|
||||
}
|
||||
.sidenav{
|
||||
padding-top: 204px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 243px ) and (min-width: 0px){
|
||||
.actionbar{
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.workspacebase{
|
||||
padding-top: 189px;
|
||||
}
|
||||
.sidenav{
|
||||
padding-top: 224px;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
@font-face {
|
||||
font-family: 'arial';
|
||||
src: url('../fonts/arial.ttf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'comic sans ms';
|
||||
src: url('../fonts/comic sans.ttf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'courier new';
|
||||
src: url('../fonts/Courier New.ttf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'georgia';
|
||||
src: url('../fonts/Georgia.ttf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'helvetica';
|
||||
src: url('../fonts/helvetica.ttf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'impact';
|
||||
src: url('../fonts/impact.ttf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'helvetica';
|
||||
src: url('../fonts/helvetica.ttf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'times new roman';
|
||||
src: url('../fonts/times-new-roman.ttf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'trebuchet ms';
|
||||
src: url('../fonts/Trebuchet MS.ttf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'verdana';
|
||||
src: url('../fonts/Verdana.ttf');
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
/* ==========================================================================
|
||||
Author's custom styles
|
||||
========================================================================== */
|
||||
|
||||
.deft-navbar{
|
||||
z-index: 3;
|
||||
background-color: #039974;
|
||||
box-shadow: 1px 1px 2px;
|
||||
}
|
||||
|
||||
.navbar-brand{
|
||||
color: white;
|
||||
}
|
||||
|
||||
.navbar-brand:hover{
|
||||
color: #2aabd2;
|
||||
}
|
||||
|
||||
.navbar-menu{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.coats{
|
||||
color: greenyellow;
|
||||
font-style: oblique;
|
||||
}
|
||||
|
||||
.heading2{
|
||||
color: #039974;
|
||||
text-shadow: 1px 1px;
|
||||
}
|
||||
.heading1{
|
||||
color: #039974;
|
||||
}
|
||||
|
||||
.bottom-navbar{
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.jumboHome {
|
||||
background: #F7EFC2; /* For browsers that do not support gradients */
|
||||
background: -webkit-linear-gradient(#F7EFC2, #F4F0DC); /* For Safari 5.1 to 6.0 */
|
||||
background: -o-linear-gradient(#F7EFC2, #F4F0DC); /* For Opera 11.1 to 12.0 */
|
||||
background: -moz-linear-gradient(#F7EFC2, #F4F0DC); /* For Firefox 3.6 to 15 */
|
||||
background: linear-gradient(#F7EFC2, #F4F0DC); /* Standard syntax (must be last) */
|
||||
}
|
||||
|
||||
.actionbar{
|
||||
width: 100%;
|
||||
position: fixed;
|
||||
z-index: 2;
|
||||
background-color: #cccc00;
|
||||
overflow: hidden;
|
||||
appearance: menubar;
|
||||
box-shadow: 1px 1px 2px;
|
||||
}
|
||||
|
||||
.sidenav{
|
||||
height: 100%;
|
||||
width: 200px;
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: #ffffcc;
|
||||
display: none;
|
||||
padding-top: 85px;
|
||||
}
|
||||
|
||||
.sideNavMenu{
|
||||
display: block;
|
||||
overflow: auto;
|
||||
height: calc(100% - 100px);
|
||||
}
|
||||
|
||||
.sideNavMenu a{
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
color: #039974;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
.sideNavMenu div{
|
||||
padding: 10px 0px 10px 30px;
|
||||
}
|
||||
|
||||
.sideNavMenu a:hover div{
|
||||
color: #006600;
|
||||
background-color: #99ccff;
|
||||
}
|
||||
|
||||
.sideNavCover{
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
background-color: #7fc6ff;
|
||||
background-size: 100% 100px;
|
||||
border-bottom-style: dashed;
|
||||
}
|
||||
|
||||
.displayPic{
|
||||
margin-top: 5px;
|
||||
margin-left: 5px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border: #039974 dashed 3px;
|
||||
border-radius: 100px;
|
||||
}
|
||||
|
||||
.sidenavbarName{
|
||||
padding-left: 10px;
|
||||
font-size: 12px;
|
||||
color: white;
|
||||
border-width: 5px;
|
||||
text-shadow: 1px 1px 2px;
|
||||
}
|
||||
|
||||
.sidenavbarEmail{
|
||||
padding-left: 10px;
|
||||
font-size: 12px;
|
||||
color: white;
|
||||
border-width: 5px;
|
||||
text-shadow: 1px 1px 2px;
|
||||
}
|
||||
|
||||
.workspacebase{
|
||||
width: 760px;
|
||||
text-align: left;
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
.diary-canvas{
|
||||
border: dotted 1px;
|
||||
width: 600px;
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
.diary-thumbnail{
|
||||
width: 150px;
|
||||
height: 200px;
|
||||
border: whitesmoke solid 2px;
|
||||
box-shadow: #000 2px 2px 5px;
|
||||
border-radius: 10px;
|
||||
margin: 30px;
|
||||
}
|
||||
|
||||
.wordwrap {
|
||||
white-space: pre-wrap; /* CSS3 */
|
||||
white-space: -moz-pre-wrap; /* Firefox */
|
||||
white-space: -pre-wrap; /* Opera <7 */
|
||||
white-space: -o-pre-wrap; /* Opera 7 */
|
||||
word-wrap: break-word; /* IE */
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
<!doctype html>
|
||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
|
||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
|
||||
<!--[if IE 8]> <html class="no-js lt-ie9" lang=""> <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang=""> <!--<![endif]-->
|
||||
<head>
|
||||
<!-- Start:HeaderDeclarations -->
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>UDiary</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<!-- Stylesheets Start -->
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
|
||||
<link rel="stylesheet" href="emoji/emoji.css">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link rel="stylesheet" href="css/diaryResponsive.css">
|
||||
<!-- Stylesheets End -->
|
||||
<style>
|
||||
body {
|
||||
padding-top: 50px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="js/vendor/modernizr-2.8.3-respond-1.4.2.min.js"></script>
|
||||
<!-- End:HeaderDeclarations -->
|
||||
</head>
|
||||
<body>
|
||||
<!-- Start:1st Navigation Bar(Title Bar) -->
|
||||
<nav class=" navbar navbar-fixed-top deft-navbar">
|
||||
<div class=" container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"><img src="img/menu.png"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<nobr>
|
||||
<a class=" navbar-brand" href="#"><nobr><img width="40px" height="29px" src="img/icon.png">UDiary</nobr></a>
|
||||
<sup><i class="coats ">Storing Great Ideas!</i></sup>
|
||||
</nobr>
|
||||
</div>
|
||||
<div id="navbar" class="navbar-collapse collapse navbar-right">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a class="label" href="#">Home</a></li>
|
||||
<li><a class="label" href="#">Contact Us</a></li>
|
||||
<li><a class="label" href="#">About Us</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<!-- End:Navigation Bar -->
|
||||
|
||||
<!-- Start:Action Bar -->
|
||||
<nav id="toolbar" class="actionbar">
|
||||
<button type="button" style=" float: left; border: none; background: transparent; padding-top:5px;" onclick="sideNavbarAction();">
|
||||
<span class="icon-bar"><img src="img/menu.png" width="30" height="30" alt="menu"/></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<DIV id="panel" style="float: left; padding-top: 8px;"></DIV>
|
||||
</nav>
|
||||
<!-- End:Action Bar -->
|
||||
|
||||
<!-- Start:Side NavigationBar -->
|
||||
<div id="sidenavbar" class="sidenav">
|
||||
<form style=" width: 100%; height: 100%;">
|
||||
<div class="sideNavCover" style="background-image: url('');">
|
||||
<img src="" class="displayPic" /><br>
|
||||
<strong id="sidenavbarName" class="sidenavbarName">Name</strong><br>
|
||||
<p id="sidenavbarEmail" class="sidenavbarEmail">login@email.com</p>
|
||||
</div>
|
||||
<br>
|
||||
<a href="#">Shelf</a>
|
||||
<a href="#">Log Out</a>
|
||||
</form>
|
||||
</div>
|
||||
<!-- End:Side Navigation Bar -->
|
||||
|
||||
<!-- Start:Working area-->
|
||||
<center>
|
||||
<div class="workspacebase">
|
||||
<div style="padding-left: 0px;">
|
||||
<div style="width: 0px; height: 0px; background-image: url('img/smiley.png');"></div>
|
||||
</div>
|
||||
<div style="width: 0px; height: 0px; background-image: url(''); float: left;"></div>
|
||||
<div style="float: left;">
|
||||
<img id="workImage" src="file.jpg" width="700" height="500" alt="test" style="position: absolute;"/>
|
||||
<canvas id="canvasArea" width="700" height="500" style="position: absolute;">Your browser dosen't support canvas yet!</canvas>
|
||||
<div id="workText" style="padding-left: 55px; position: relative;"><textarea id="textarea" style="width: 645px; height: 492px; background: transparent;"></textarea></div>
|
||||
</div>
|
||||
<div style="width: 0px; height: 0px; background-image: url(''); float: left;"></div>
|
||||
<div style=" padding-top: 0px; padding-left: 0px;">
|
||||
<div style="width: 0px; height: 0px; background-image: url('img/smiley.png');"></div>
|
||||
</div>
|
||||
</div>
|
||||
</center>
|
||||
<!-- End:Working Canvas -->
|
||||
|
||||
<!-- Start:Navigation Panel--->
|
||||
<nav id="navpanel" style=" background-color: #269abc; border-radius: 10px 10px 0px 0px; box-shadow: 1px 1px 2px; width: 200px; z-index: 2;" class="navbar navbar-fixed-bottom center-block">
|
||||
|
||||
</nav>
|
||||
<!-- End:Navigation Panel--->
|
||||
|
||||
<!-- Start:container -->
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js"></script>
|
||||
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.2.js"><\/script>');</script>
|
||||
|
||||
<script src="js/vendor/bootstrap.min.js"></script>
|
||||
|
||||
<script src="js/libs/nicEdit/nicEdit.js"></script>
|
||||
|
||||
<script src="js/main.js"></script>
|
||||
|
||||
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
|
||||
<script>
|
||||
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
|
||||
function(){(b[l].q=b[l].q||[]).push(arguments);});b[l].l=+new Date;
|
||||
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
|
||||
e.src='//www.google-analytics.com/analytics.js';
|
||||
r.parentNode.insertBefore(e,r);}(window,document,'script','ga'));
|
||||
ga('create','UA-XXXXX-X','auto');ga('send','pageview');
|
||||
</script>
|
||||
<!-- End:container -->
|
||||
|
||||
<link rel="stylesheet" href="css/fonts.css">
|
||||
</body>
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 195 KiB |
|
After Width: | Height: | Size: 58 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 124 KiB |
|
After Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 753 KiB |
|
|
@ -0,0 +1,15 @@
|
|||
# humanstxt.org/
|
||||
# The humans responsible & technology colophon
|
||||
|
||||
# TEAM
|
||||
|
||||
<name> -- <role> -- <twitter>
|
||||
|
||||
# THANKS
|
||||
|
||||
<name>
|
||||
|
||||
# TECHNOLOGY COLOPHON
|
||||
|
||||
HTML5, CSS3
|
||||
jQuery, Modernizr
|
||||
|
After Width: | Height: | Size: 134 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 637 B |
|
After Width: | Height: | Size: 890 B |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 895 B |
|
After Width: | Height: | Size: 899 B |
|
After Width: | Height: | Size: 209 B |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
|
@ -0,0 +1,114 @@
|
|||
<%-- Now, this is netbean's enemy. --%>
|
||||
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
|
||||
<!doctype html>
|
||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
|
||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
|
||||
<!--[if IE 8]> <html class="no-js lt-ie9" lang=""> <![endif]-->
|
||||
<!--[if gt IE 8]><!-->
|
||||
<html class="no-js" lang=""> <!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>UDiary</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
|
||||
<!-- StyleSheets Start -->
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<!-- Styesheets End -->
|
||||
<style>
|
||||
body {
|
||||
padding-top: 50px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<script src="js/vendor/modernizr-2.8.3-respond-1.4.2.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav class=" navbar navbar-fixed-top deft-navbar">
|
||||
<div class=" container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"><img src="img/menu.png"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span>
|
||||
<a class=" navbar-brand" href="#"><nobr><img width="40px" height="29px" src="img/icon.png">UDiary</nobr></a>
|
||||
<sup><i class="coats ">Storing Great Ideas!</i></sup>
|
||||
</span>
|
||||
</div>
|
||||
<div id="navbar" class="navbar-collapse collapse navbar-right">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a class="label" href="/start">Home</a></li>
|
||||
<li><a class="label" href="/contact.jsp">Contact Us</a></li>
|
||||
<li><a class="label" href="/about.jsp">About Us</a></li>
|
||||
<li><a id ="account" class="label" href="/?sign">Sign In</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<!-- Main jumbotron for a primary marketing message or call to action -->
|
||||
<div class="jumbotron jumboHome">
|
||||
<img src="img/icon.png" class="img-rounded" align="right">
|
||||
<div class="container">
|
||||
<h1 style="text-shadow: #444 0 1px 1px; color: #009999;">UDiary</h1>
|
||||
<p>What an Idea sir!!!. <br>
|
||||
Are you roaming in market, on street or sitting in garden? And suddenly an idea hits your mind? Where to write it? Udiary is the best place to write your ideas. </p>
|
||||
<p><a style="background: #66ae29" class="btn btn-primary btn-lg" href="/about.jsp" role="button">Know More »</a>
|
||||
<a style="background: #28a4c9" class="btn btn-primary btn-lg" href="/?sign" role="button">Sign In »</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<h3 class="heading2">Fast & Easy</h3>
|
||||
<p>It is fast & easy with format editor to store ideas decoratively.</p>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<h3 class="heading2">No fear of data loss!</h3>
|
||||
<p>When you save all your data on cloud, it prevents the chance of data loss by any damage to you PDA!</p>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<h3 class="heading2">Safe</h3>
|
||||
<p>All the notes are saved on your drive in the form of secret codes which prevents third party to steal your ideas.</p>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<h3 class="heading2">Paint tools</h3>
|
||||
<p>You can draw images in your diary with paint tools.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<footer>
|
||||
<center>
|
||||
<p style=" width: 300px; border: #f0ad4e thin dashed;">Created by <a href="http://urrsmsng.blogspot.com/">urrsm.sng</a></p>
|
||||
</center>
|
||||
</footer>
|
||||
|
||||
<!-- /container -->
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js"></script>
|
||||
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.2.js"><\/script>')</script>
|
||||
<script src="js/vendor/bootstrap.min.js"></script>
|
||||
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
|
||||
<script>
|
||||
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
|
||||
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
|
||||
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
|
||||
e.src='//www.google-analytics.com/analytics.js';
|
||||
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
|
||||
ga('create','UA-XXXXX-X','auto');ga('send','pageview');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
function LoadPage(date, month)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
//addDiaries(10,["template.png","template.png","template.png","template.png","template.png","template.png","template.png","template.png","template.png","template.png",]);
|
||||
|
||||
function addDiaries(num,image)
|
||||
{
|
||||
for(i = 0;i < num;i++)
|
||||
{
|
||||
addDiary(image[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function addDiary(name)
|
||||
{
|
||||
var element = document.createElement("div");
|
||||
element.classList.add('col-md-11');
|
||||
|
||||
var thum = document.createElement("div");
|
||||
thum.classList.add('btn');
|
||||
thum.classList.add('diary-thumbnail');
|
||||
element.appendChild(thum);
|
||||
|
||||
element.appendChild(document.createElement("br"));
|
||||
|
||||
var chk = document.createElement("div");
|
||||
chk.classList.add('btn-group');
|
||||
chk.setAttribute("data-toggle", "buttons");
|
||||
thum.appendChild(chk);
|
||||
|
||||
var lab = document.createElement("label");
|
||||
lab.classList.add('btn');
|
||||
lab.classList.add('btn-default');
|
||||
chk.appendChild(lab);
|
||||
|
||||
var but = document.createElement("input");
|
||||
but.type = "checkbox";
|
||||
but.autocomplete = "off";
|
||||
lab.appendChild(but);
|
||||
|
||||
var lab2 = document.createElement("label");
|
||||
lab2.classList.add('glyphicon');
|
||||
lab2.classList.add('glyphicon-ok');
|
||||
lab.appendChild(lab2);
|
||||
|
||||
var title = document.createElement("label");
|
||||
title.classList.add("label");
|
||||
title.style.fontSize = "20px";
|
||||
title.innerHTML = name;
|
||||
title.style.color = '#fff';
|
||||
element.appendChild(title);
|
||||
|
||||
document.getElementById('dashboard').appendChild(element);
|
||||
}
|
||||
|
||||
function getTheme(count)
|
||||
{
|
||||
console.log("Entered");
|
||||
$.ajax({
|
||||
url: "/theme",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
mimeType: "application/json",
|
||||
data: JSON.stringify({code: "gettheme",last: count}),
|
||||
success: function(data)
|
||||
{
|
||||
console.log("success");
|
||||
console.log(data);
|
||||
},
|
||||
error: function(data)
|
||||
{
|
||||
console.log("error");
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
console.log("Ended");
|
||||
}
|
||||
|
||||
// List diaries with their info
|
||||
$.ajax({
|
||||
url: "/drive",
|
||||
type: "post",
|
||||
dataType : "json",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({cmd: "listdiaries"}),
|
||||
success: function(r){
|
||||
console.log(r.responseText);
|
||||
}
|
||||
,
|
||||
error: function(r){
|
||||
console.log(r);
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1 @@
|
|||
.DS_Store
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
## Bug and Feature Requests
|
||||
|
||||
Please read through the [issues](https://github.com/danishkhan/NicEdit/issues). If you do not see an issue created yet
|
||||
for your bug then [create an issue](https://github.com/danishkhan/NicEdit/issues/new).
|
||||
|
||||
Make sure to outline what the bug is. If you know how to fix the bug yourself please send a
|
||||
[pull request](https://github.com/danishkhan/NicEdit/pulls).
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
NicEdit License
|
||||
|
||||
Copyright (c) 2007-2008 Brian Kirchoff [(http://nicedit.com)](http://nicedit.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
**Not a maintained project**
|
||||
|
||||
Lightweight, Cross Platform WYSIWYG editor.
|
||||
|
||||
Project is a member of the [OSS Manifesto](http://ossmanifesto.org/)
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Demo 1 : Convert All Textareas</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="menu"></div>
|
||||
|
||||
<div id="intro">
|
||||
By calling the nicEditors.allTextareas() function the below example replaces all 3 textareas on the page with nicEditors. NicEditors will match the size of the editor window with the size of the textarea it replaced.
|
||||
</div>
|
||||
<br />
|
||||
|
||||
<div id="sample">
|
||||
<script type="text/javascript" src="../nicEdit.js"></script>
|
||||
<script type="text/javascript">
|
||||
bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
|
||||
</script>
|
||||
|
||||
<h4>First Textarea</h4>
|
||||
<textarea name="area1" cols="40"></textarea>
|
||||
<br />
|
||||
|
||||
<h4>Second Textarea</h4>
|
||||
<textarea name="area2" style="width: 100%;">
|
||||
Some Initial Content was in this textarea
|
||||
</textarea>
|
||||
<br />
|
||||
|
||||
<h4>Third Textarea</h4>
|
||||
<textarea name="area3" style="width: 300px; height: 100px;">
|
||||
HTML <b>content</b> <i>default</i> in textarea
|
||||
</textarea>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Demo 2 : NicEdit Configuration</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="menu"></div>
|
||||
|
||||
<div id="intro">
|
||||
<p>NicEdit is highly configurable by passing the configuration when you create the NicEditor. Pass your configuration when you call:</p>
|
||||
<p>new NicEditor({CONFIG HERE})</p>
|
||||
<p>Add .panelInstance('ID TO TEXTAREA HERE') to add the editor to the textarea.</p>
|
||||
<p>See the examples below:</p>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
<div id="sample">
|
||||
<script src="../nicEdit.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
bkLib.onDomLoaded(function() {
|
||||
new nicEditor().panelInstance('area1');
|
||||
new nicEditor({fullPanel : true}).panelInstance('area2');
|
||||
new nicEditor({iconsPath : '../nicEditorIcons.gif'}).panelInstance('area3');
|
||||
new nicEditor({buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image']}).panelInstance('area4');
|
||||
new nicEditor({maxHeight : 100}).panelInstance('area5');
|
||||
});
|
||||
</script>
|
||||
|
||||
<h4>Default (No Config Specified)</h4>
|
||||
<p>new nicEditor().panelInstance('area1');</p>
|
||||
|
||||
<textarea cols="50" id="area1"></textarea>
|
||||
|
||||
<h4>All Available Buttons {fullPanel : true}</h4>
|
||||
<p>new nicEditor({fullPanel : true}).panelInstance('area2');</p>
|
||||
<textarea cols="60" id="area2">Some Initial Content was in this textarea</textarea>
|
||||
|
||||
<h4>Change Path to Icon File {iconsPath : 'path/to/nicEditorIcons.gif'}</h4>
|
||||
|
||||
<p>new nicEditor({iconsPath : 'nicEditorIcons.gif'}).panelInstance('area3');</p>
|
||||
<textarea cols="50" id="area3"></textarea>
|
||||
|
||||
<h4>Customize the Panel Buttons/Select List</h4>
|
||||
|
||||
<p>{buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript']}</p>
|
||||
<textarea cols="50" id="area4">HTML <b>content</b> <i>default</i> in textarea</textarea>
|
||||
|
||||
<h4>Set a maximum expansion size (maxHeight)</h4>
|
||||
|
||||
<p>{maxHeight : 100}</p>
|
||||
<textarea style="height: 100px;" cols="50" id="area5">HTML <b>content</b> <i>default</i> in textarea</textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Demo 3 : Add/Remove NicEditors</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="menu"></div>
|
||||
|
||||
<div id="intro">
|
||||
<p>The demo below shows toggling the display of NicEditors on both textarea and div elements. NicEdit instances can be added and removed at any time</p>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
<div id="sample">
|
||||
<h4>Div Example</h4>
|
||||
<div id="myArea1" style="width: 300px; height: 100px; border: 1px solid #000;">
|
||||
This is some TEST CONTENT<br />
|
||||
In a DIV Tag<br />
|
||||
Click the Buttons to activate
|
||||
</div>
|
||||
<button onClick="toggleArea1();">Toggle DIV Editor</button>
|
||||
<br /><br />
|
||||
<h4>Textarea Example</h4>
|
||||
<div>
|
||||
<textarea style="width: 300px; height: 100px;" id="myArea2"></textarea>
|
||||
<br />
|
||||
<button onClick="addArea2();">Add Editor to TEXTAREA</button> <button onClick="removeArea2();">Remove Editor from TEXTAREA</button>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
|
||||
<script src="../nicEdit.js" type="text/javascript"></script>
|
||||
<script>
|
||||
var area1, area2;
|
||||
|
||||
function toggleArea1() {
|
||||
if(!area1) {
|
||||
area1 = new nicEditor({fullPanel : true}).panelInstance('myArea1',{hasPanel : true});
|
||||
} else {
|
||||
area1.removeInstance('myArea1');
|
||||
area1 = null;
|
||||
}
|
||||
}
|
||||
|
||||
function addArea2() {
|
||||
area2 = new nicEditor({fullPanel : true}).panelInstance('myArea2');
|
||||
}
|
||||
function removeArea2() {
|
||||
area2.removeInstance('myArea2');
|
||||
}
|
||||
|
||||
bkLib.onDomLoaded(function() { toggleArea1(); });
|
||||
</script>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Demo 4 : Inline NicEditors</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="menu"></div>
|
||||
|
||||
<div id="intro">
|
||||
<p>In addition to replacing textareas NicEdit instances can also replace any element (divs,spans,paragraphs,ect.) with editor instances without effecting the layout of the page. As you will see in other examples content can be saved via AJAX to the server or retrieved from javascript</p>
|
||||
|
||||
<p>To make use of Inline Editing you should first create an empty element as a placeholder for the Editor Panel. In this case I use a div with id="myNicPanel" set. Its usually a good idea to set a width on element but it is not required.</p>
|
||||
</div>
|
||||
|
||||
<div id="sample">
|
||||
|
||||
<script src="../nicEdit.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
bkLib.onDomLoaded(function() {
|
||||
var myNicEditor = new nicEditor();
|
||||
myNicEditor.setPanel('myNicPanel');
|
||||
myNicEditor.addInstance('myInstance1');
|
||||
myNicEditor.addInstance('myInstance2');
|
||||
myNicEditor.addInstance('myInstance3');
|
||||
});
|
||||
</script>
|
||||
|
||||
This is text above the Panel
|
||||
<div id="myNicPanel" style="width: 525px;"></div>
|
||||
This is text below the Panel
|
||||
<br /><br />
|
||||
|
||||
<h4>Inline Div</h4>
|
||||
<div id="myInstance1" style="font-size: 16px; background-color: #ccc; padding: 3px; border: 5px solid #000; width: 400px;">
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed magna dolor, faucibus ac, iaculis non, cursus et, dui. Donec non urna. Aliquam volutpat ornare augue. Phasellus egestas, nisl fermentum porttitor rutrum, magna metus rutrum risus, id fringilla magna mi nec lorem. Etiam eget metus sed justo ultricies rhoncus. Praesent rhoncus arcu non dolor. Proin eu eros. Curabitur vehicula. Nulla vehicula lectus eget eros. Nulla vel nulla at dui dictum mollis. Etiam purus felis, pretium vel, eleifend id, consectetuer nec, purus. Vivamus pretium orci ac sapien. Etiam at tortor. Nunc tincidunt mi sed sapien. Etiam lacus pede, fermentum eu, blandit ac, congue eget, metus. Quisque sed sem. Mauris at sapien. Ut luctus.
|
||||
</div>
|
||||
<br />
|
||||
<h4>Inline Span</h4>
|
||||
<span id="myInstance2" style="display: block;">
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed magna dolor, faucibus ac, iaculis non, cursus et, dui. Donec non urna. Aliquam volutpat ornare augue. Phasellus egestas, nisl fermentum porttitor rutrum, magna metus rutrum risus, id fringilla magna mi nec lorem. Etiam eget metus sed justo ultricies rhoncus. Praesent rhoncus arcu non dolor. Proin eu eros. Curabitur vehicula. Nulla vehicula lectus eget eros. Nulla vel nulla at dui dictum mollis. Etiam purus felis, pretium vel, eleifend id, consectetuer nec, purus. Vivamus pretium orci ac sapien. Etiam at tortor. Nunc tincidunt mi sed sapien. Etiam lacus pede, fermentum eu, blandit ac, congue eget, metus. Quisque sed sem. Mauris at sapien. Ut luctus.
|
||||
</span>
|
||||
<br />
|
||||
<h4>Inline Paragraph</h4>
|
||||
<p id="myInstance3" style="border: 1px solid #000;">This is some text that can be edited in the inline paragraph editor.</p>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Demo 5 : Editor Styles</title>
|
||||
|
||||
<style type="text/css">
|
||||
#myInstance1 {
|
||||
border: 2px dashed #0000ff;
|
||||
}
|
||||
.nicEdit-selected {
|
||||
border: 2px solid #0000ff !important;
|
||||
}
|
||||
|
||||
.nicEdit-panel {
|
||||
background-color: #fff !important;
|
||||
}
|
||||
|
||||
.nicEdit-button {
|
||||
background-color: #fff !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="menu"></div>
|
||||
|
||||
<div id="intro">
|
||||
<p>NicEdit instances and the panel can be styled using CSS classes to fit the look and feel of your site.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="sample">
|
||||
|
||||
<script src="../nicEdit.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
bkLib.onDomLoaded(function() {
|
||||
var myNicEditor = new nicEditor();
|
||||
myNicEditor.setPanel('myNicPanel');
|
||||
myNicEditor.addInstance('myInstance1');
|
||||
});
|
||||
</script>
|
||||
|
||||
This is text above the Panel
|
||||
<div id="myNicPanel" style="width: 350px;"></div>
|
||||
This is text below the Panel
|
||||
<br /><br />
|
||||
|
||||
<h4>Selected Style Example</h4>
|
||||
<div id="myInstance1" style="font-size: 16px; background-color: #ccc; padding: 3px; width: 400px;">
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed magna dolor, faucibus ac, iaculis non, cursus et, dui. Donec non urna. Aliquam volutpat ornare augue. Phasellus egestas, nisl fermentum porttitor rutrum, magna metus rutrum risus, id fringilla magna mi nec lorem. Etiam eget metus sed justo ultricies rhoncus. Praesent rhoncus arcu non dolor. Proin eu eros. Curabitur vehicula. Nulla vehicula lectus eget eros. Nulla vel nulla at dui dictum mollis. Etiam purus felis, pretium vel, eleifend id, consectetuer nec, purus. Vivamus pretium orci ac sapien. Etiam at tortor. Nunc tincidunt mi sed sapien. Etiam lacus pede, fermentum eu, blandit ac, congue eget, metus. Quisque sed sem. Mauris at sapien. Ut luctus.
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 3.6 KiB |
|
|
@ -0,0 +1,8 @@
|
|||
function sideNavbarAction()
|
||||
{
|
||||
if($('#sidenavbar').css('display')==='none'){
|
||||
document.getElementById("sidenavbar").style.display = "block";
|
||||
} else {
|
||||
document.getElementById("sidenavbar").style.display = "none";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
|
||||
require('../../js/transition.js')
|
||||
require('../../js/alert.js')
|
||||
require('../../js/button.js')
|
||||
require('../../js/carousel.js')
|
||||
require('../../js/collapse.js')
|
||||
require('../../js/dropdown.js')
|
||||
require('../../js/modal.js')
|
||||
require('../../js/tooltip.js')
|
||||
require('../../js/popover.js')
|
||||
require('../../js/scrollspy.js')
|
||||
require('../../js/tab.js')
|
||||
require('../../js/affix.js')
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# www.robotstxt.org/
|
||||
|
||||
# Allow crawling of all content
|
||||
User-agent: *
|
||||
Disallow:
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
<%-- Now, this is netbean's enemy. --%>
|
||||
|
||||
<%@ page import="com.google.api.client.http.javanet.NetHttpTransport"%>
|
||||
<%@ page import="com.google.api.client.json.jackson2.JacksonFactory"%>
|
||||
<%@ page import="com.google.api.client.auth.oauth2.Credential" %>
|
||||
<%@ page import="com.google.api.services.oauth2.model.Userinfoplus" %>
|
||||
<%@ page import="com.urrsm.sng.udiary.ServletToolkit" %>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
|
||||
<!doctype html>
|
||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
|
||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
|
||||
<!--[if IE 8]> <html class="no-js lt-ie9" lang=""> <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang=""> <!--<![endif]-->
|
||||
<head>
|
||||
<!-- Start:HeaderDeclarations -->
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>UDiary</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css" media="none" onload="if(media!='all')media='all'">
|
||||
<link rel="stylesheet" href="css/bootstrap-theme.min.css" media="none" onload="if(media!='all')media='all'">
|
||||
<link rel="stylesheet" href="css/main.css" media="none" onload="if(media!='all')media='all'">
|
||||
<style>
|
||||
body {
|
||||
padding-top: 50px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
<script src="js/vendor/modernizr-2.8.3-respond-1.4.2.min.js"></script>
|
||||
<!-- End:HeaderDeclarations -->
|
||||
</head>
|
||||
<body style=" background-image: url('img/1627.jpg');">
|
||||
<%
|
||||
Userinfoplus userinfo = ServletToolkit.getUserInfo(request, response);
|
||||
if(userinfo==null)return;
|
||||
pageContext.setAttribute("userinfo",userinfo);
|
||||
%>
|
||||
<!-- Start:1st Navigation Bar(Title Bar) -->
|
||||
<nav class=" navbar navbar-fixed-top deft-navbar">
|
||||
<div class=" container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"><img src="img/menu.png"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span>
|
||||
<a class=" navbar-brand" href="#"><nobr><img width="40px" height="29px" src="img/icon.png">UDiary</nobr></a>
|
||||
<sup><i class="coats ">Storing Great Ideas!</i></sup>
|
||||
</span>
|
||||
</div>
|
||||
<div id="navbar" class="navbar-collapse collapse navbar-right">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a class="label" href="/">Home</a></li>
|
||||
<li><a class="label" href="/contact.jsp">Contact Us</a></li>
|
||||
<li><a class="label" href="/about.jsp">About Us</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<!-- End:Navigation Bar -->
|
||||
|
||||
<!-- Start:Action Bar -->
|
||||
<div class="actionbar">
|
||||
<button type="button" style="float: left; border: none; background: transparent; padding-top:5px;" onclick="sideNavbarAction();">
|
||||
<span class="icon-bar"><img src="img/menu.png" width="30" height="30" alt="menu"/></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<div style="padding-top: 5px;">
|
||||
<div class="btn" title="Add Diary" data-toggle="modal" data-target="#addDiaryModal" style="float: left; display: block; width: 30px; height: 30px; background-image: url(img/dboard.png); "></div>
|
||||
<div class="btn" title="Delete Diary" data-toggle="modal" data-target="#" style="float: left; display: block; width: 30px; height: 30px; background-image: url(img/dboard.png); background-position: 30px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End:Action Bar -->
|
||||
|
||||
<!-- Start:Side NavigationBar -->
|
||||
<div id="sidenavbar" class="sidenav">
|
||||
<form style=" width: 100%; height: 100%;">
|
||||
<div class="sideNavCover">
|
||||
<img src="${userinfo.picture}" class="displayPic" /><br>
|
||||
<strong id="sidenavbarName" style="padding-left: 10px; font-family: comic sans ms; font-size: 12px; color: white; outline: #000 1px; ">${userinfo.name}</strong><br>
|
||||
<p id="sidenavbarEmail" style="padding-left: 10px; font-family: comic sans ms; font-size: 12px; color: white; ">${userinfo.email}</p>
|
||||
</div>
|
||||
<div class="sideNavMenu">
|
||||
<a href="/"><div>Shelf</div></a>
|
||||
<a href="/logout"><div>Log Out</div></a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- End:Side Navigation Bar -->
|
||||
<!-- Start:Working area-->
|
||||
<div style="padding-top: 50px;" class="container">
|
||||
<div class=" col-md-12 thumbnail">
|
||||
<div class="diary-thumbnail thumbnail" style=" float: left;"></div>
|
||||
<div style="width: calc(100% - 150px)">
|
||||
<h3>Title</h3>
|
||||
<article>description...........</article>
|
||||
</div>
|
||||
<input class="btn btn-success" value="Open">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Diary -->
|
||||
<div class="modal fade" id="addDiaryModal" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h4 class="modal-title">Add Diary</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a data-toggle="tab" href="#addtheme">Theme</a></li>
|
||||
<li><a data-toggle="tab" href="#adddetails">Details</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div id="addtheme" class="tab-pane fade in active">
|
||||
|
||||
</div>
|
||||
<div id="adddetails" class="tab-pane fade">
|
||||
<div class=" form-group" style=" margin-top: 20px;">
|
||||
<label>Name:</label>
|
||||
<input class=" form-control">
|
||||
</div>
|
||||
<div class=" form-group">
|
||||
<label>Note:</label>
|
||||
<textarea class=" form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Create</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- End:Working Canvas -->
|
||||
<!-- Start: ihtml editor script -->
|
||||
<!-- End: ihtml editor script-->
|
||||
<!-- Start:container -->
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js"></script>
|
||||
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.2.js"><\/script>');</script>
|
||||
|
||||
<script src="js/vendor/bootstrap.min.js"></script>
|
||||
|
||||
<script src="js/main.js"></script>
|
||||
|
||||
<script src="js/cupboard.js"></script>
|
||||
|
||||
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
|
||||
<script>
|
||||
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
|
||||
function(){(b[l].q=b[l].q||[]).push(arguments);});b[l].l=+new Date;
|
||||
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
|
||||
e.src='//www.google-analytics.com/analytics.js';
|
||||
r.parentNode.insertBefore(e,r);}(window,document,'script','ga'));
|
||||
ga('create','UA-XXXXX-X','auto');ga('send','pageview');
|
||||
</script>
|
||||
<!-- End:container -->
|
||||
<link rel="stylesheet" href="css/fonts.css">
|
||||
</body>
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 7.9 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* @author piyush
|
||||
*/
|
||||
public class Test
|
||||
{
|
||||
public Test()
|
||||
{
|
||||
|
||||
}
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Test();
|
||||
}
|
||||
|
||||
}
|
||||