diff --git a/mansrht-migrate b/mansrht-migrate index 9d58665..c9a28db 100755 --- a/mansrht-migrate +++ b/mansrht-migrate @@ -3,4 +3,3 @@ import mansrht.alembic import srht.alembic from srht.database import alembic alembic("man.sr.ht", mansrht.alembic) -alembic("man.sr.ht", srht.alembic) diff --git a/mansrht/blueprints/create.py b/mansrht/blueprints/create.py index 70df08d..e8a9720 100644 --- a/mansrht/blueprints/create.py +++ b/mansrht/blueprints/create.py @@ -20,6 +20,7 @@ def select_repo(backend, wiki_name, **kwargs): existing = [ wiki.repo.name for wiki in Wiki.query.filter(Wiki.owner_id == current_user.id).all() + if wiki.repo ] # TODO: Add cancel button. diff --git a/mansrht/blueprints/html.py b/mansrht/blueprints/html.py index 4c5fe65..1825cbf 100644 --- a/mansrht/blueprints/html.py +++ b/mansrht/blueprints/html.py @@ -54,9 +54,10 @@ def content(wiki, path, is_root=False, **kwargs): backend = GitsrhtBackend(wiki.owner) clone_urls = get_clone_urls( backend.origin, wiki.owner, wiki.repo, backend.ssh_format) + web_url=f"{backend.origin}/{wiki.owner.canonical_name}/{wiki.repo.name}" if not wiki.repo.commit_sha: - return render_template( - "new-wiki.html", clone_url=clone_urls[1], repo=wiki.repo) + return render_template("new-wiki.html", wiki=wiki, + clone_url=clone_urls[1], repo=wiki.repo, web_url=web_url) head, tail = os.path.split(path) if path else (None, None) path = tuple(p for p in (head, tail) if p) @@ -136,7 +137,7 @@ def content(wiki, path, is_root=False, **kwargs): return render_template("content.html", content=html, title=title, repo=wiki.repo, toc=toc, wiki=wiki, is_root=is_root, path=path, frontmatter=frontmatter, - clone_urls=clone_urls, **kwargs) + clone_urls=clone_urls, web_url=web_url, **kwargs) @html.route("/") @html.route("/") diff --git a/mansrht/templates/content.html b/mansrht/templates/content.html index aa35541..3494176 100644 --- a/mansrht/templates/content.html +++ b/mansrht/templates/content.html @@ -57,7 +57,9 @@

This commit

-
commit {{ repo.commit_sha }}
+
commit {{ repo.commit_sha }}
 Author: {{ repo.commit_author }} <{{ repo.commit_email }}>
 Date:   {{ repo.commit_time }}
 
@@ -67,7 +69,13 @@ Date:   {{ repo.commit_time }}
       
Clone this wiki
{% for url in clone_urls|map(attribute="url") %} + {% if "://" in url %} {{ url }} + (read-only) + {% else %} + {{url}} + (read/write) + {% endif %} {% endfor %}
diff --git a/mansrht/templates/new-wiki.html b/mansrht/templates/new-wiki.html index e944ba5..46bb2ef 100644 --- a/mansrht/templates/new-wiki.html +++ b/mansrht/templates/new-wiki.html @@ -2,15 +2,31 @@ {% block content %}
-
+

index

- You've successfully created your wiki, but it does not have any content - yet. Your repository is available at {{ clone_url.url }}. - To populate the index page, clone the repository and add an - index.md file. Commit it, push to the - {{ repo.ref }} branch, and you'll see the changes here. + Your wiki has been created, but does not have any content. To add + content, push commits to the {{repo.ref}} branch of + {{wiki.owner.canonical_name}}/{{wiki.repo.name}}: + {{clone_url.url}}

+ {% if repo.ref != "master" %} +
git clone {{clone_url.url}} && cd {{repo.name}}
+git checkout --orphan {{repo.ref}}
+git rm -rf *
+echo "Hello world!" >index.md
+git add index.md
+git commit -m"Initial wiki commit"
+git push -u origin {{repo.ref}}
+ {% else %} +
git clone {{clone_url.url}} && cd {{repo.name}}
+echo "Hello world!" >index.md
+git add index.md
+git commit -m"Initial wiki commit"
+git push -u origin {{repo.ref}}
+ {% endif %}
diff --git a/scss/main.scss b/scss/main.scss index 4d43306..9840252 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -57,3 +57,8 @@ h5 { } } } + +code.grey { + background: $gray-200; + padding: 0 0.25rem; +}