-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This sounds like an innocuous-enough commit but it's actually quite involved. The "page" field has been replaced by two fields--"in_preface" , and "page_number"--for the Section, TermOccurrence, and Note models. As a result, the forms for adding notes, sections and terms all had to be revamped to varying degrees, both cosmetically and functionally. The templates for displaying notes/terms/sections had to be adjusted as well. This closes #12. Also closes #13 since now the section is determined solely from the page (assumes that all section page numbers are filled).
- Loading branch information
1 parent
fc46555
commit 6104f91
Showing
26 changed files
with
582 additions
and
430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
numeral_map = zip( | ||
(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1), | ||
('m', 'cm', 'd', 'cd', 'c', 'xc', 'l', 'xl', 'x', 'ix', 'v', 'iv', 'i') | ||
) | ||
|
||
|
||
def int_to_roman(i): | ||
result = [] | ||
for integer, numeral in numeral_map: | ||
count = int(i / integer) | ||
result.append(numeral * count) | ||
i -= integer * count | ||
return ''.join(result) | ||
|
||
|
||
def roman_to_int(n): | ||
n = unicode(n) | ||
|
||
i = result = 0 | ||
for integer, numeral in numeral_map: | ||
while n[i:i + len(numeral)] == numeral: | ||
result += integer | ||
i += len(numeral) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,33 @@ | ||
function fetchDefinition() { | ||
var term = document.getElementById('id_term').value; | ||
var language = document.getElementById('id_language').value; | ||
var term = document.getElementById('id_term-text').value; | ||
var language = document.getElementById('id_term-language').value; | ||
var url = '/api/define.json?term=' + term + '&language=' + language; | ||
|
||
fetch(url) | ||
.then(function(response) { | ||
return response.json(); | ||
}) | ||
.then(function(data) { | ||
var definitionInput = document.getElementById('id_definition'); | ||
var definitionInput = document.getElementById('id_term-definition'); | ||
var highlightsInput = document.getElementById('id_term-highlights'); | ||
definitionInput.value = data.definition; | ||
highlightsInput.value = data.highlights; | ||
|
||
// If the term already exists, disable the textarea and add a link to | ||
// the page for editing it. | ||
if (data.edit_link) { | ||
definitionInput.disabled = true; | ||
var definitionEdit = document.getElementById('definition_edit'); | ||
definitionEdit.className = ''; | ||
definitionEdit.href = data.edit_link; | ||
var linkButton = document.getElementById('link_button'); | ||
var occurrencesCount = document.getElementById('occurrences_count'); | ||
|
||
// If the term already exists, disable the definition and highlights | ||
// textareas and add a link to the page for viewing it. | ||
if (data.view_link) { | ||
linkButton.className = 'ui blue button'; | ||
linkButton.href = data.view_link; | ||
|
||
occurrencesCount.innerText = '(' + data.num_occurrences + ' occurrences)'; | ||
} else { | ||
definitionInput.disabled = false; | ||
document.getElementById('definition_edit').className = 'hidden'; | ||
highlightsInput.disabled = false; | ||
linkButton.className = 'ui disabled button'; | ||
occurrencesCount.innerText = ''; | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.