Skip to content

Commit

Permalink
ProjectVersions starting to think about layout
Browse files Browse the repository at this point in the history
Tiny colum fix for python to keep it thin
Sudoku from a dependency graph!
  • Loading branch information
calaldees committed Oct 23, 2024
1 parent 4aed635 commit 4bf8874
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion teachprogramming/lib/make_ver2.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def diff(self, language: LanguageFileExtension) -> MappingProxyType[Version, str
self.language(language)[version].split("\n"),
fromfile=parent, tofile=version, n=2, lineterm=''))
for version, parent in self.versions.parents.items()
if parent
if parent is not None
})

@cached_property
Expand Down
20 changes: 19 additions & 1 deletion teachprogramming/lib/static/projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,31 @@ <h1>Projects</h1>
}

function renderProject(data) {
return h('div',{},Object.keys(data.languages).map(language=>[
h('h2',{},language),
...Object.entries(data.versions.parents).map(([version, parent_version])=>[
h('h3',{},version),
h('pre',{classList: 'diff'}, data.diffs[language] && data.diffs[language][version]),
h('pre',{classList: 'full'}, data.languages[language] && data.languages[language][version]),
]).flat()
]).flat())
}

function renderProjectBasic(data) {
return h('div',{},Object.entries(data.languages).map(
([language, _version_code])=>[h('h2',{},language), ...(!_version_code?[]:
Object.entries(_version_code).map(([version, code])=>[h('h3',{},version), h('pre',{},code)]).flat()
Object.entries(_version_code).map(([version, code])=>[
h('h3',{},version),
h('pre',{},code),
h('pre',{},data.diffs[language][version])
]).flat()
)]
).flat())
}

// Consider CSS toggle
// https://blog.logrocket.com/advanced-guide-css-toggle-pseudo-class/

if (urlParams.has(QUERY_STRING_project)) {
fetch(`/api/v1/projects/${urlParams.get(QUERY_STRING_project)}.json`)
.then(response => response.json())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def file_binary():
def assertion():
name = "bob"
count = 3
assert name == "bob", f"I am expecting {name} to be 'bob'" # ver: assertion
assert name == "bob", f"Expecting {name} to be 'bob'" # ver: assertion
assert count >= 3 # ver: assertion

def sort():
Expand Down
4 changes: 3 additions & 1 deletion teachprogramming/static/projects/data/sudoku.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,4 +487,6 @@ Other implementations
=====================

* [Suduku in one line](https://dfns.dyalog.com/n_sudoku.htm)
* Problem description and notation for solution
* Problem description and notation for solution
* [Sudoku in python packaging](https://github.com/konstin/sudoku-in-python-packaging)
* package dependencies have requirements - we can use that chaining to solve sudoku

0 comments on commit 4bf8874

Please sign in to comment.