lot of updates

This commit is contained in:
Harry Bomrah 2012-04-30 14:33:12 +08:00
commit 1b7fb106f8
8 changed files with 28 additions and 34 deletions

View File

@ -25,6 +25,7 @@ gem 'sinatra'
gem 'sprockets' gem 'sprockets'
gem 'tinymce-rails' gem 'tinymce-rails'
gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux")
gem 'mongoid-encryptor', :require => 'mongoid/encryptor'
# Gems used only for assets and not required # Gems used only for assets and not required
# in production environments by default. # in production environments by default.

View File

@ -77,6 +77,7 @@ GEM
orm_adapter (~> 0.0.3) orm_adapter (~> 0.0.3)
warden (~> 1.1) warden (~> 1.1)
diff-lcs (1.1.3) diff-lcs (1.1.3)
encrypted_strings (0.3.3)
erubis (2.7.0) erubis (2.7.0)
exception_notification (2.5.2) exception_notification (2.5.2)
actionmailer (>= 3.0.4) actionmailer (>= 3.0.4)
@ -115,6 +116,10 @@ GEM
activemodel (~> 3.1) activemodel (~> 3.1)
mongo (~> 1.3) mongo (~> 1.3)
tzinfo (~> 0.3.22) tzinfo (~> 0.3.22)
mongoid-encryptor (0.0.5)
activesupport (~> 3.0)
encrypted_strings (~> 0.3.3)
mongoid (~> 2)
multi_json (1.1.0) multi_json (1.1.0)
nokogiri (1.5.2) nokogiri (1.5.2)
nokogiri (1.5.2-x86-mingw32) nokogiri (1.5.2-x86-mingw32)
@ -255,6 +260,7 @@ DEPENDENCIES
mini_magick mini_magick
mongo_session_store-rails3 mongo_session_store-rails3
mongoid mongoid
mongoid-encryptor
nokogiri nokogiri
radius radius
rails (>= 3.1.0, < 3.2.0) rails (>= 3.1.0, < 3.2.0)

View File

@ -136,8 +136,10 @@ var orbitDesktop = function(dom){
o.currentface = "home"; o.currentface = "home";
var bindHandlers = function(){ // this function will bind all the handlers in the desktop var bindHandlers = function(){ // this function will bind all the handlers in the desktop
var groupWrapperWidth = 0; var groupWrapperWidth = 0;
$("div#desktop .group").each(function(){groupWrapperWidth+=$(this).outerWidth(true);}); $("div#desktop .group").each(function(){groupWrapperWidth+=$(this).outerWidth(true);});
$("div#desktop #group_wrapper").css("width",groupWrapperWidth); $("div#desktop #group_wrapper").css("width",groupWrapperWidth);
$("div#desktop .g_col").sortable({ $("div#desktop .g_col").sortable({
connectWith: ".g_col", connectWith: ".g_col",

View File

@ -9,13 +9,19 @@ class OtheraccountsController< ApplicationController
@email = params['email'] @email = params['email']
@password = params['password'] @password = params['password']
@account = params['account'] @account = params['account']
OtherAccount.new(email: @email, encrypted_password: @password, type: @account) OtherAccount.create(user_id: current_user.id, email: @email, encrypted_password: @password, type: @account)
a = Array.new
a << {"success"=>"true"}
render :json=>a.to_json
end end
def gmail def gmail
@gmailaccount = OtherAccount.where(:type.all => ["gmail"],:user_id.all => [current_user.id])
@decrypted_password = @gmailaccount.first.encrypted_password.decrypt
@email = @gmailaccount.first.email
url = URI.parse("https://mail.google.com/mail/feed/atom") url = URI.parse("https://mail.google.com/mail/feed/atom")
req = Net::HTTP::Get.new(url.path) req = Net::HTTP::Get.new(url.path)
req.basic_auth params['username'], params['password'] req.basic_auth @email, @decrypted_password
req.content_type = 'text/xml' req.content_type = 'text/xml'
http = Net::HTTP.new(url.host, url.port) http = Net::HTTP.new(url.host, url.port)

View File

@ -1,15 +1,15 @@
class OtherAccount class OtherAccount
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
include Mongoid::Encryptor
field :user_id
field :type field :type
field :email field :email
field :encrypted_password field :encrypted_password
#attr_encrypted :encrypted_password, :key => 'rulingorbit.com', :encode => true encrypts :encrypted_password, :mode => :symmetric, :password => 'rulingcom'
belongs_to :user belongs_to :user
end end

View File

@ -10,7 +10,8 @@
<td valign="top"><label for="s_name1">Username</label><input type="text" /></td> <td valign="top"><label for="s_name1">Username</label><input type="text" /></td>
</tr> </tr>
<tr> <tr>
<td><label for="s_name1">Password</label><input type="password" /></td> <td width="400"><label for="s_name1">Password</label><input type="password" /></td>
<td><a href="" id="connection_save_btn" class="setting_btn thmc1 thmtxt w1 hh2 hp" onclick='return false;' style='float:left;'>Connect</a></td>
</tr> </tr>
<tr> <tr>
<td rowspan="2"><img src="assets/facebook.png" alt=""></td> <td rowspan="2"><img src="assets/facebook.png" alt=""></td>

View File

@ -1,20 +1,10 @@
var gmail = function(){ var gmail = function(){
var usernm = $("#gmail input[type=text]").val();
var pwd = $("#gmail input[type=password]").val();
// usernm = "hr@rulingcom.com";
// pwd = "hr08973"
if(usernm!="" && pwd!=""){
$("#gmail a#gmail_button").text("Check again");
$("#gmail #loading").show();
$("#gmail table#form").hide();
$.ajax({ $.ajax({
url: "/desktop/forgmail", url: "/desktop/forgmail",
dataType : "xml", dataType : "xml",
data : {username:usernm,password:pwd},
success:function(data){ success:function(data){
if($(data).find("HEAD").find("TITLE").text()=="Unauthorized"){ if($(data).find("HEAD").find("TITLE").text()=="Unauthorized"){
$("#gmail #forerror").text($(data).find("HEAD").find("TITLE").text()).show(); $("#gmail #forerror").text($(data).find("HEAD").find("TITLE").text()).show();
$("#gmail table#form").show();
}else{ }else{
if($(data).find("fullcount").text()=="0"){ if($(data).find("fullcount").text()=="0"){
$("#gmail #forerror").hide(); $("#gmail #forerror").hide();
@ -22,9 +12,9 @@ var gmail = function(){
}else{ }else{
var msg; var msg;
if($(data).find("fullcount").text()=="1") if($(data).find("fullcount").text()=="1")
msg = $(data).find("fullcount").text()+" unread message in your inbox." msg = $(data).find("fullcount").text()+" unread message in your inbox.";
else else
msg = $(data).find("fullcount").text()+" unread messages in your inbox." msg = $(data).find("fullcount").text()+" unread messages in your inbox.";
o.notify(msg,"alert",2); o.notify(msg,"alert",2);
$(data).find("entry").each(function(i,val){ $(data).find("entry").each(function(i,val){
if(i==0){ if(i==0){
@ -41,15 +31,14 @@ var gmail = function(){
$("#gmail #content").show(); $("#gmail #content").show();
} }
}); });
}
} }
var saveaccount = function(){ var saveaccount = function(){
var usernm = $("#gmail input[type=text]").val(); var usernm = $("#gmail input[type=text]").val();
var pwd = $("#gmail input[type=password]").val(); var pwd = $("#gmail input[type=password]").val();
usernm = "hr@rulingcom.com"; usernm = "harry@rulingcom.com";
pwd = "hr08973"; pwd = "hr08973";
if(usernm!="" && pwd!=""){ if(usernm!="" && pwd!=""){
$.post("/desktop/save_account_info",{email:usernm,password:pwd,account:"gmail"}) $.post("/desktop/save_account_info",{email:usernm,password:pwd,account:"yahoo"})
} }
} }

View File

@ -1,17 +1,6 @@
<div id="gmail"> <div id="gmail">
<div id="forerror" style="color:red;display:none;"></div> <div id="forerror" style="color:red;display:none;"></div>
<table id="form"> <div id="loading" class="thmtxt">Retrieving new emails...</div>
<tr>
<td><label class="thmtxt" style="width:75px;">Username:</label></td><td><input type="text" style="width:150px;" /></td>
</tr>
<tr>
<td><label class="thmtxt" style="width:75px;">Password:</label></td><td><input type="password" style="width:150px;" /></td>
</tr>
<tr>
<td colspan="2" align='center'><a href="" onclick="gmail();return false;" class='thmtxt' id="gmail_button">Check for new mail</button></td>
</tr>
</table>
<div id="loading" style="display:none" class="thmtxt">Retrieving new emails...</div>
<div id="content" style="display:none;"background-color:#000;height:200px;"" > <div id="content" style="display:none;"background-color:#000;height:200px;"" >
<div id="subject" ></div> <div id="subject" ></div>
<div id="date" class='thmtxt'></div> <div id="date" class='thmtxt'></div>
@ -20,6 +9,6 @@
</div> </div>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
gmail();
}) })
</script> </script>