Skip to content

Commit

Permalink
maint: remove obsolete CI/maint and re-implement source index
Browse files Browse the repository at this point in the history
Signed-off-by: Yury V. Zaytsev <[email protected]>
  • Loading branch information
zyv committed Oct 20, 2024
1 parent 3e64bd0 commit 7783fca
Show file tree
Hide file tree
Showing 28 changed files with 228 additions and 275 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/update-sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: update-sources

on:
push:
branches:
- master

jobs:
update-sources:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install GNU Global
run: sudo apt-get install -y global exuberant-ctags python3-pygments

- name: Checkout source repo
uses: actions/checkout@v4
with:
repository: MidnightCommander/source
path: HTML
ref: gh-pages
ssh-key: ${{ secrets.SOURCE_DEPLOY_KEY }}

- name: Create sources index
run: |
pushd HTML
git rm -rf *
popd
gtags
htags --suggest -t "Welcome to the Midnight Commander source tour!"
./maint/htagsfix
- name: Deploy to GitHub
run: |
cd HTML
touch .nojekyll
echo "source.midnight-commander.org" > CNAME
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add .
git commit -m "Deploy to GitHub Pages"
git push --force-with-lease
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

File renamed without changes.
4 changes: 0 additions & 4 deletions maint/docs/COMMIT_PROCEDURE

This file was deleted.

7 changes: 0 additions & 7 deletions maint/docs/README

This file was deleted.

9 changes: 0 additions & 9 deletions maint/docs/systems.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
180 changes: 180 additions & 0 deletions maint/htagsfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
#!/usr/bin/env ruby

#
# Fixes htags' output so that files have fixed names. E.g., S/542.html -> D/whatever.c.h.
#
# It addresses the following problem:
#
# "Can htags create permanent addresses?"
# http://lists.gnu.org/archive/html/help-global/2015-11/msg00002.html
#

require 'fileutils'
require 'pp'

Encoding.default_external = "BINARY"

$base = '.' # Where the HTML is stored.
$verbose = false
$debug = false
$create_subdirs = false # Experimental feature. Doesn't really work.

# Bonus: highlight the target line.
$css = "
a:target {
position: absolute;
left: 0;
height: 1.35em;
width: 100%;
background: yellow;
opacity: .5;
z-index: -1000;
}
"

#
# Computes pretty names for files:
#
# '.../S/456.html' => 'S/modules/tty.c.html'
#
def prettyname(full_path, prefix, kind, nid, ext)
gist = nid
start = IO.read(full_path, 1024)
if start =~ /<title>(.*?)<\/title>/ then
gist = $1
gist.gsub!(%r{/+$}, '') # remove trailing '/'s.
if not $create_subdirs then
gist.gsub!('/', '--')
end
gist.gsub!(%r{[^a-zA-Z0-9_.,/-]}, '-') # clean special characters.
end
return kind + '/' + gist + ext
end

class Counter
class << self
def init(total)
@total = total
end
def reset()
@count = 0
end
def report()
print "[#{@count}/#{@total}]\r"
@count += 1
end
def finish()
puts
end
end
end

#
# Returns a table explaining how to rename the files. E.g.:
#
# {
# 'S/456.html' => 'S/modules/tty.c.html'
# ...
# }
#
def build_cnv_tbl()
Counter.reset()
cnv = {}
Dir[$base + '/{[A-Z],files}/*.html'].each do |full_path|
#p full_path
if full_path =~ /(.*)\/((\w+)\/(\d+)(\.\w+))$/ then
prefix = $1 # "/home/joe/.../HTML"
path = $2 # "S/323.html"
kind = $3 # "S"
nid = $4 # "323"
ext = $5 # ".html"
pretty = prettyname(full_path, prefix, kind, nid, ext)
cnv[path] = pretty
end
Counter.report()
end
Counter.finish()
return cnv
end

#
# Make all the substiutions inside the files:
#
# <a href='../S/456.html'> --> <a href='../S/modules/tty.c.html'>
# ...
#
def mksub(cnv)
Counter.reset()
Dir[$base + '/**/*.html'].each do |path|
kind = path[$base.length .. -1][/\w+/]
text = IO.read(path)
fixed = text.gsub(/(<a href='(?:..\/)?)([^'#]+)/) do |a|
prefix = $1
target = $2
if cnv[target] then
target = cnv[target]
elsif cnv[kind + '/' + target] then
# This is a relative link of the form: href='456.html'
if cnv[kind + '/' + target].match /\/(.*)/ # converts "s/whatever.html" to "whatever.html"
target = $1
end
end
prefix + target
end

# Fix a problem in Opera, where empty lines are squashed.
fixed.gsub!(%r{(<a id='L\d+' name='L\d+'></a>)\n}, "\\1 \n")

if text != fixed then
IO.write(path, fixed)
puts(path + " modified") if $debug
end
Counter.report()
end
Counter.finish()
end

#
# Rename the files.
#
def rename(cnv)
Counter.reset()
cnv.each do |a, b|
src = $base + '/' + a
trg = $base + '/' + b
if $create_subdirs then
FileUtils.mkdir_p(File.dirname(trg))
end
File.rename(src, trg)
Counter.report()
end
Counter.finish()
end

def better_css(css_path)
text = IO.read(css_path)
IO.write(css_path, text + $css)
end

def main()
if not File.exists?($base + '/help.html') then
$base += '/HTML'
if not File.exists?($base + '/help.html') then
puts "Error: This doesn't look like htags' output directory."
exit(1)
end
end
Counter.init( Dir[$base + '/**/*.html'].length )
puts "Figuring out pretty names..."
cnv = build_cnv_tbl()
pp cnv if $verbose
puts "Updating links in files..."
mksub(cnv)
puts "Renaming files..."
rename(cnv)
puts "Enhancing the css..."
better_css($base + '/style.css')
puts "Done."
end

main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
47 changes: 0 additions & 47 deletions maint/utils/check-indent.sh

This file was deleted.

Binary file removed maint/utils/deploy-key.enc
Binary file not shown.
1 change: 0 additions & 1 deletion maint/utils/deploy-key.pub

This file was deleted.

Loading

0 comments on commit 7783fca

Please sign in to comment.