# Path: bnw/core/base.py
# def get_webui_base(user):
#     """Get base url for links in accordance with baseurl user setting.
#     baseurl can be one of:
#         "http": return http base url
#         "https": return https base url
#         "random string": return this string
#         None: return http base url
#     """
#     baseurl = user.get('settings', {}).get('baseurl', None) if user else None
#     if not baseurl:
#         return get_http_webui_base()
#     else:
#         if baseurl == 'http':
#             return get_http_webui_base()
#         elif baseurl == 'https':
#             return get_https_webui_base()
#         else:
#             return baseurl


import datetime
from bnw.core.base import get_webui_base
    'comment': None,
    'message': None,
    'recommendation': None,
    'message_with_replies': None,
    'messages': None,
}


def format_message(request, msg, short=False):
    result = ('@%(author)s: %(tags)s %(clubs)s\n%(text)s\n' + ('\n' if not short else '') + '#%(id)s (%(rc)d) %(web)s/p/%(id)s') % \
        {'id': msg['id'].upper(),
         'author': msg['user'],
         'tags': ' '.join('*' + tag for tag in msg['tags']),
         'clubs': ' '.join('!' + tag for tag in msg['clubs']),
         'rc': msg['replycount'],
         'text': msg['text'],
         'web': get_webui_base(request.user),
         }
    return result


def format_comment(request, msg, short=False):
    args = {'id': msg['id'].split('/')[1].upper(),
            'author': msg['user'],
            'message': msg['message'].upper(),
            'replyto': msg['replyto'],
            'replytotext': msg['replytotext'],
            'rc': msg.get('num', -1),
            'text': msg['text'],
            'date': datetime.datetime.utcfromtimestamp(msg['date']).strftime('%d.%m.%Y %H:%M:%S'),

# Path: bnw/core/base.py
# def get_webui_base(user):
#     """Get base url for links in accordance with baseurl user setting.
#     baseurl can be one of:
#         "http": return http base url
#         "https": return https base url
#         "random string": return this string
#         None: return http base url
#     """
#     baseurl = user.get('settings', {}).get('baseurl', None) if user else None
#     if not baseurl:
#         return get_http_webui_base()
#     else:
#         if baseurl == 'http':
#             return get_http_webui_base()
#         elif baseurl == 'https':
#             return get_https_webui_base()
#         else:
#             return baseurl


# Path: bnw/xmpp/formatters_simple.py
import datetime
from bnw.core.base import get_webui_base

    'comment': None,
    'message': None,
    'recommendation': None,
    'message_with_replies': None,
    'messages': None,
}


def format_message(request, msg, short=False):
    result = ('@%(author)s: %(tags)s %(clubs)s\n%(text)s\n' + ('\n' if not short else '') + '#%(id)s (%(rc)d) %(web)s/p/%(id)s') % \
        {'id': msg['id'].upper(),
         'author': msg['user'],
         'tags': ' '.join('*' + tag for tag in msg['tags']),
         'clubs': ' '.join('!' + tag for tag in msg['clubs']),
         'rc': msg['replycount'],
         'text': msg['text'],
         'web': get_webui_base(request.user),
         }
    return result


def format_comment(request, msg, short=False):
    args = {'id': msg['id'].split('/')[1].upper(),
            'author': msg['user'],
            'message': msg['message'].upper(),
            'replyto': msg['replyto'],
            'replytotext': msg['replytotext'],
            'rc': msg.get('num', -1),
            'text': msg['text'],
            'date': datetime.datetime.utcfromtimestamp(msg['date']).strftime('%d.%m.%Y %H:%M:%S'),

            'web': get_webui_base(request.user),