Skip to content

Commit

Permalink
Fix news page layout bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SonnyX committed Aug 9, 2019
1 parent c982691 commit 784f78a
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 192 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ tokio = "^0.1.18"
tokio-tls = "^0.2.1"
native-tls = "^0.2"
tokio-reactor = "^0.1.9"
tokio-xmpp = "^1.0.0"
xmpp-parsers = "^0.14.0"
url = "^1.7.2"
futures = "^0.1.27"
sciter-rs = "^0.5.45"
Expand Down
18 changes: 18 additions & 0 deletions dom/chat.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
div.chat {
height: *;
width: *;
}


div.chat h2 {
width: *;
text-align: center;
border-bottom: 1px solid #000;
line-height: 0.1em;
margin: 10px 0 20px;
}

div.chat h2 span {
background:#fff;
padding:0 10px;
}
45 changes: 4 additions & 41 deletions dom/containers.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ div.titlebar > .title {
overflow: auto;
}

.grid, .news-grid {
.grid {
flow:grid(2 1 3,
2 5 3,
2 4 3);
width: *;
height: *;
}

.grid > div:nth-child(1), .grid > div:nth-child(4), .news-grid > div:nth-child(1), .news-grid > div:nth-child(4) {
.grid > div:nth-child(1), .grid > div:nth-child(4) {
height: 80dip;
width: *;
}
Expand All @@ -142,11 +142,11 @@ div.titlebar > .title {
width: 20dip;
}

.grid > div:nth-child(4), .news-grid > div:nth-child(4) {
.grid > div:nth-child(4) {
vertical-align: middle;
}

.grid > div:nth-child(4) *, .news-grid > div:nth-child(4) * {
.grid > div:nth-child(4) * {
text-transform: uppercase;
}

Expand All @@ -164,48 +164,11 @@ div.titlebar > .title {
height: *;
}

.news-grid > div:nth-child(2), .news-grid > div:nth-child(3) {
height: *;
width: *;
}

.news-grid > div:nth-child(5) {
width: *;
height: *;
padding: -10dip;
}

.join_server {
min-width: 600dip;
max-width: 700dip;
}

.news_items_container {
width: 400dip;
background-color: #0c151ee6;
}

.news_items_container > div:nth-child(2) {
aspect: "Emu.render_news_items";
}

.news_items_container > div:nth-child(2) > div {
width: *;
height: 60dip;
}

.news_items_container > div:nth-child(2) > div:nth-child(even) {
background-color: #0c151ee6;
}

.news_container {
width: 750dip;
}

.news_container .body {
padding-top: -5dip;
}

.logo {
background-image: url(images/RenX_Logo.png);
background-position: center;
Expand Down
3 changes: 2 additions & 1 deletion dom/frontpage.htm
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<html window-icon="images/rx.ico" window-resizable>
<html window-icon="images/rx.ico" window-frame="extended" window-resizable>
<head>
<title>RenegadeX-Launcher</title>
<style>
@import url(elements.css);
@import url(containers.css);
@import url(fonts.css);
@import url(news.css);
@import url(chat.css);
</style>
<script type="text/tiscript">
include "events.tis";
Expand Down
2 changes: 1 addition & 1 deletion dom/game.htm
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ <h3>MAP: <span #map-name style="color: #CE5135;"></span></h3>
<div.nowrap style="margin-right: 10dip;">connect disconnect users</div>
</div>
<div.body.mheight>
<div.chat readonly="true" spellcheck="false" style="behavior: htmlarea;">Chat is still under construction, our apologies!</div>
<div.chat readonly="true" spellcheck="false" style="behavior: htmlarea;"></p>Chat is still under construction, our apologies!</p></br><div.vflow><div.vflow><hr /></div>User connected<div.vflow><hr /></div></div></div>
<div.reply>
<input|text novalue="Type here..." enter="sendIrcMessage(this)" />
</div>
Expand Down
79 changes: 69 additions & 10 deletions dom/news.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
.news-grid {
flow:grid(2 1 3,
2 5 3,
2 4 3);
width: *;
height: *;
}

.news-grid > div:nth-child(1), .news-grid > div:nth-child(4) {
height: 80dip;
width: *;
}

.news-grid > div:nth-child(2), .news-grid > div:nth-child(3) {
height: *;
width: *;
}

.news-grid > div:nth-child(4) {
vertical-align: middle;
}

.news-grid > div:nth-child(4) * {
text-transform: uppercase;
}

.news-grid > div:nth-child(5) {
height: *;
}

.news_items_container {
width: 400dip;
background-color: #0c151ee6;
}

.news_items_container > div:nth-child(2) {
aspect: "Emu.render_news_items";
}

.news_items_container > div:nth-child(2) > div {
width: *;
height: 60dip;
}

.news_items_container > div:nth-child(2) > div:nth-child(even) {
background-color: #0c151ee6;
}

.news_container {
width: 750dip;
height: *;
}

.news_container > div:nth-child(2) {
padding-top: 10dip;
padding-bottom: 10dip;
background-color: #0c151ee6;
overflow-y: auto;
width: *;
height: *;
min-height: 0;
max-height: min-intrinsic;
}

#news {
height: min-intrinsic;
}

#news p {
margin-top: 1em;
margin-bottom: 1em;
Expand All @@ -7,19 +75,10 @@
line-height: 1.5;
}

#news p:empty {
margin-top: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
border-radius: 0;
line-height: 0;
}

#news img {
border-style: none;
aspect: "Emu.news_image";
image-rendering:optimize-quality;
image-rendering: optimize-quality;
}

#news img[data-ratio] {
Expand Down
10 changes: 6 additions & 4 deletions dom/news.htm
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ <h1><output game_version/></h1>
<div.left-margin></div>
<div.right-margin></div>
<div.footer-margin></div>
<div.hflow.child-margin>
<div.hflow.child-margin.expand>
<div.news_items_container.vflow>
<div.titlebar>
<h3.title>[WIP] Chat</h3>
<h3.title.uppercase>Renegade-X news</h3>
</div>
<div.expand>
<div><pubDate>date</pubDate><p.title>title</p></div>
<div><pubDate>date</pubDate><p.type_news.uppercase>patch</p><p.title.uppercase>title</p></div>
</div>
</div>
<div.news_container.vflow>
<div.titlebar>
<h3.title>[WIP] Chat</h3>
</div>
<div.body.expand #news style="overflow-y:auto; margin-bottom: 10dip;"></div>
<div>
<div #news></div>
</div>
</div>
</div>
</div>
110 changes: 0 additions & 110 deletions src/chat.rs
Original file line number Diff line number Diff line change
@@ -1,113 +1,3 @@
use std::thread;
use std::sync::{Arc, Mutex};
use futures::unsync::mpsc::{unbounded, UnboundedSender, UnboundedReceiver};
use tokio_xmpp::{Client, Packet};
use xmpp_parsers::{Jid, Element, TryFrom};
use xmpp_parsers::message::{Body, MessageType};
use xmpp_parsers::presence::{Presence, Show as PresenceShow, Type as PresenceType};


//traits:
use futures::{Stream, Sink, Future};

/// The generic chat instance, should be transformed into a trait
pub struct Chat<R: FnMut(ChatEvent)> {
connected: Arc<Mutex<bool>>,
receiver: R,
sender: UnboundedSender<tokio_xmpp::xmpp_codec::Packet>,
rt: tokio::runtime::Runtime,
}

pub enum ChatEvent {
/// Send a string
Send(String),
/// Receive a message
Receive(Message),
/// Any event, like connect, disconnect, list of users?, etc.
Event(String),
/// Any error that occurs
Error(Error)
}

pub struct Message {
//add something like a timestamp?
pub username: String,
pub message: String,
}

pub struct Error {
pub description: String,
}

fn make_presence() -> Element {
let mut presence = Presence::new(PresenceType::None);
presence.show = Some(PresenceShow::Chat);
presence.statuses.insert(String::from("en"), String::from("Echoing messages."));
presence.into()
}

impl<R: FnMut(ChatEvent)> Chat<R> {
pub fn new(receiver: R, username: String, password: String, server: String) -> Chat<R> {
let (client_sender, mut server_receiver) = unbounded();
let connected = Arc::new(Mutex::new(false));
let chat = Chat {
connected: connected.clone(),
receiver: receiver,
sender: client_sender,
rt: tokio::runtime::Runtime::new().unwrap(),
};
let client = tokio_xmpp::Client::new(&format!("{}@{}", username, server), &password).unwrap();
let (sink, stream) = client.split();
/*
chat.rt.spawn(
server_receiver.forward(
sink.sink_map_err(|_| panic!("Pipe"))
).map(|(server_receiver, mut sink)| {
drop(server_receiver);
let _ = sink.close();
}).map_err(|e| {
panic!("Send error: {:?}", e);
})
);
*/
/*
chat.rt.block_on(stream.for_each(|event| {
if event.is_online() {
println!("Online!");
//let presence = make_presence();
//tx.start_send(Packet::Stanza(presence)).unwrap();
} else if let Some(message) = event.into_stanza().and_then(|stanza| xmpp_parsers::message::Message::try_from(stanza).ok()) {
println!("{:?}", message);
}
futures::future::ok(())
}).map_err(|e| {
panic!("Send error: {:?}", e);
}));
*/
chat
}
/*
pub fn send(&self, message: String) {
self.rt.spawn(self.sender.send(message));
}
*/
pub fn is_connected(&self) -> bool {
*self.connected.lock().unwrap()
}
}

/// encodes an input to an html-encoded output
pub fn encode(input: String) -> String {
let mut output = String::new();
for chr in input.chars() {
match chr {
'0'..='9' | 'a'..='z' | 'A'..='Z' => {
output.push(chr);
},
_ => {
output.push_str(&format!("#{};", chr as u32));
},
}
}
output
}
Loading

0 comments on commit 784f78a

Please sign in to comment.