Skip to content

Commit

Permalink
port tgui changelog (shiptest-ss13#1425)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZephyrTFA authored Aug 11, 2022
1 parent a9501d3 commit fa0d9cd
Show file tree
Hide file tree
Showing 11 changed files with 442 additions and 47 deletions.
32 changes: 14 additions & 18 deletions .github/workflows/compile_changelogs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,51 @@ name: Compile changelogs

on:
schedule:
- cron: "0 * * * *"
workflow_dispatch:
- cron: "0 0 * * *"

jobs:
compile:
name: "Compile changelogs"
runs-on: ubuntu-20.04
steps:
- name: "Check for CHANGELOG_ENABLER secret and pass true to output if it exists to be checked by later steps"
- name: "Check for ACTION_ENABLER secret and pass true to output if it exists to be checked by later steps"
id: value_holder
env:
CHANGELOG_ENABLER: ${{ secrets.CHANGELOG_ENABLER }}
ENABLER_SECRET: ${{ secrets.CHANGELOG_ENABLER }}
run: |
unset SECRET_EXISTS
if [ -n $CHANGELOG_ENABLER ]; then SECRET_EXISTS='true' ; fi
echo ::set-output name=CL_ENABLED::${SECRET_EXISTS}
if [ -n "$ENABLER_SECRET" ]; then SECRET_EXISTS=true ; fi
echo "::set-output name=ACTIONS_ENABLED::$SECRET_EXISTS"
- name: "Setup python"
if: steps.value_holder.outputs.CL_ENABLED
if: steps.value_holder.outputs.ACTIONS_ENABLED
uses: actions/setup-python@v1
with:
python-version: "3.9"
python-version: '3.x'
- name: "Install deps"
if: steps.value_holder.outputs.CL_ENABLED
if: steps.value_holder.outputs.ACTIONS_ENABLED
run: |
python -m pip install --upgrade pip
python -m pip install pyyaml
sudo apt-get install dos2unix
- name: "Checkout"
if: steps.value_holder.outputs.CL_ENABLED
if: steps.value_holder.outputs.ACTIONS_ENABLED
uses: actions/checkout@v1
with:
fetch-depth: 25
- name: "Compile"
if: steps.value_holder.outputs.CL_ENABLED
if: steps.value_holder.outputs.ACTIONS_ENABLED
run: |
python tools/changelog/ss13_genchangelog.py html/changelog.html html/changelogs
- name: "Convert Lineendings"
if: steps.value_holder.outputs.CL_ENABLED
run: |
unix2dos html/changelogs/.all_changelog.yml
python tools/ss13_genchangelog.py html/changelogs
- name: Commit
if: steps.value_holder.outputs.CL_ENABLED
if: steps.value_holder.outputs.ACTIONS_ENABLED
run: |
git config --local user.email "[email protected]"
git config --local user.name "Changelogs"
git pull origin master
git add html/changelogs
git commit -m "Automatic changelog compile [ci skip]" -a || true
- name: "Push"
if: steps.value_holder.outputs.CL_ENABLED
if: steps.value_holder.outputs.ACTIONS_ENABLED
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.CHANGELOG_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,4 @@ Temporary Items

# tool-generated files
check_regex_output.txt

2 changes: 1 addition & 1 deletion check_regex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ standards:

- exactly:
[
292,
291,
"non-bitwise << uses",
'(?<!\d)(?<!\d\s)(?<!<)<<(?!=|\s\d|\d|<|\/)',
]
Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ GLOBAL_LIST_INIT(pda_styles, sortList(list(MONO, VT, ORBITRON, SHARE)))

#define INCREMENT_TALLY(L, stat) if(L[stat]){L[stat]++}else{L[stat] = 1}

/// Removes characters incompatible with file names.
#define SANITIZE_FILENAME(text) (GLOB.filename_forbidden_chars.Replace(text, ""))

//TODO Move to a pref
#define STATION_GOAL_BUDGET 1

Expand Down
5 changes: 5 additions & 0 deletions code/_globalvars/regexes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ GLOBAL_DATUM_INIT(is_website, /regex, regex("http|www.|\[a-z0-9_-]+.(com|org|net
GLOBAL_DATUM_INIT(is_email, /regex, regex("\[a-z0-9_-]+@\[a-z0-9_-]+.\[a-z0-9_-]+", "i"))
GLOBAL_DATUM_INIT(is_alphanumeric, /regex, regex("\[a-z0-9]+", "i"))
GLOBAL_DATUM_INIT(is_punctuation, /regex, regex("\[.!?]+", "i"))

//All characters forbidden by filenames: ", \, \n, \t, /, ?, %, *, :, |, <, >, ..
GLOBAL_DATUM_INIT(filename_forbidden_chars, /regex, regex(@{""|[\\\n\t/?%*:|<>]|\.\."}, "g"))
GLOBAL_PROTECT(filename_forbidden_chars)
// had to use the OR operator for quotes instead of putting them in the character class because it breaks the syntax highlighting otherwise.
52 changes: 52 additions & 0 deletions code/datums/changelog.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
GLOBAL_DATUM(changelog_tgui, /datum/changelog)

/datum/changelog
var/static/list/changelog_items = list()

/datum/changelog/ui_state()
return GLOB.always_state

/datum/changelog/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if (!ui)
ui = new(user, src, "Changelog")
ui.open()

/datum/changelog/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
if(action == "get_month")
var/datum/asset/changelog_item/changelog_item = changelog_items[params["date"]]
if (!changelog_item)
changelog_item = new /datum/asset/changelog_item(params["date"])
changelog_items[params["date"]] = changelog_item
return ui.send_asset(changelog_item)

/datum/changelog/ui_static_data()
var/list/data = list( "dates" = list() )
var/regex/ymlRegex = regex(@"\.yml", "g")

for(var/archive_file in sortList(flist("html/changelogs/archive/")))
var/archive_date = ymlRegex.Replace(archive_file, "")
data["dates"] = list(archive_date) + data["dates"]

return data

/datum/asset/changelog_item
_abstract = /datum/asset/changelog_item
var/item_filename

/datum/asset/changelog_item/New(date)
item_filename = SANITIZE_FILENAME("[date].yml")
SSassets.transport.register_asset(item_filename, file("html/changelogs/archive/" + item_filename))

/datum/asset/changelog_item/send(client)
if (!item_filename)
return
. = SSassets.transport.send_assets(client, item_filename)

/datum/asset/changelog_item/get_url_mappings()
if (!item_filename)
return
. = list("[item_filename]" = SSassets.transport.get_asset_url(item_filename))
3 changes: 2 additions & 1 deletion code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ GLOBAL_VAR(restart_counter)
start_log(GLOB.tgui_log)
start_log(GLOB.world_shuttle_log)

GLOB.changelog_hash = md5('html/changelog.html') //for telling if the changelog has changed recently
var/latest_changelog = file("[global.config.directory]/../html/changelogs/archive/" + time2text(world.timeofday, "YYYY-MM") + ".yml")
GLOB.changelog_hash = fexists(latest_changelog) ? md5(latest_changelog) : 0 //for telling if the changelog has changed recently
if(fexists(GLOB.config_error_log))
fcopy(GLOB.config_error_log, "[GLOB.log_directory]/config_error.log")
fdel(GLOB.config_error_log)
Expand Down
24 changes: 0 additions & 24 deletions code/modules/asset_cache/asset_list_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,30 +121,6 @@
/datum/asset/simple/IRV
)

/datum/asset/simple/namespaced/changelog
assets = list(
"88x31.png" = 'html/88x31.png',
"bug-minus.png" = 'html/bug-minus.png',
"cross-circle.png" = 'html/cross-circle.png',
"hard-hat-exclamation.png" = 'html/hard-hat-exclamation.png',
"image-minus.png" = 'html/image-minus.png',
"image-plus.png" = 'html/image-plus.png',
"music-minus.png" = 'html/music-minus.png',
"music-plus.png" = 'html/music-plus.png',
"tick-circle.png" = 'html/tick-circle.png',
"wrench-screwdriver.png" = 'html/wrench-screwdriver.png',
"spell-check.png" = 'html/spell-check.png',
"burn-exclamation.png" = 'html/burn-exclamation.png',
"chevron.png" = 'html/chevron.png',
"chevron-expand.png" = 'html/chevron-expand.png',
"scales.png" = 'html/scales.png',
"coding.png" = 'html/coding.png',
"ban.png" = 'html/ban.png',
"chrome-wrench.png" = 'html/chrome-wrench.png',
"changelog.css" = 'html/changelog.css'
)
parents = list("changelog.html" = 'html/changelog.html')

/datum/asset/simple/jquery
legacy = TRUE
assets = list(
Expand Down
7 changes: 4 additions & 3 deletions interface/interface.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@
/client/verb/changelog()
set name = "Changelog"
set category = "OOC"
var/datum/asset/simple/namespaced/changelog = get_asset_datum(/datum/asset/simple/namespaced/changelog)
changelog.send(src)
src << browse(changelog.get_htmlloader("changelog.html"), "window=changes;size=675x650")
if(!GLOB.changelog_tgui)
GLOB.changelog_tgui = new /datum/changelog()

GLOB.changelog_tgui.ui_interact(mob)
if(prefs.lastchangelog != GLOB.changelog_hash)
prefs.lastchangelog = GLOB.changelog_hash
prefs.save_preferences()
Expand Down
1 change: 1 addition & 0 deletions shiptest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@
#include "code\datums\beam.dm"
#include "code\datums\browser.dm"
#include "code\datums\callback.dm"
#include "code\datums\changelog.dm"
#include "code\datums\chatmessage.dm"
#include "code\datums\cinematic.dm"
#include "code\datums\dash_weapon.dm"
Expand Down
Loading

0 comments on commit fa0d9cd

Please sign in to comment.