Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "slack-export-viewer"
version = "3.5.0"
description = "Slack Export Archive Viewer"
authors = ["hfaran <hamzafaran@outlook.com>"]
authors = ["hfaran"]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/hfaran/slack-export-viewer"
Expand All @@ -12,11 +12,11 @@ packages = [{include = "slackviewer"}]
[tool.poetry.dependencies]
python = ">=3.12"
click = "*"
Werkzeug = "<3.0.0"
Flask = "<3.0.0"
Werkzeug = ">=3.0.0"
Flask = ">=3.0.0"
markdown2 = "*"
emoji = ">=2.0.0,<3.0"
frozen-flask = ">=1.0.1,<2.0"
frozen-flask = ">=1.0.1"

[tool.poetry.group.dev.dependencies]
pypandoc = "*"
Expand Down
56 changes: 28 additions & 28 deletions slackviewer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def read_css_file(file_path):

@app.route("/channel/<name>/")
def channel_name(name):
messages = flask._app_ctx_stack.channels[name]
channels = list(flask._app_ctx_stack.channels.keys())
groups = list(flask._app_ctx_stack.groups.keys()) if flask._app_ctx_stack.groups else {}
dm_users = list(flask._app_ctx_stack.dm_users)
mpim_users = list(flask._app_ctx_stack.mpim_users)
messages = app.channels[name]
channels = list(app.channels.keys())
groups = list(app.groups.keys()) if app.groups else {}
dm_users = list(app.dm_users)
mpim_users = list(app.mpim_users)

viewer_css_contents = read_css_file(os.path.join(app.static_folder, 'viewer.css')) if app.no_external_references else None

Expand All @@ -36,16 +36,16 @@ def channel_name(name):

@app.route("/channel/<name>/attachments/<attachment>")
def channel_name_attachment(name, attachment):
return flask.send_file(os.path.join(flask._app_ctx_stack.path, name, "attachments", attachment))
return flask.send_file(os.path.join(app.slack_path, name, "attachments", attachment))


@app.route("/group/<name>/")
def group_name(name):
messages = flask._app_ctx_stack.groups[name]
channels = list(flask._app_ctx_stack.channels.keys())
groups = list(flask._app_ctx_stack.groups.keys())
dm_users = list(flask._app_ctx_stack.dm_users)
mpim_users = list(flask._app_ctx_stack.mpim_users)
messages = app.groups[name]
channels = list(app.channels.keys())
groups = list(app.groups.keys())
dm_users = list(app.dm_users)
mpim_users = list(app.mpim_users)

viewer_css_contents = read_css_file(os.path.join(app.static_folder, 'viewer.css')) if app.no_external_references else None

Expand All @@ -62,16 +62,16 @@ def group_name(name):

@app.route("/group/<name>/attachments/<attachment>")
def group_name_attachment(name, attachment):
return flask.send_file(os.path.join(flask._app_ctx_stack.path, name, "attachments", attachment))
return flask.send_file(os.path.join(app.slack_path, name, "attachments", attachment))


@app.route("/dm/<id>/")
def dm_id(id):
messages = flask._app_ctx_stack.dms[id]
channels = list(flask._app_ctx_stack.channels.keys())
groups = list(flask._app_ctx_stack.groups.keys())
dm_users = list(flask._app_ctx_stack.dm_users)
mpim_users = list(flask._app_ctx_stack.mpim_users)
messages = app.dms[id]
channels = list(app.channels.keys())
groups = list(app.groups.keys())
dm_users = list(app.dm_users)
mpim_users = list(app.mpim_users)

viewer_css_contents = read_css_file(os.path.join(app.static_folder, 'viewer.css')) if app.no_external_references else None

Expand All @@ -88,16 +88,16 @@ def dm_id(id):

@app.route("/dm/<name>/attachments/<attachment>")
def dm_name_attachment(name, attachment):
return flask.send_file(os.path.join(flask._app_ctx_stack.path, name, "attachments", attachment))
return flask.send_file(os.path.join(app.slack_path, name, "attachments", attachment))


@app.route("/mpim/<name>/")
def mpim_name(name):
messages = flask._app_ctx_stack.mpims.get(name, list())
channels = list(flask._app_ctx_stack.channels.keys())
groups = list(flask._app_ctx_stack.groups.keys())
dm_users = list(flask._app_ctx_stack.dm_users)
mpim_users = list(flask._app_ctx_stack.mpim_users)
messages = app.mpims.get(name, list())
channels = list(app.channels.keys())
groups = list(app.groups.keys())
dm_users = list(app.dm_users)
mpim_users = list(app.mpim_users)

viewer_css_contents = read_css_file(os.path.join(app.static_folder, 'viewer.css')) if app.no_external_references else None

Expand All @@ -114,15 +114,15 @@ def mpim_name(name):

@app.route("/mpim/<name>/attachments/<attachment>")
def mpim_name_attachment(name, attachment):
return flask.send_file(os.path.join(flask._app_ctx_stack.path, name, "attachments", attachment))
return flask.send_file(os.path.join(app.slack_path, name, "attachments", attachment))


@app.route("/")
def index():
channels = list(flask._app_ctx_stack.channels.keys())
groups = list(flask._app_ctx_stack.groups.keys())
dms = list(flask._app_ctx_stack.dms.keys())
mpims = list(flask._app_ctx_stack.mpims.keys())
channels = list(app.channels.keys())
groups = list(app.groups.keys())
dms = list(app.dms.keys())
mpims = list(app.mpims.keys())
if channels:
if "general" in channels:
return channel_name("general")
Expand Down
30 changes: 14 additions & 16 deletions slackviewer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os

import click
import flask

from slackviewer.app import app
from slackviewer.config import Config
Expand All @@ -20,26 +19,25 @@ def configure_app(app, config):

reader = Reader(config)

top = flask._app_ctx_stack
top.path = reader.archive_path()
top.channels = reader.compile_channels(config.channels)
top.groups = reader.compile_groups()
top.dms = {}
top.dm_users = []
top.mpims = {}
top.mpim_users = []
app.slack_path = reader.archive_path()
app.channels = reader.compile_channels(config.channels)
app.groups = reader.compile_groups()
app.dms = {}
app.dm_users = []
app.mpims = {}
app.mpim_users = []
if config.show_dms:
top.dms = reader.compile_dm_messages()
top.dm_users = reader.compile_dm_users()
top.mpims = reader.compile_mpim_messages()
top.mpim_users = reader.compile_mpim_users()
app.dms = reader.compile_dm_messages()
app.dm_users = reader.compile_dm_users()
app.mpims = reader.compile_mpim_messages()
app.mpim_users = reader.compile_mpim_users()

reader.warn_not_found_to_hide_channels()

# remove any empty channels & groups. DM's are needed for now
# since the application loads the first
top.channels = {k: v for k, v in top.channels.items() if v}
top.groups = {k: v for k, v in top.groups.items() if v}
app.channels = {k: v for k, v in app.channels.items() if v}
app.groups = {k: v for k, v in app.groups.items() if v}


@click.command()
Expand Down Expand Up @@ -126,7 +124,7 @@ def main(**kwargs):
# This tells freezer about the channel URLs
@freezer.register_generator
def channel_name():
for channel in flask._app_ctx_stack.channels:
for channel in app.channels:
yield {"name": channel}

freezer.freeze()
Expand Down
Loading