Skip to content

Commit

Permalink
Merge pull request #772 from arnavkagrawal/chat
Browse files Browse the repository at this point in the history
Sahana Eden Chat
  • Loading branch information
flavour committed May 29, 2014
2 parents dff1c69 + 87f4cb3 commit f217937
Show file tree
Hide file tree
Showing 11 changed files with 1,501 additions and 0 deletions.
Empty file added cron/crontab
Empty file.
6 changes: 6 additions & 0 deletions modules/s3cfg.py
Expand Up @@ -132,6 +132,12 @@ def get_template(self):
"""
return self.base.get("template", "default")

def get_chat_server(self):
"""
Get the ip of the chat server if enabled or return False
"""
return self.base.get("chat_server", False)

def exec_template(self, path):
"""
Execute the template
Expand Down
4 changes: 4 additions & 0 deletions private/templates/000_config.py
Expand Up @@ -25,6 +25,10 @@
# - note that you should restart your web2py after changing this setting
settings.base.template = "default"

# Enable Disable Chat Module
# Enter ip of the chat sever, refer http://eden.sahanafoundation.org/wiki/InstallationGuidelines/Chat
#settings.base.chat_server = "127.0.0.1:7070"

# Database settings
# Uncomment to use a different database, other than sqlite
#settings.database.db_type = "postgres"
Expand Down
15 changes: 15 additions & 0 deletions static/scripts/S3/s3.chat.js
@@ -0,0 +1,15 @@
require(['converse'], function (converse) {
converse.initialize({
allow_otr: true,
auto_list_rooms: true,
auto_subscribe: false,
bosh_service_url: S3.chat_url,
debug: true ,
hide_muc_server: false,
i18n: locales['en'],
prebind: false,
show_controlbox_by_default: true,
xhr_user_search: false,
});
});

163 changes: 163 additions & 0 deletions static/scripts/converse.min.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions static/scripts/tools/build.sahana.py
Expand Up @@ -262,6 +262,22 @@ def dojs(dogis = False, warnings = True):
pass
shutil.move(outputFilename, "../S3")

# Chat
print "Compressing Chat"
sourceDirectory = ".."
configFilename = "sahana.chat.js.cfg"
outputFilename = "s3.chat.min.js"
merged = mergejs.run(sourceDirectory,
None,
configFilename)
minimized = minimize(merged)
open(outputFilename, "w").write(minimized)
try:
os.remove("../S3/%s" % outputFilename)
except:
pass
shutil.move(outputFilename, "../S3")

# Guided Tour
print "Compressing Guided Tour"
sourceDirectory = ".."
Expand Down
9 changes: 9 additions & 0 deletions static/scripts/tools/sahana.chat.js.cfg
@@ -0,0 +1,9 @@
[first]
converse.min.js

[last]

[include]
S3/s3.chat.js

[exclude]
1,262 changes: 1,262 additions & 0 deletions static/styles/plugins/converse.css

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions static/styles/plugins/converse.min.css

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions views/chat.html
@@ -0,0 +1,13 @@
{{chat_server = settings.get_chat_server()}}
{{if chat_server:}}
{{if s3.debug:}}
{{main_css = "<link href='/%s/static/styles/plugins/converse.css' rel='stylesheet' type='text/css'/>" % appname}}
{{s3.scripts.append(URL(c="static", f="scripts", args=["converse.min.js"]))}}
{{s3.scripts.append(URL(c="static", f="scripts", args=["S3", "s3.chat.js"]))}}
{{else:}}
{{main_css = "<link href='/%s/static/styles/plugins/converse.min.css' rel='stylesheet' type='text/css'/>" % appname}}
{{s3.scripts.append(URL(c="static", f="scripts", args=["S3", "s3.chat.min.js"]))}}
{{pass}}
{{s3.js_global.append('''S3.chat_url="%s"\n$('link:first').before("%s")''' % ("http://"+str(chat_server+"/http-bind/"),main_css))}}
<div id="conversejs"></div>
{{pass}}
1 change: 1 addition & 0 deletions views/scripts.html
@@ -1,4 +1,5 @@
{{# Include dynamically added Scripts at the end of the body}}
{{include "chat.html"}}
{{for script in s3.scripts:}}
{{=SCRIPT(_src=script)}}
{{pass}}
Expand Down

0 comments on commit f217937

Please sign in to comment.