More bugs in tex_list

Fix some more bugs in the new
tex_list action.
Make the drag-reorder *not*
result in a (superfluous)
AJAX request.
This commit is contained in:
Jacques Distler 2010-10-11 10:57:26 -05:00
parent 8a989b1a7b
commit 46da49485f
3 changed files with 6 additions and 6 deletions

View file

@ -190,10 +190,10 @@ EOL
if [:markdownMML, :markdownPNG, :markdown].include?(@web.markup) if [:markdownMML, :markdownPNG, :markdown].include?(@web.markup)
@tex_content = '' @tex_content = ''
# Ruby 1.9.x has ordered hashes; 1.8.x doesn't. So let's just parse the query ourselves. # Ruby 1.9.x has ordered hashes; 1.8.x doesn't. So let's just parse the query ourselves.
ordered_params = ActiveSupport::OrderedHash[*request.raw_post.split('&').collect {|k_v| k_v.split('=').each {|x| CGI::unescape(x)}}.flatten] ordered_params = ActiveSupport::OrderedHash[*request.raw_post.split('&').collect {|k_v| k_v.split('=').collect {|x| CGI::unescape(x)}}.flatten]
ordered_params.each do |name, p| ordered_params.each do |name, p|
if p == 'tex' && @web.has_page?(name) if p == 'tex' && @web.has_page?(name)
@tex_content << "\\section*\{#{name}\}\n\n".as_utf8 @tex_content << "\\section*\{#{Maruku.new(name).to_latex.strip}\}\n\n"
@tex_content << Maruku.new(@web.page(name).content).to_latex @tex_content << Maruku.new(@web.page(name).content).to_latex
end end
end end

View file

@ -28,7 +28,7 @@
<% end %> <% end %>
</ul> </ul>
<%= sortable_element('sortable_pages') %> <%= sortable_element('sortable_pages', {:onUpdate => 'function(){}'}) %>
<label for="commit"> Export selected pages (drag to re-order them) to a LaTeX file.</label> <label for="commit"> Export selected pages (drag to re-order them) to a LaTeX file.</label>
<%= submit_tag("Export") %> <%= submit_tag("Export") %>
</div> </div>

View file

@ -1346,13 +1346,13 @@ Page2 contents $\mathbb{01234}$.
end end
def test_tex_list def test_tex_list
@wiki.write_page('wiki1', 'Page2', @wiki.write_page('wiki1', "Ch\303\242timent & Page",
"Page2 contents $\\mathbb{01234}$.\n", "Page2 contents $\\mathbb{01234}$.\n",
Time.now, Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer) Time.now, Author.new('AnotherAuthor', '127.0.0.2'), x_test_renderer)
@request.env['RAW_POST_DATA'] = "_form_key=353106ff8c8466727ee5338baaa0640c87c9b0d6&Page2=tex&BogusPage=tex&HomePage=tex&commit=Export" @request.env['RAW_POST_DATA'] = "_form_key=353106ff8c8466727ee5338baaa0640c87c9b0d6&Ch%C3%A2timent+%26+Page=tex&BogusPage=tex&HomePage=tex&commit=Export"
r = process('tex_list', 'web' => 'wiki1', 'Page2' => 'tex', 'BogusPage'=> 'tex', 'HomePage' => 'tex') r = process('tex_list', 'web' => 'wiki1', 'Page2' => 'tex', 'BogusPage'=> 'tex', 'HomePage' => 'tex')
assert_response(:success) assert_response(:success)
assert_equal @tex_header1 + "\\usepackage{mathbbol}\n" + @tex_header2 + %q!\section*{Page2} assert_equal @tex_header1 + "\\usepackage{mathbbol}\n" + @tex_header2 + %q!\section*{Châtiment \\& Page}
Page2 contents $\mathbb{01234}$. Page2 contents $\mathbb{01234}$.