From 2788fa31d2736cbd0f8147901c95ce9ef7680740 Mon Sep 17 00:00:00 2001 From: Joseph Date: Wed, 18 Apr 2018 00:00:50 +0100 Subject: Fix sidebar routes --- pysite/database/table_init/wiki_revisions.json | 1 + pysite/views/wiki/history/compare.py | 2 +- templates/wiki/base.html | 28 +++++++++++++++++++++----- 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 pysite/database/table_init/wiki_revisions.json diff --git a/pysite/database/table_init/wiki_revisions.json b/pysite/database/table_init/wiki_revisions.json new file mode 100644 index 00000000..09675889 --- /dev/null +++ b/pysite/database/table_init/wiki_revisions.json @@ -0,0 +1 @@ +[{"date":1523552033.199194,"id":"1e701916-6504-4c93-950a-09c274610447","post":{"headers":[],"html":"
\n

lol dab

\n
\n","rst":"lol dab","slug":"lol","title":"Test test"},"slug":"lol","user":"165023948638126080"},{"date":1523563438.478759,"id":"0237eae4-01d9-4b63-a644-9b9cdcd77f02","post":{"headers":[],"html":"
\n

Hello world.

\n

Python is good.

\n

Thank you.

\n
\n
dabward
\n

\n
\n
let myvar = String::from("World");\nprintln!("Hello {}", myvar)
\n

lol

\n
\n","rst":"Hello world.\r\n\r\nPython is good.\r\n\r\nThank you.\r\n\r\n:dabward:\r\n\r\n.. code:: rust\r\n\r\n let myvar = String::from(\"World\");\r\n println!(\"Hello {}\", myvar)\r\n \r\nlol","title":"My Lovely Page"},"slug":"mypage","user":"165023948638126080"},{"date":1523552320.439601,"id":"4d9c0dee-56a0-40f7-893d-0722176f650c","post":{"headers":[{"id":"#hello","title":"Hello"},{"id":"#world","title":"World"}],"html":"
\n\n
\n

Hello

\n

lol dab

\n
\n
\n

World

\n
print("hello")
\n
\n
\n","rst":"Hello\r\n-----\r\n\r\nlol dab\r\n\r\nWorld\r\n------\r\n\r\n.. code:: python\r\n\r\n print(\"hello\")","title":"Test test"},"slug":"lol","user":"165023948638126080"},{"date":1523563634.73207,"id":"9db92d5f-8b8c-4e23-9636-6c0961017efc","post":{"headers":[],"html":"
\n

Hello world.

\n

Python is good.

\n

Thank you.

\n
\n
dabward
\n

\n
\n
let myvar = String::from("World");\nprintln!("Hello {}", myvar)
\n

lol

\n
puts "Hello world, in Ruby!"
\n
\n","rst":"Hello world.\r\n\r\nPython is good.\r\n\r\nThank you.\r\n\r\n:dabward:\r\n\r\n.. code:: rust\r\n\r\n let myvar = String::from(\"World\");\r\n println!(\"Hello {}\", myvar)\r\n \r\nlol\r\n\r\n.. code:: ruby\r\n\r\n puts \"Hello world, in Ruby!\"","title":"My Lovely Page"},"slug":"mypage","user":"165023948638126080"},{"date":1523626337.532685,"id":"191fdfa4-c4d3-4d4c-8a9d-043c5b2a9130","post":{"headers":[],"html":"
\n

Testing testing

\n

1..2..3..

\n
print("Hello world")
\n
\n","rst":"Testing testing\r\n\r\n1..2..3..\r\n\r\n.. code:: python\r\n\r\n print(\"Hello world\")","title":"Test test"},"slug":"home","user":"165023948638126080"},{"date":1523626279.682973,"id":"40b4d131-929d-42c9-b486-11a202135959","post":{"headers":[],"html":"
\n

Testing testing

\n

1..2..3..

\n
\n","rst":"Testing testing\r\n\r\n1..2..3..","title":"Test test"},"slug":"home","user":"165023948638126080"},{"date":1523554013.463373,"id":"665c6946-5beb-4522-a5e5-715dd119e601","post":{"headers":[{"id":"#hello","title":"Hello"},{"id":"#world","title":"World"},{"id":"#hahahaha","title":"Hahahaha"}],"html":"
\n\n
\n

Hello

\n

lol dab

\n
\n
\n

World

\n
print("hello")
\n
\n
\n

Hahahaha

\n

Lmfao

\n
\n
\n","rst":"Hello\r\n-----\r\n\r\nlol dab\r\n\r\nWorld\r\n------\r\n\r\n.. code:: python\r\n\r\n print(\"hello\")\r\n \r\nHahahaha\r\n--------\r\nLmfao","title":"Test test"},"slug":"lol","user":"165023948638126080"},{"date":1523563086.517109,"id":"fc7a58ca-820e-4227-a31f-650f8c4ff142","post":{"headers":[],"html":"
\n

Hello world.

\n

Python is good.

\n

Thank you.

\n
\n
dabward
\n

\n
\n
let myvar = String::from("World");\nprintln!("Hello {}", myvar)
\n
\n","rst":"Hello world.\r\n\r\nPython is good.\r\n\r\nThank you.\r\n\r\n:dabward:\r\n\r\n.. code:: rust\r\n\r\n let myvar = String::from(\"World\");\r\n println!(\"Hello {}\", myvar)","title":"My Lovely Page"},"slug":"mypage","user":"165023948638126080"},{"date":1523626516.035445,"id":"fd3e093d-f6ca-49a6-9204-655580301626","post":{"headers":[],"html":"
\n

Testing testing

\n

1..2..3..

\n
print("Hello world")
\n

hahaha

\n

lit

\n
\n","rst":"Testing testing\r\n\r\n1..2..3..\r\n\r\n.. code:: python\r\n\r\n print(\"Hello world\")\r\n \r\nhahaha\r\n\r\nlit\r\n","title":"Test test"},"slug":"home","user":"165023948638126080"},{"date":1523562803.740303,"id":"771834af-de66-49a4-b48c-447703c26ad7","post":{"headers":[],"html":"
\n

Hello world.

\n

JavaScript is bad.

\n

Thank you.

\n
\n","rst":"Hello world.\r\n\r\nJavaScript is bad.\r\n\r\nThank you.","title":"My Lovely Page"},"slug":"mypage","user":"165023948638126080"},{"date":1523552057.061374,"id":"4916abe5-5619-4c0d-a6cf-86ba3605fa42","post":{"headers":[{"id":"#hello","title":"Hello"}],"html":"
\n\n
\n

Hello

\n

lol dab

\n
\n
\n","rst":"Hello\r\n-----\r\n\r\nlol dab","slug":"lol","title":"Test test"},"slug":"lol","user":"165023948638126080"},{"date":1523626419.4753,"id":"4e682aba-fa0d-40a7-96b7-a72994880acb","post":{"headers":[],"html":"
\n

Testing testing

\n

1..2..3..

\n
print("Hello world")
\n

hahaha

\n
\n","rst":"Testing testing\r\n\r\n1..2..3..\r\n\r\n.. code:: python\r\n\r\n print(\"Hello world\")\r\n \r\nhahaha","title":"Test test"},"slug":"home","user":"165023948638126080"},{"date":1523562845.147068,"id":"d5317a3e-0054-4d6d-833f-27739383931d","post":{"headers":[],"html":"
\n

Hello world.

\n

Python is good.

\n

Thank you.

\n
\n
dabward
\n

\n
\n
\n","rst":"Hello world.\r\n\r\nPython is good.\r\n\r\nThank you.\r\n\r\n:dabward:","title":"My Lovely Page"},"slug":"mypage","user":"165023948638126080"}] \ No newline at end of file diff --git a/pysite/views/wiki/history/compare.py b/pysite/views/wiki/history/compare.py index 46dad8e9..ff83dc35 100644 --- a/pysite/views/wiki/history/compare.py +++ b/pysite/views/wiki/history/compare.py @@ -48,4 +48,4 @@ class CompareView(RouteView, DBMixin): diff = difflib.unified_diff(before_text, after_text, fromfile=f"{first_rev}.rst", tofile=f"{second_rev}.rst") diff = "".join(diff) diff = highlight(diff, DiffLexer(), HtmlFormatter()) - return self.render("wiki/compare_revision.html", title=after["post"]["title"], diff=diff) + return self.render("wiki/compare_revision.html", title=after["post"]["title"], diff=diff, slug=before["slug"]) diff --git a/templates/wiki/base.html b/templates/wiki/base.html index 5b8a83a7..87686a83 100644 --- a/templates/wiki/base.html +++ b/templates/wiki/base.html @@ -86,15 +86,33 @@ {% endif %} - {% if current_page != "source" %} + {% if current_page != "history.show" %} + {% if current_page == "history.compare" %} +
  • + +  Back + +
  • + {% else %} +
  • + +  Revisions + +
  • + {% endif %} + {% else %}
  • - -  Source + +  Back
  • + {% endif %} + + + {% if current_page != "source" %}
  • - -  Revisions + +  Source
  • {% else %} -- cgit v1.2.3