mirror of https://github.com/PiyushXCoder/lupt.git
git support
This commit is contained in:
parent
ce5ee19c9e
commit
6089cfb428
|
|
@ -67,6 +67,8 @@ dependencies = [
|
|||
"futures-util",
|
||||
"http",
|
||||
"log",
|
||||
"openssl",
|
||||
"tokio-openssl",
|
||||
"trust-dns-proto",
|
||||
"trust-dns-resolver",
|
||||
]
|
||||
|
|
@ -103,6 +105,7 @@ dependencies = [
|
|||
"actix-rt",
|
||||
"actix-service",
|
||||
"actix-threadpool",
|
||||
"actix-tls",
|
||||
"actix-utils",
|
||||
"base64",
|
||||
"bitflags",
|
||||
|
|
@ -264,6 +267,8 @@ dependencies = [
|
|||
"actix-service",
|
||||
"actix-utils",
|
||||
"futures-util",
|
||||
"openssl",
|
||||
"tokio-openssl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -314,6 +319,7 @@ dependencies = [
|
|||
"fxhash",
|
||||
"log",
|
||||
"mime",
|
||||
"openssl",
|
||||
"pin-project 1.0.5",
|
||||
"regex",
|
||||
"serde",
|
||||
|
|
@ -447,6 +453,7 @@ dependencies = [
|
|||
"futures-core",
|
||||
"log",
|
||||
"mime",
|
||||
"openssl",
|
||||
"percent-encoding",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
|
|
@ -1199,6 +1206,7 @@ dependencies = [
|
|||
"clap",
|
||||
"env_logger",
|
||||
"futures",
|
||||
"openssl",
|
||||
"rand 0.8.3",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
@ -2042,6 +2050,16 @@ dependencies = [
|
|||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-openssl"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c4b08c5f4208e699ede3df2520aca2e82401b2de33f45e96696a074480be594"
|
||||
dependencies = [
|
||||
"openssl",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.2.0"
|
||||
|
|
|
|||
|
|
@ -9,12 +9,13 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
actix = "0.10"
|
||||
actix-web = "3"
|
||||
actix-web = { version = "3", features = ["openssl"] }
|
||||
actix-web-actors = "3"
|
||||
actix-broker = "0.3.1"
|
||||
actix-files = "0.5.0"
|
||||
actix-ratelimit = "0.3.1"
|
||||
env_logger = "0.8.3"
|
||||
openssl = "0.10.28"
|
||||
|
||||
clap = "2.33.3"
|
||||
serde = "1.0.123"
|
||||
|
|
|
|||
29
src/main.rs
29
src/main.rs
|
|
@ -8,11 +8,14 @@
|
|||
//! |--> ws_sansad3 <---- /
|
||||
//! |--> ws_sansad4 <----/
|
||||
//!
|
||||
|
||||
use actix_web::{App, Error, HttpRequest, HttpResponse, HttpServer, middleware::Logger, web};
|
||||
use actix_web::{
|
||||
App, Error, HttpRequest, HttpResponse, HttpServer, middleware::Logger, web,
|
||||
client::{Client, Connector}
|
||||
};
|
||||
use actix_files as fs;
|
||||
use actix_web_actors::ws;
|
||||
use actix_ratelimit::{RateLimiter, MemoryStore, MemoryStoreActor};
|
||||
use openssl::ssl::{SslConnector, SslMethod};
|
||||
use ws_sansad::WsSansad;
|
||||
|
||||
mod config;
|
||||
|
|
@ -38,6 +41,8 @@ async fn main() -> std::io::Result<()> {
|
|||
)
|
||||
.wrap(Logger::new("%t [%{x-forwarded-for}i] %s %{User-Agent}i %r"))
|
||||
.service(web::resource("/ws/").route(web::get().to(ws_index)))
|
||||
.service(web::resource("/gif/").route(web::get().to(gif)))
|
||||
.service(web::resource("/gif/{query}").route(web::get().to(gif)))
|
||||
.service(fs::Files::new("/", &static_path).index_file("index.html"))
|
||||
})
|
||||
.bind(config.bind_address)?
|
||||
|
|
@ -48,3 +53,23 @@ async fn main() -> std::io::Result<()> {
|
|||
async fn ws_index(req: HttpRequest, stream: web::Payload) -> Result<HttpResponse, Error> {
|
||||
ws::start(WsSansad::new(), &req, stream)
|
||||
}
|
||||
|
||||
async fn gif(req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||
let name = req.match_info().get("query").unwrap_or("");
|
||||
let builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||
|
||||
let client = Client::builder()
|
||||
.connector(Connector::new().ssl(builder.build()).finish())
|
||||
.finish();
|
||||
|
||||
|
||||
let url = format!("https://g.tenor.com/v1/search?q={}&key=LIVDSRZULELA&limit=20&media_filter=tinygif", name);
|
||||
let response = client.get(url)
|
||||
.header("User-Agent", "actix-web/3.0")
|
||||
.send()
|
||||
.await?
|
||||
.body()
|
||||
.await?;
|
||||
|
||||
Ok(HttpResponse::Ok().content_type("application/json").body(response))
|
||||
}
|
||||
|
|
@ -289,8 +289,23 @@ input {
|
|||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.clip-win.camera-clip {
|
||||
width: 314px;
|
||||
.clip-win.gif-clip {
|
||||
width: calc(100% - 2*8px - 3*5px);
|
||||
max-width: 720px;
|
||||
/* max-height: 70%; */
|
||||
}
|
||||
|
||||
.gif-clip .button {
|
||||
max-width: 120px;
|
||||
padding: 0.5rem;
|
||||
margin: 0.5rem;
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.gif-clip > #gif_area {
|
||||
overflow-y: auto;
|
||||
max-height: 350px;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
#dialog {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="600px" height="600px" viewBox="0 0 600 600" enable-background="new 0 0 600 600" xml:space="preserve">
|
||||
<g>
|
||||
<path fill="#4C6B62" d="M500,423.139C500,465.587,465.587,500,423.138,500H176.862C134.413,500,100,465.587,100,423.139V176.862
|
||||
C100,134.413,134.413,100,176.862,100h246.275C465.587,100,500,134.413,500,176.862V423.139z"/>
|
||||
<path fill="#426158" d="M500,423.139V264.812l-68.108-46.778L163.206,377.652L323.24,500h99.897
|
||||
C465.587,500,500,465.587,500,423.139z"/>
|
||||
<g>
|
||||
<path fill="#223E52" d="M445.315,355.89c0,17.708-14.354,32.061-32.06,32.061H186.742c-17.708,0-32.059-14.353-32.059-32.061
|
||||
V244.111c0-17.706,14.352-32.059,32.059-32.059h226.514c17.706,0,32.06,14.353,32.06,32.059V355.89z"/>
|
||||
<path fill="#4D3D4D" d="M409.64,312.955c0,17.704-14.354,32.062-32.059,32.062H222.416c-17.706,0-32.059-14.357-32.059-32.062
|
||||
v-7.992c0-17.707,14.354-32.06,32.059-32.06h155.166c17.705,0,32.059,14.353,32.059,32.06V312.955z"/>
|
||||
<path fill="#8DB3B3" d="M230.43,282.029c-14.872,0-26.929,12.058-26.929,26.93c0,14.87,12.057,26.93,26.929,26.93
|
||||
c14.874,0,26.93-12.06,26.93-26.93C257.359,294.086,245.304,282.029,230.43,282.029z M230.43,323.328
|
||||
c-7.936,0-14.371-6.431-14.371-14.369c0-7.938,6.435-14.372,14.371-14.372c7.938,0,14.373,6.434,14.373,14.372
|
||||
C244.803,316.897,238.368,323.328,230.43,323.328z"/>
|
||||
<path fill="#8DB3B3" d="M369.566,287.585c-11.805,0-21.373,9.57-21.373,21.374c0,11.806,9.568,21.371,21.373,21.371
|
||||
c11.803,0,21.373-9.565,21.373-21.371C390.939,297.155,381.369,287.585,369.566,287.585z M369.566,324.119
|
||||
c-8.372,0-15.161-6.787-15.161-15.16s6.789-15.162,15.161-15.162s15.161,6.789,15.161,15.162S377.938,324.119,369.566,324.119z"/>
|
||||
<rect x="245.147" y="261.229" fill="#223E52" width="109.703" height="99.04"/>
|
||||
<path fill="#E7BD79" d="M345.504,323.065c0,7.081-5.742,12.823-12.822,12.823h-66.646c-7.083,0-12.823-5.742-12.823-12.823
|
||||
v-29.924c0-7.083,5.74-12.825,12.823-12.825h66.646c7.08,0,12.822,5.742,12.822,12.825V323.065z"/>
|
||||
<rect x="253.212" y="294.591" fill="#DCD4B6" width="92.292" height="26.909"/>
|
||||
<path fill="#DC7D49" d="M413.256,212.052H186.742c-17.463,0-31.656,13.965-32.042,31.334h290.598
|
||||
C444.912,226.018,430.72,212.052,413.256,212.052z"/>
|
||||
<path fill="#9F4456" d="M340.408,301.314c0,1.237-1.004,2.243-2.245,2.243h-77.612c-1.241,0-2.245-1.006-2.245-2.243l0,0
|
||||
c0-1.241,1.004-2.245,2.245-2.245h77.612C339.404,299.069,340.408,300.073,340.408,301.314L340.408,301.314z"/>
|
||||
<path fill="#9F4456" d="M340.408,308.047c0,1.241-1.004,2.243-2.245,2.243h-77.612c-1.241,0-2.245-1.002-2.245-2.243l0,0
|
||||
c0-1.24,1.004-2.242,2.245-2.242h77.612C339.404,305.805,340.408,306.807,340.408,308.047L340.408,308.047z"/>
|
||||
<path fill="#9F4456" d="M340.408,314.779c0,1.241-1.004,2.247-2.245,2.247h-77.612c-1.241,0-2.245-1.006-2.245-2.247l0,0
|
||||
c0-1.24,1.004-2.242,2.245-2.242h77.612C339.404,312.537,340.408,313.539,340.408,314.779L340.408,314.779z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
|
|
@ -178,10 +178,15 @@
|
|||
<div id="action_clip" class="clip-win action-clip is-hidden">
|
||||
<div style="padding-bottom: 10px;">
|
||||
<button class="button" onclick="$('#file-input').click()">
|
||||
<img src="img/image.svg" alt="Image" width="50" max-size="3072" class="siimple--py-2 siimple--px-2">
|
||||
<img src="img/image.svg" alt="Image" width="50" max-size="3072">
|
||||
<div>send image</div>
|
||||
</button>
|
||||
<input id="file-input" class="is-hidden" type="file" accept="image/png, image/jpeg"/>
|
||||
|
||||
<button class="button" onclick="$('#action_clip').addClass('is-hidden'); $('#gif_clip').removeClass('is-hidden'); loadGif('')">
|
||||
<img src="img/gif.svg" alt="Image" width="50" max-size="3072">
|
||||
<div>send Gif</div>
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button onclick="changeColor()" class="button"><img src="img/color.svg" alt="C" height="16"></button>
|
||||
|
|
@ -190,11 +195,10 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Camera Clip -->
|
||||
<div id="camera_clip" class="clip-win camera-clip is-hidden">
|
||||
<video autoplay="true" id="videoElement" width="300"></video>
|
||||
<button class="button is-full-width">Send</button>
|
||||
|
||||
<!-- Gif Clip -->
|
||||
<div id="gif_clip" class="clip-win gif-clip is-hidden">
|
||||
<input type="text" id="gif_search" placeholder="Search">
|
||||
<div id="gif_area"></div>
|
||||
</div>
|
||||
|
||||
<!-- vayakti -->
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ var no_name_message = false;
|
|||
|
||||
// check if support ws
|
||||
if(!('WebSocket' in window || 'MozWebSocket' in window)) {
|
||||
$('initerror').text('Warning: Web Browser dosen\'t support websocket! Upgrade');
|
||||
$('#initerror').text('Warning: Web Browser dosen\'t support websocket! Upgrade');
|
||||
}
|
||||
|
||||
// Connection opened
|
||||
|
|
@ -40,14 +40,13 @@ socket.onopen = function(event) {
|
|||
|
||||
// Connection fail
|
||||
socket.onerror = function(event) {
|
||||
$('initerror').text('Warning: Failed to connect websocket! Refresh the '+
|
||||
$('#initerror').text('Warning: Failed to connect websocket! Refresh the '+
|
||||
'page and if still don\'t work upgrade Web Browser');
|
||||
}
|
||||
|
||||
// Listen for messages
|
||||
socket.onmessage = function(event) {
|
||||
var j = JSON.parse(event.data);
|
||||
console.log(j);
|
||||
switch(j.cmd) {
|
||||
case 'resp':
|
||||
if(j.result == 'Err') {
|
||||
|
|
@ -288,7 +287,7 @@ function autosize(el){
|
|||
},0);
|
||||
}
|
||||
|
||||
|
||||
// Dialog
|
||||
var dialogCallback;
|
||||
function dialog(prop, call) {
|
||||
dialogCallback = call;
|
||||
|
|
@ -310,3 +309,32 @@ $('#dialog_ok').click(function() {
|
|||
$('#dialog').addClass('is-hidden');
|
||||
dialogCallback();
|
||||
});
|
||||
|
||||
// Gif
|
||||
$("#gif_search").keyup(function(event){
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
loadGif(this.value);
|
||||
}
|
||||
});
|
||||
|
||||
function loadGif(query) {
|
||||
var area = $('#gif_area');
|
||||
area.empty();
|
||||
$.get("/gif/"+query, function(data, status){
|
||||
if(status == 'success') {
|
||||
data.results.forEach(function(result) {
|
||||
var gif = result.media[0].tinygif.url;
|
||||
area.append($('<button>', {class: 'button', onclick: 'sendGif("'+gif+'"); $("#gif_clip").addClass("is-hidden");'})
|
||||
.append($('<img>', {src: gif})));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function sendGif(gif) {
|
||||
socket.send(JSON.stringify({
|
||||
cmd: "img",
|
||||
src: gif
|
||||
}));
|
||||
}
|
||||
|
|
@ -121,13 +121,10 @@ let Messages = class {
|
|||
|
||||
static addReaction(sender, emoji, msg_id) {
|
||||
var msg = $('[msgid='+msg_id+']');
|
||||
console.log('msg', msg, msg_id);
|
||||
if(msg.find('[name=bar_msg]').length == 0) {
|
||||
msg.append($('<div>', {class: 'message-sub', name: 'bar_msg'}));
|
||||
console.log('inside');
|
||||
}
|
||||
var bar = msg.find('[name=bar_msg]');
|
||||
console.log('bar', bar);
|
||||
var elm = bar.find('[name="r_'+sender+'"]');
|
||||
if(elm.length > 0) {
|
||||
elm.find('img').attr('src', 'img/'+emoji+'.svg');
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ let State = class {
|
|||
$('#connect_panel').removeClass('is-hidden');
|
||||
$('#chat_panel').addClass('is-hidden');
|
||||
$('#reply_clip').addClass('is-hidden');
|
||||
$('#gif_clip').addClass('is-hidden');
|
||||
$('#selected_clip').addClass('is-hidden');
|
||||
$('#action_clip').addClass('is-hidden');
|
||||
$('#vayakti_model').addClass('is-hidden');
|
||||
|
|
@ -13,6 +14,7 @@ let State = class {
|
|||
$('#chat_panel').removeClass('is-hidden');
|
||||
$('#connect_panel').addClass('is-hidden');
|
||||
$('#reply_clip').addClass('is-hidden');
|
||||
$('#gif_clip').addClass('is-hidden');
|
||||
$('#selected_clip').addClass('is-hidden');
|
||||
$('#action_clip').addClass('is-hidden');
|
||||
$('#vayakti_model').addClass('is-hidden');
|
||||
|
|
|
|||
Loading…
Reference in New Issue