diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml new file mode 100644 index 0000000..1ea6fd9 --- /dev/null +++ b/.github/workflows/cleanup.yml @@ -0,0 +1,28 @@ +name: Cleanup Preview + +on: + pull_request: + types: [closed] + +permissions: + contents: write + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: gh-pages + + - name: Remove preview directory + run: | + if [ -d "preview/pr-${{ github.event.number }}" ]; then + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git rm -rf "preview/pr-${{ github.event.number }}" + git commit -m "Remove preview for PR #${{ github.event.number }}" + git push + else + echo "No preview directory found, skipping." + fi diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..e38c536 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,28 @@ +name: Deploy + +on: + push: + branches: [main] + +permissions: + contents: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.1' + bundler-cache: true + + - name: Build site + run: bundle exec jekyll build + + - name: Deploy to gh-pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000..82ce5cf --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,63 @@ +name: PR Preview + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: write + pull-requests: write + +jobs: + preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.1' + bundler-cache: true + + - name: Build preview + run: bundle exec jekyll build --baseurl "/preview/pr-${{ github.event.number }}" + + - name: Deploy preview to gh-pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site + destination_dir: preview/pr-${{ github.event.number }} + + - name: Post preview comment + uses: actions/github-script@v7 + with: + script: | + const url = `https://mpc-deadlines.github.io/preview/pr-${{ github.event.number }}/`; + const body = `## Preview deployed\n\nšŸ” **${url}**\n\n_Updates automatically on each push to this PR._`; + + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + + const existing = comments.find(c => + c.user.type === 'Bot' && c.body.includes('Preview deployed') + ); + + if (existing) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body, + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body, + }); + } diff --git a/.gitignore b/.gitignore index 9258ee9..d58eeca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .DS_Store static/.DS_Store -static/.DS_Store .phcode.json +_site/ +.bundle/ +.jekyll-cache/ diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..e7ca5f0 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" +gem "jekyll", "~> 4.2" +gem "webrick" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..e6824a6 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,85 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.9.0) + public_suffix (>= 2.0.2, < 8.0) + base64 (0.3.0) + bigdecimal (4.1.2) + colorator (1.1.0) + concurrent-ruby (1.3.6) + csv (3.3.5) + em-websocket (0.5.3) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0) + eventmachine (1.2.7) + ffi (1.17.4-x86_64-linux-musl) + forwardable-extended (2.6.0) + google-protobuf (4.34.1-x86_64-linux-musl) + bigdecimal + rake (~> 13.3) + http_parser.rb (0.8.1) + i18n (1.14.8) + concurrent-ruby (~> 1.0) + jekyll (4.4.1) + addressable (~> 2.4) + base64 (~> 0.2) + colorator (~> 1.0) + csv (~> 3.0) + em-websocket (~> 0.5) + i18n (~> 1.0) + jekyll-sass-converter (>= 2.0, < 4.0) + jekyll-watch (~> 2.0) + json (~> 2.6) + kramdown (~> 2.3, >= 2.3.1) + kramdown-parser-gfm (~> 1.0) + liquid (~> 4.0) + mercenary (~> 0.3, >= 0.3.6) + pathutil (~> 0.9) + rouge (>= 3.0, < 5.0) + safe_yaml (~> 1.0) + terminal-table (>= 1.8, < 4.0) + webrick (~> 1.7) + jekyll-sass-converter (3.1.0) + sass-embedded (~> 1.75) + jekyll-watch (2.2.1) + listen (~> 3.0) + json (2.19.5) + kramdown (2.5.2) + rexml (>= 3.4.4) + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + liquid (4.0.4) + listen (3.10.0) + logger + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + logger (1.7.0) + mercenary (0.4.0) + pathutil (0.16.2) + forwardable-extended (~> 2.6) + public_suffix (6.0.2) + rake (13.4.2) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rexml (3.4.4) + rouge (4.7.0) + safe_yaml (1.0.5) + sass-embedded (1.99.0) + google-protobuf (~> 4.31) + rake (>= 13) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + unicode-display_width (2.6.0) + webrick (1.9.2) + +PLATFORMS + x86_64-linux + x86_64-linux-musl + +DEPENDENCIES + jekyll (~> 4.2) + webrick + +BUNDLED WITH + 2.3.25 diff --git a/index.html b/index.html index 263597f..2d88fb0 100644 --- a/index.html +++ b/index.html @@ -94,6 +94,10 @@

+    + Sort by: + +
@@ -110,7 +114,7 @@

{% assign conf_type = conf.tags | join: "-" | slugify %} {% assign conf_id = conf.name | append: conf.year | append: '-' | append: conf_type | append: '-' | append: i | slugify %} -
+
{{conf.name}} {{conf.year}} diff --git a/static/css/styles.css b/static/css/styles.css index 1d18f95..3247225 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -9,4 +9,16 @@ h2 .evtname { .past { opacity: 0.5; +} + +.sort-label { + margin-left: 10px; + margin-right: 5px; + vertical-align: middle; +} + +.sort-btn.active-sort { + background-color: #337ab7; + color: #fff; + border-color: #2e6da4; } \ No newline at end of file diff --git a/static/js/main.js b/static/js/main.js index f054aa3..56f31a0 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -82,39 +82,59 @@ $(function() { // Reorder list var today = moment(); - var confs = $('.conf').detach(); - - confs.sort(function(a, b) { - var aDeadline = deadlineByConf[a.id]; - var bDeadline = deadlineByConf[b.id]; - var aDiff = today.diff(aDeadline); - var bDiff = today.diff(bDeadline); - if (aDiff < 0 && bDiff > 0) { - return -1; - } - if (aDiff > 0 && bDiff < 0) { - return 1; - } - return bDiff - aDiff; - }); - - var pastConfs = []; - var upcomingConfs = []; - - confs.each(function() { - var conf = $(this); - if (conf.hasClass("past")) { - pastConfs.push(conf); + function getEventStartDate(confEl) { + var dateStr = $(confEl).data('conf-date'); + var year = $(confEl).data('conf-year'); + if (!dateStr || String(dateStr).toLowerCase().indexOf('tba') === 0) return null; + // Handle "June 29 - July 03" → "June 29"; handle "November 15-19" → "November 15" + var firstPart = String(dateStr).split(' - ')[0].replace(/-\d+$/, '').trim(); + var parsed = moment(firstPart + ' ' + year, 'MMMM D YYYY'); + return parsed.isValid() ? parsed : null; + } + + function renderConfs(sortMode) { + var confs = $('.conf-container .conf, #past-events-list .conf').detach(); + + if (sortMode === 'event-date') { + confs.sort(function(a, b) { + var aDate = getEventStartDate(a); + var bDate = getEventStartDate(b); + if (!aDate && !bDate) return 0; + if (!aDate) return 1; + if (!bDate) return -1; + return aDate.diff(bDate); + }); } else { - upcomingConfs.push(conf); + confs.sort(function(a, b) { + var aDeadline = deadlineByConf[a.id]; + var bDeadline = deadlineByConf[b.id]; + var aDiff = today.diff(aDeadline); + var bDiff = today.diff(bDeadline); + if (aDiff < 0 && bDiff > 0) return -1; + if (aDiff > 0 && bDiff < 0) return 1; + return bDiff - aDiff; + }); } - }); - - //$('.conf-container').append(confs); - $('.conf-container').append(upcomingConfs); - $('#past-events-list').append(pastConfs); - + + var pastConfs = []; + var upcomingConfs = []; + confs.each(function() { + ($(this).hasClass('past') ? pastConfs : upcomingConfs).push(this); + }); + + $('.conf-container').append(upcomingConfs); + $('#past-events-list').append(pastConfs); + } + + renderConfs('deadline'); + + $('.sort-btn').click(function() { + $('.sort-btn').removeClass('active-sort'); + $(this).addClass('active-sort'); + renderConfs($(this).data('sort')); + }); + // Toggle past events visibility $(".past-deadlines").click(function() { $("#past-events-list").slideToggle();