Ejemplo n.º 1
0
def index():
  join_channel = request.args.get("channel")
  if join_channel:
    g.user["last_selected_channel"] = join_channel
    add_user_to_channel(g.user, join_channel)

  channels = g.user["channels"]

  last_selected_channel = g.user["last_selected_channel"]
  username = g.user["email"].split("@")[0]

  right_sidebar_closed = (request.args.get("rightSidebar") or request.cookies.get("rightSidebar")) == "closed"
  left_sidebar_closed = (request.args.get("leftSidebar") or request.cookies.get("leftSidebar")) == "closed"

  context = {
    "username": username,
    "email": g.user["email"],
    "channels": channels,
    "last_selected_channel": last_selected_channel,
    "right_sidebar_closed": right_sidebar_closed,
    "left_sidebar_closed": left_sidebar_closed,
    "preferences": get_user_preferences(g.user),
    "imgur_client_id": current_app.config["IMGUR_CLIENT_ID"],
    "collapse_time_window": current_app.config["COLLAPSED_MESSAGE_TIME_WINDOW"],
    "name": current_app.config["APP_NAME"],
    "websocket_keep_alive_interval": current_app.config["WEBSOCKET_KEEP_ALIVE_INTERVAL"],
  }

  if current_app.config["REWRITE_MAIN_TEMPLATE"]:
    write_main_template()
  headers = {
    "Cache-Control": "no-store",
  }

  return (render_square_bracket_template("index.htmljinja", { "initial": context }), 200, headers)
Ejemplo n.º 2
0
def index():
  join_channel = request.args.get("channel")
  if join_channel:
    g.user["last_selected_channel"] = join_channel
    add_user_to_channel(g.user, join_channel)

  channels = g.user["channels"]

  last_selected_channel = g.user["last_selected_channel"]
  username = g.user["email"].split("@")[0]

  right_sidebar_closed = (request.args.get("rightSidebar") or request.cookies.get("rightSidebar")) == "closed"
  left_sidebar_closed = (request.args.get("leftSidebar") or request.cookies.get("leftSidebar")) == "closed"

  context = {
    "username": username,
    "email": g.user["email"],
    "channels": channels,
    "last_selected_channel": last_selected_channel,
    "right_sidebar_closed": right_sidebar_closed,
    "left_sidebar_closed": left_sidebar_closed,
    "preferences": get_user_preferences(g.user),
  }

  if current_app.config["REWRITE_MAIN_TEMPLATE"]:
    write_main_template()

  return render_square_bracket_template("index.htmljinja", context)
Ejemplo n.º 3
0
def index():
    join_channel = request.args.get("channel")
    if join_channel:
        g.user["last_selected_channel"] = join_channel
        add_user_to_channel(g.user, join_channel)

    channels = g.user["channels"]

    last_selected_channel = g.user["last_selected_channel"]
    username = g.user["email"].split("@")[0]

    right_sidebar_closed = (request.args.get("rightSidebar")
                            or request.cookies.get("rightSidebar")) == "closed"
    left_sidebar_closed = (request.args.get("leftSidebar")
                           or request.cookies.get("leftSidebar")) == "closed"

    context = {
        "username": username,
        "email": g.user["email"],
        "channels": channels,
        "last_selected_channel": last_selected_channel,
        "right_sidebar_closed": right_sidebar_closed,
        "left_sidebar_closed": left_sidebar_closed,
        "preferences": get_user_preferences(g.user),
    }

    if current_app.config["REWRITE_MAIN_TEMPLATE"]:
        write_main_template()
    headers = {
        "Cache-Control": "no-store",
    }

    return (render_square_bracket_template("index.htmljinja",
                                           context), 200, headers)
Ejemplo n.º 4
0
Archivo: api.py Proyecto: ytamura/prat
def user_preferences():
    if request.method == "PATCH":
        try:
            new_preferences = json.loads(request.data)
        except ValueError:
            return "Could not parse JSON", 400
        try:
            return json.dumps(update_user_preferences(g.user, new_preferences))
        except InvalidDocument as e:
            return 400, "Invalid Document: {0}".format(e.message)
    elif request.method == "GET":
        return json.dumps(get_user_preferences(g.user))
Ejemplo n.º 5
0
Archivo: api.py Proyecto: bkad/prat
def user_preferences():
    if request.method == "PATCH":
        try:
            new_preferences = json.loads(request.data)
        except ValueError:
            return "Could not parse JSON", 400
        try:
            return json.dumps(update_user_preferences(g.user, new_preferences))
        except InvalidDocument as e:
            return 400, "Invalid Document: {0}".format(e.message)
    elif request.method == "GET":
        return json.dumps(get_user_preferences(g.user))