Browse Source

- Add Jappix image support in Post

- Rewrite Chat UI
pull/16/head
Jaussoin Timothée 13 years ago
parent
commit
7ddb8d796f
  1. 17
      system/Datas/Post.php
  2. 63
      system/Utils.php
  3. 75
      system/Widget/widgets/Chat/Chat.php
  4. 166
      system/Widget/widgets/Chat/chat.css
  5. 26
      system/Widget/widgets/Chat/chat.js
  6. BIN
      system/Widget/widgets/Chat/img/arrow.png
  7. 2
      system/Widget/widgets/Login/login.css
  8. 2
      system/Widget/widgets/Roster/roster.css
  9. 17
      themes/movim/css/posts.css
  10. 4
      themes/movim/css/style2.css

17
system/Datas/Post.php

@ -80,11 +80,11 @@ class Post extends DatajarBase {
$this->parentid->setval($parent);
if($item->entry->title)
$this->content->setval((string)$item->entry->title);
$content = (string)$item->entry->title;
elseif($item->entry->content)
$this->content->setval((string)$item->entry->content);
$content = (string)$item->entry->content;
elseif($item->entry->body)
$this->content->setval((string)$item->entry->body);
$content = (string)$item->entry->body;
$this->published->setval(date('Y-m-d H:i:s', strtotime((string)$item->entry->published)));
@ -109,16 +109,27 @@ class Post extends DatajarBase {
unset((string)$item->entry->link->attributes());
}*/
$contentimg = '';
foreach($item->entry->link as $attachment) {
/*if($attachment['link[0]['attributes()->title == 'thumb') {
AttachmentHandler::saveAttachment($attachment, $key, $from, (string)$item->attributes()->id);
}*/
if(isset($attachment->link[0]) && (string)$attachment->link[0]->attributes()->title == 'thumb') {
$contentimg .= '
<a href="'.(string)$attachment->attributes()->href.'" target="_blank" class="imglink"><img title="'.(string)$attachment->attributes()->title.'" src="'.(string)$attachment->link[0]->attributes()->href.'"/></a>';
}
if((string)$attachment->attributes()->title == 'comments') {
$this->commentson->setval(1);
$this->commentplace->setval(reset(explode('?', substr((string)$attachment->attributes()->href, 5))));
}
}
if($contentimg != '')
$content .= '<br />'.$contentimg;
$this->content->setval($content);
}
public function setNoComments() {

63
system/Utils.php

@ -143,69 +143,6 @@ function prepareString($string) {
return trim($string);
}
/**
* Convert plaintext URI to HTML links.
*
* Converts URI, www and ftp, and email addresses. Finishes by fixing links
* within links.
*
* @since 0.71
*
* @param string $text Content to convert URIs.
* @return string Content with converted URIs.
*/
function make_clickable( $text ) {
$r = '';
$textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags
foreach ( $textarr as $piece ) {
if ( empty( $piece ) || ( $piece[0] == '<' && ! preg_match('|^<\s*[\w]{1,20}+://|', $piece) ) ) {
$r .= $piece;
continue;
}
// Long strings might contain expensive edge cases ...
if ( 10000 < strlen( $piece ) ) {
// ... break it up
foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses
if ( 2101 < strlen( $chunk ) ) {
$r .= $chunk; // Too big, no whitespace: bail.
} else {
$r .= make_clickable( $chunk );
}
}
} else {
$ret = " $piece "; // Pad with whitespace to simplify the regexes
$url_clickable = '~
([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation
( # 2: URL
[\\w]{1,20}+:// # Scheme and hier-part prefix
(?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long
[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character
(?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character
[\'.,;:!?)] # Punctuation URL character
[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character
)*
)
(\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing)
~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character.
// Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
$ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret );
$ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );
$ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret );
$ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.
$r .= $ret;
}
}
// Cleanup of accidental links within links
$r = preg_replace( '#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
return $r;
}
/**
* Return a human-readable date
*

75
system/Widget/widgets/Chat/Chat.php

@ -178,15 +178,15 @@ class Chat extends WidgetBase
$presence = $presence[0];
if($contact->getData('chaton') != 1 && isset($presence) && $presence->presence->getval() != 6) {
$contact->chaton->setval(2);
$contact->run_query($contact->query()->save($contact));
RPC::call('movim_prepend',
'chats',
RPC::cdata($this->prepareChat($contact)));
RPC::call('scrollAllTalks');
$contact->chaton->setval(1);
$contact->run_query($contact->query()->save($contact));
RPC::commit();
}
}
@ -233,13 +233,14 @@ class Chat extends WidgetBase
->where(array(
'key' => $this->user->getLogin(),
'jid' => $jid));
$contact = Contact::run_query($query);
$contact = $contact[0];
if($contact->getData('chaton') == 1 || $contact->getData('chaton') == 2) {
$contact->chaton->setval(0);
$contact->run_query($contact->query()->save($contact));
$contacts = Contact::run_query($query);
//$contact = $contact[0];
foreach($contacts as $contact) {
if((int)$contact->getData('chaton') == 1 || (int)$contact->getData('chaton') == 2) {
$contact->chaton->setval(0);
$contact->run_query($contact->query()->save($contact));
}
}
}
@ -274,7 +275,7 @@ class Chat extends WidgetBase
$content = $message->getData('body');
if(preg_match("#^/me#", $message->getData('body'))) {
$html .= "own ";
$html .= " own ";
$content = "** ".substr($message->getData('body'), 4);
}
@ -313,24 +314,44 @@ class Chat extends WidgetBase
$style = '';
if($contact->getData('chaton') == 2) {
$style = ' style="display: none;" ';
$tabstyle = ' style="display: none;" ';
$panelstyle = ' style="display: block;" ';
}
$html = '
<div class="chat" onclick="this.querySelector(\'textarea\').focus()">'.
'<div class="messages" '.$style.' id="messages'.$contact->getData('jid').'">'.$messageshtml.'
<div style="display: none;" class="message" id="composing'.$contact->getData('jid').'">'.t('Composing...').'</div>
<div style="display: none;" class="message" id="paused'.$contact->getData('jid').'">'.t('Paused...').'</div>
</div>'.
'<textarea onkeyup="movim_textarea_autoheight(this);" '.$style.'
onkeypress="if(event.keyCode == 13) {'.$this->genCallAjax('ajaxSendMessage', "'".$contact->getData('jid')."'", "sendMessage(this, '".$contact->getData('jid')."')").' return false; }"
onfocus="setBackgroundColor(\'chatwindow'.$contact->getData('jid').'\', \'#444444\')"
></textarea>'.
'<a class="name" onclick="'.$this->genCallAjax("ajaxHideTalk", "'".$contact->getData('jid')."'").' hideTalk(this);">'.
'<img class="avatar" src="'.$contact->getPhoto('xs').'" /><span>'.$contact->getTrueName().'</span>'.
'</a>'.
'<span class="cross" onclick="'.$this->genCallAjax("ajaxCloseTalk", "'".$contact->getData('jid')."'").' closeTalk(this)"></span>'.
'</div>';
<div class="chat" onclick="this.querySelector(\'textarea\').focus()">
<div class="panel" '.$panelstyle.'>
<div class="head" >
<span class="chatbutton cross" onclick="'.$this->genCallAjax("ajaxCloseTalk", "'".$contact->getData('jid')."'").' closeTalk(this)"></span>
<span class="chatbutton arrow" onclick="'.$this->genCallAjax("ajaxHideTalk", "'".$contact->getData('jid')."'").' hideTalk(this)"></span>
<img class="avatar" src="'.$contact->getPhoto('xs').'" />
<a class="name" href="?q=friend&f='.$contact->getData('jid').'">
'.$contact->getTrueName().'
</a>
</div>
<div class="messages" id="messages'.$contact->getData('jid').'">
'.$messageshtml.'
<div style="display: none;" class="message" id="composing'.$contact->getData('jid').'">'.t('Composing...').'</div>
<div style="display: none;" class="message" id="paused'.$contact->getData('jid').'">'.t('Paused...').'</div>
</div>
<div class="text">
<textarea
rows="1"
onkeyup="movim_textarea_autoheight(this);"
onkeypress="if(event.keyCode == 13) {'.$this->genCallAjax('ajaxSendMessage', "'".$contact->getData('jid')."'", "sendMessage(this, '".$contact->getData('jid')."')").' return false; }"
onfocus="setBackgroundColor(\'chatwindow'.$contact->getData('jid').'\', \'#444444\')"
></textarea>
</div>
</div>
<div class="tab" '.$tabstyle.' onclick="'.$this->genCallAjax("ajaxHideTalk", "'".$contact->getData('jid')."'").' showTalk(this);">
<div class="name">
<img class="avatar" src="'.$contact->getPhoto('xs').'" />'.$contact->getTrueName().'
</div>
</div>
</div>
';
return $html;
}

166
system/Widget/widgets/Chat/chat.css

@ -1,6 +1,6 @@
#chats {
position: fixed;
bottom: 0;
bottom: -4px;
right: 210px;
z-index: 3;
}
@ -9,96 +9,152 @@
display: inline-block;
position: relative;
bottom: 0;
background-color: #444;
color: white;
width: 200px;
border-radius: 2px 2px 0px 0px;
overflow: hidden;
box-shadow: 0px 5px 10px rgba(0,0,0,0.3);
}
#chats .chat .name:hover {
cursor: pointer;
}
#chats .chat span {
padding: 5px;
line-height: 20px;
font-size: 11px;
}
#chats .chat .messages {
background-color: white;
color: gray;
max-height: 200px;
overflow: auto;
border: 1px solid black;
min-height: 3em;
border-color: #E5E5E5 #E5E5E5 white;
#chats .chat .panel {
display: none;
}
#chats .chat .messages .message {
padding: 5px;
word-wrap: break-word;
#chats .chat .tab {
background-color: #DDD;
border: 1px solid #888;
border-top: 1px solid #AAA;
border-bottom: 0px;
}
#chats .chat .messages .message.me {
background-color: #FFC;
#chats .chat .tab:hover {
background-color: #EEE;
}
#chats .chat .messages .message.own {
color: blue;
#chats .chat .tab .name {
padding-right: 5px ;
line-height: 24px;
}
#chats .chat .messages .message.presence {
color: black;
font-weight: bold;
#chats .chat .tab .name img {
margin-right: 5px;
float: left;
width: 24px;
}
#chats .chat span.cross {
background-image: url(img/cross.png);
#chats .chat .panel .head span.chatbutton {
width: 15px;
height: 15px;
background-repeat: no-repeat;
padding: 0px;
margin-top: 5px;
margin-right: 2px;
float: right;
}
margin-top: 6px;
margin-right: 3px;
float: right;
}
#chats .chat .panel .head span.chatbutton.cross {
background-image: url(img/cross.png);
}
#chats .chat .panel .head span.chatbutton.arrow {
background-image: url(img/arrow.png);
}
#chats .chat .panel .head a.name {
padding-right: 1em;
}
#chats .chat .tab:hover {
cursor: pointer;
}
#chats .chat .panel {
background-color: white;
width: 225px;
border-radius: 2px 2px 0px 0px;
}
#chats .chat span.cross:hover {
#chats .chat .panel .head {
background-color: #242424;
color: white;
line-height: 24px;
border: 1px solid #222;
border-radius: 2px 2px 0px 0px;
border-bottom: 1px solid #242424;
}
#chats .chat .panel .head:hover {
cursor: pointer;
}
#chats .chat .avatar {
#chats .chat .panel .head > * {
color: white;
}
#chats .chat .panel .head a:hover {
text-decoration: underline;
}
#chats .chat .panel .head img {
margin-right: 5px;
float: left;
height: 20px;
margin: 1px;
margin-bottom: 0px;
margin-top: 0px;
width: 24px;
}
#chats .chat .messages .message.me span.date {
color: #444;
#chats .chat .panel .messages {
background-color: white;
color: gray;
max-height: 250px;
overflow: auto;
min-height: 3em;
border: 1px solid #888;
border-top: 0px;
border-bottom: 0px;
}
#chats .chat .panel .text {
overflow: hidden;
border: 1px solid #888;
}
#chats .chat textarea {
width: 194px;
border: 1px solid #444;
#chats .chat .panel .text textarea {
width: 100%;
border: 0px;
padding: 2px;
overflow: auto;
border-bottom: 0px;
background-color: white;
height: 1.2em;
resize: none;
border-top: 0px;
height: 1.1em;
}
#chats .chat .panel .text textarea:focus {
border: 0px;
}
#chats .chat .panel .messages .message {
padding: 5px;
word-wrap: break-word;
font-size: 12px;
}
#chats .chat .panel .messages .message.me {
background-color: #FFC;
}
#chats .chat:hover textarea {
display: block;
#chats .chat .panel .messages .message.own {
color: blue;
}
#chats .chat .messages .message span.date {
#chats .chat .panel .messages .message.presence {
color: black;
font-weight: bold;
}
#chats .chat .panel .messages .message span.date {
float: right;
color: #ccc;
padding: 2px;
line-height: 1em;
}
#chats .chat .panel .messages .message.me span.date {
color: #444;
}

26
system/Widget/widgets/Chat/chat.js

@ -21,23 +21,23 @@ function colorTalk(params) {
chat.parentNode.style.backgroundColor = '#DD951F';
}
function showTalk(n) {
panel = n.parentNode.querySelector('.panel');
panel.style.display = 'block';
n.style.display = 'none';
}
function hideTalk(n) {
n.parentNode.style.backgroundColor = '#444';
childs = n.parentNode.childNodes;
messages = childs[0];
text = childs[1];
if(messages.style.display == 'none') {
messages.style.display = 'block';
text.style.display = 'block';
}
else {
messages.style.display = 'none';
text.style.display = 'none';
}
panel = n.parentNode.parentNode.parentNode.querySelector('.panel');
tab = n.parentNode.parentNode.parentNode.querySelector('.tab');
panel.style.display = 'none';
tab.style.display = 'block';
}
function closeTalk(n) {
n.parentNode.parentNode.removeChild(n.parentNode);
n.parentNode.parentNode.parentNode.parentNode.removeChild(n.parentNode.parentNode.parentNode);
}
function scrollTalk(params) {

BIN
system/Widget/widgets/Chat/img/arrow.png

After

Width: 11  |  Height: 11  |  Size: 263 B

2
system/Widget/widgets/Login/login.css

@ -46,6 +46,7 @@
background: linear-gradient(top, #B9D1D6 0%, #547D86 2px, #547D86 32px, #274950 100%);
background: -moz-linear-gradient(top, #B9D1D6 0%, #547D86 2px, #547D86 32px, #274950 100%);
background: -webkit-linear-gradient(top, #B9D1D6 0%, #547D86 2px, #547D86 32px, #274950 100%);
background: -o-linear-gradient(top, #B9D1D6 0%, #547D86 2px, #547D86 32px, #274950 100%);
color: white;
box-shadow: none;
min-width: 130px;
@ -63,6 +64,7 @@
background: linear-gradient(top, #274950 0%, #456C74 2px, #456C74 32px, #6A959F 100%);
background: -moz-linear-gradient(top, #274950 0%, #456C74 2px, #456C74 32px, #6A959F 100%);
background: -webkit-linear-gradient(top, #274950 0%, #456C74 2px, #456C74 32px, #6A959F 100%);
background: -o-linear-gradient(top, #274950 0%, #456C74 2px, #456C74 32px, #6A959F 100%);
background-color: #274950;
}

2
system/Widget/widgets/Roster/roster.css

@ -109,7 +109,7 @@
position: fixed;
bottom: 0;
right: 0;
background-color: #444;
background-color: #242424;
color: white;
height: 21px;
width: 200px;

17
themes/movim/css/posts.css

@ -127,7 +127,6 @@
}
.post .content {
text-align: justify;
margin-left: 65px;
margin-right: 5px;
margin-top: 0.3em;
@ -144,10 +143,24 @@
.post .content i, .post .content em { font-style: italic; }
.post .content b, .post .content strong { font-weight: bold; }
.post .content u, .post .content a { text-decoration: underline; }
.post content a.imglink {
text-decoration: none;
display: none;
}
.post .content img {
margin: 1em 0px;
margin: 10px 5px 0px 5px;
max-width: 100%;
max-height: 300px;
padding: 5px;
border: 1px solid #AAA;
}
.post .content img.smiley {
margin: 0px;
padding: 0px;
border: none;
}
.post .content h1, .post .content h2, .post .content h3, .post .content h4 {

4
themes/movim/css/style2.css

@ -34,6 +34,7 @@ body {
background-image: -moz-radial-gradient(center
45deg, ellipse, #6E9EA8 0%, #274950 100%);
background-image: -webkit-radial-gradient(50% 50%, ellipse, #6E9EA8, #274950);
background-image: -o-radial-gradient(50% 50%, ellipse, #6E9EA8, #274950);
background-repeat: no-repeat;
background-attachment:fixed;
margin: 0 auto;
@ -374,6 +375,9 @@ span#widgettitle {
background-image: -webkit-linear-gradient(top left, rgba(255,255, 255, 0.05) 25%, transparent 25%,
transparent 50%, rgba(255,255, 255, 0.05) 50%, rgba(255,255, 255, 0.05) 75%,
transparent 75%, transparent);
background-image: -o-linear-gradient(top left, rgba(255,255, 255, 0.05) 25%, transparent 25%,
transparent 50%, rgba(255,255, 255, 0.05) 50%, rgba(255,255, 255, 0.05) 75%,
transparent 75%, transparent);
box-shadow: inset 0 -1px 0 rgba(255,255, 255, 0.4);
border: 1px solid;
color: #fff;

Loading…
Cancel
Save