Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Commit

Permalink
Workaround for showing submissions without language
Browse files Browse the repository at this point in the history
  • Loading branch information
moschlar committed Nov 14, 2013
1 parent 185183b commit cdcfc4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions sauce/controllers/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def index(self, *args, **kwargs):
@expose('sauce.templates.submission_show')
def show(self, *args, **kwargs):
c.pygmentize = Pygmentize(
lexer_name=self.submission.language.lexer_name if self.submission.language else '',
formatter_args=dict(
linenos='table',
lineanchors='line',
Expand Down Expand Up @@ -183,6 +184,7 @@ def judge(self, *args, **kwargs):

c.judgement_form = JudgementForm(action=url('./judge_'))
c.pygmentize = Pygmentize(
lexer_name=self.submission.language.lexer_name if self.submission.language else '',
formatter_args=dict(
linenos='table',
lineanchors='line',
Expand Down Expand Up @@ -365,6 +367,7 @@ def source(self, what=None, style='default', linenos=True, *args, **kwargs):
src = self.submission.source

pyg = Pygmentize(
lexer_name=self.submission.language.lexer_name if self.submission.language else '',
formatter_args=dict(
full=True,
title='Submission %d' % (self.submission.id),
Expand All @@ -374,8 +377,7 @@ def source(self, what=None, style='default', linenos=True, *args, **kwargs):
)
)

return pyg.display(lexer_name=self.submission.language.lexer_name,
source=src)
return pyg.display(source=src)


class SubmissionsController(TGController):
Expand Down
4 changes: 2 additions & 2 deletions sauce/templates/submission.mak
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ ${next.body()}
</p>

<div>
${c.pygmentize.display(id="source_container", lexer_name=submission.language.lexer_name, source=submission.source) | n}
${c.pygmentize.display(id="source_container", source=submission.source) | n}
</div>

% else:
Expand Down Expand Up @@ -225,7 +225,7 @@ ${next.body()}
<a href="${judgement.submission.url}/source/judgement" class="btn btn-mini"><i class="icon-file"></i>&nbsp;Full page</a>
<a href="${judgement.submission.url}/download/judgement" class="btn btn-mini"><i class="icon-download-alt"></i>&nbsp;Download</a>
</p>
${c.pygmentize.display(lexer_name=judgement.submission.language.lexer_name, source=judgement.corrected_source) | n}
${c.pygmentize.display(source=judgement.corrected_source) | n}

<h4>Diff</h4>
${c.pygmentize.display(lexer_name='diff', source=judgement.diff) | n}
Expand Down

0 comments on commit cdcfc4e

Please sign in to comment.