Better Display of Interweb Wikilinks
Perhaps not the most creative use of CSS. But, at least, this will read better.
This commit is contained in:
parent
7b7d2e80dc
commit
e3aa626489
|
@ -155,6 +155,7 @@ module WikiChunk
|
|||
if web_match
|
||||
@web_name = normalize_whitespace(web_match[1])
|
||||
@page_name = web_match[2]
|
||||
@link_text = @page_name if @link_text == web_match[0]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -180,7 +180,8 @@ class UrlGenerator < AbstractUrlGenerator
|
|||
action = web.published? && (web != @web || [:publish, :s5].include?(mode) ) ? 'published' : 'show'
|
||||
href = @controller.url_for :controller => 'wiki', :web => web_address, :action => action,
|
||||
:id => name, :only_path => true
|
||||
%{<a class="existingWikiWord" href="#{href}">#{text}</a>}
|
||||
title = web == @web ? '' : %{ title="#{web_address}"}
|
||||
%{<a class="existingWikiWord" href="#{href}"#{title}>#{text}</a>}
|
||||
end
|
||||
|
||||
def html_ext
|
||||
|
|
|
@ -380,6 +380,10 @@ a,li span {
|
|||
color:#000;
|
||||
}
|
||||
|
||||
a.existingWikiWord[title]{
|
||||
border: 1px dashed #000;
|
||||
}
|
||||
|
||||
a:hover,a.nav:hover, a:hover math {
|
||||
background-color:#000;
|
||||
color:#FFF;
|
||||
|
|
8
test/fixtures/pages.yml
vendored
8
test/fixtures/pages.yml
vendored
|
@ -60,4 +60,10 @@ liquor:
|
|||
updated_at: <%= 40.minutes.ago.to_formatted_s(:db) %>
|
||||
web_id: 1
|
||||
name: liquor
|
||||
|
||||
|
||||
instiki_page:
|
||||
id: 10
|
||||
created_at: <%= Time.local(2004, 4, 4, 16, 50).to_formatted_s(:db) %>
|
||||
updated_at: <%= Time.local(2004, 4, 4, 16, 50).to_formatted_s(:db) %>
|
||||
web_id: 2
|
||||
name: HomePage
|
12
test/fixtures/revisions.yml
vendored
12
test/fixtures/revisions.yml
vendored
|
@ -90,4 +90,14 @@ liquor_first_revision:
|
|||
page_id: 9
|
||||
content: "[[!redirects booze]]\n Drinky-poo. [[Instiki:HomePage|go there]]"
|
||||
author: Guest
|
||||
ip: 127.0.0.2
|
||||
ip: 127.0.0.2
|
||||
|
||||
instiki_home_page_first_revision:
|
||||
id: 11
|
||||
created_at: <%= Time.local(2004, 4, 4, 15, 50).to_formatted_s(:db) %>
|
||||
updated_at: <%= Time.local(2004, 4, 4, 15, 50).to_formatted_s(:db) %>
|
||||
revised_at: <%= Time.local(2004, 4, 4, 15, 50).to_formatted_s(:db) %>
|
||||
page_id: 10
|
||||
content: First revision of the HomePage end
|
||||
author: AnAuthor
|
||||
ip: 127.0.0.1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
||||
require Rails.root.join('test', 'test_helper')
|
||||
require 'file_controller'
|
||||
require 'fileutils'
|
||||
require 'stringio'
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# commiting to SVN
|
||||
# $INSTIKI_TEST_PDFLATEX = true
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
||||
require Rails.root.join('test', 'test_helper')
|
||||
require 'wiki_controller'
|
||||
require 'rexml/document'
|
||||
require 'tempfile'
|
||||
|
@ -361,13 +361,13 @@ class WikiControllerTest < ActionController::TestCase
|
|||
|
||||
assert_response(:success)
|
||||
assert_equal @liquor, r.template_objects['page']
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage'>go there<\/a>/, r.body
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage' title='instiki'>go there<\/a>/, r.body
|
||||
|
||||
r = process('show', 'web' => 'wiki1', 'id' => 'liquor')
|
||||
|
||||
assert_response(:success)
|
||||
assert_equal @liquor, r.template_objects['page']
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage'>go there<\/a>/, r.body
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage' title='instiki'>go there<\/a>/, r.body
|
||||
|
||||
Web.find_by_address('instiki').update_attribute(:published, true)
|
||||
|
||||
|
@ -375,13 +375,13 @@ class WikiControllerTest < ActionController::TestCase
|
|||
|
||||
assert_response(:success)
|
||||
assert_equal @liquor, r.template_objects['page']
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage'>go there<\/a>/, r.body
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage' title='instiki'>go there<\/a>/, r.body
|
||||
|
||||
r = process('show', 'web' => 'wiki1', 'id' => 'liquor')
|
||||
|
||||
assert_response(:success)
|
||||
assert_equal @liquor, r.template_objects['page']
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage'>go there<\/a>/, r.body
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage' title='instiki'>go there<\/a>/, r.body
|
||||
|
||||
set_web_property :published, false
|
||||
|
||||
|
@ -389,7 +389,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||
|
||||
assert_response(:success)
|
||||
assert_equal @liquor, r.template_objects['page']
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage'>go there<\/a>/, r.body
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/published\/HomePage' title='instiki'>go there<\/a>/, r.body
|
||||
|
||||
Web.find_by_address('instiki').update_attribute(:published, false)
|
||||
|
||||
|
@ -397,7 +397,7 @@ class WikiControllerTest < ActionController::TestCase
|
|||
|
||||
assert_response(:success)
|
||||
assert_equal @liquor, r.template_objects['page']
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage'>go there<\/a>/, r.body
|
||||
assert_match /<a class='existingWikiWord' href='\/instiki\/show\/HomePage' title='instiki'>go there<\/a>/, r.body
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ ENV['RAILS_ENV'] = 'test'
|
|||
|
||||
# Expand the path to environment so that Ruby does not load it multiple times
|
||||
# File.expand_path can be removed if Ruby 1.9 is in use.
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../config/environment')
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
|
||||
|
||||
require 'test_help'
|
||||
require 'wiki_content'
|
||||
|
@ -20,7 +20,7 @@ class ActiveSupport::TestCase
|
|||
self.pre_loaded_fixtures = false
|
||||
self.use_transactional_fixtures = true
|
||||
self.use_instantiated_fixtures = false
|
||||
self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
|
||||
self.fixture_path = Rails.root.join('test', 'fixtures', '')
|
||||
end
|
||||
|
||||
# activate PageObserver
|
||||
|
@ -28,7 +28,7 @@ PageObserver.instance
|
|||
|
||||
class Test::Unit::TestCase
|
||||
def create_fixtures(*table_names)
|
||||
Fixtures.create_fixtures(File.dirname(__FILE__) + "/fixtures", table_names)
|
||||
Fixtures.create_fixtures(Rails.root.join('test', 'fixtures'), table_names)
|
||||
end
|
||||
|
||||
# Add more helper methods to be used by all tests here...
|
||||
|
@ -128,16 +128,21 @@ class StubUrlGenerator < AbstractUrlGenerator
|
|||
def page_link(mode, name, text, web_address, known_page)
|
||||
link = CGI.escape(name)
|
||||
return %{<span class='wikilink-error'><b>Illegal link (target contains a '.'):</b> #{name}</span>} if name.include?('.')
|
||||
title = web_address == 'wiki1' ? '' : " title='#{web_address}'"
|
||||
case mode
|
||||
when :export
|
||||
if known_page then %{<a class="existingWikiWord" href="#{link}.html">#{text}</a>}
|
||||
else %{<span class="newWikiWord">#{text}</span>} end
|
||||
when :publish
|
||||
if known_page then %{<a class="existingWikiWord" href="../published/#{link}">#{text}</a>}
|
||||
if known_page then %{<a class="existingWikiWord" href="../published/#{link}"#{title}>#{text}</a>}
|
||||
else %{<span class="newWikiWord">#{text}</span>} end
|
||||
else
|
||||
if known_page
|
||||
%{<a class="existingWikiWord" href="../show/#{link}">#{text}</a>}
|
||||
if web_address == 'instiki'
|
||||
%{<a class="existingWikiWord" href="../../#{web_address}/show/#{link}"#{title}>#{text}</a>}
|
||||
else
|
||||
%{<a class="existingWikiWord" href="../show/#{link}"#{title}>#{text}</a>}
|
||||
end
|
||||
else
|
||||
if web_address == 'instiki'
|
||||
%{<span class="newWikiWord">#{text}<a href="../../#{web_address}/show/#{link}">?</a></span>}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env ruby
|
||||
# encoding: UTF-8
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
||||
require Rails.root.join('test', 'test_helper')
|
||||
require 'chunks/wiki'
|
||||
|
||||
class WikiTest < Test::Unit::TestCase
|
||||
|
@ -115,7 +115,7 @@ class WikiTest < Test::Unit::TestCase
|
|||
# empty link type
|
||||
assert_link_parsed_as 'page name', 'link?:', :show, '[[page name|link?:]]'
|
||||
# unknown link type
|
||||
assert_link_parsed_as 'create_system', 'page name:create_system', :show,
|
||||
assert_link_parsed_as 'create_system', 'create_system', :show,
|
||||
'[[page name:create_system]]'
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env ruby
|
||||
# encoding: UTF-8
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
||||
require Rails.root.join('test', 'test_helper')
|
||||
|
||||
class PageRendererTest < ActiveSupport::TestCase
|
||||
fixtures :webs, :pages, :revisions, :system, :wiki_references
|
||||
|
@ -662,10 +662,16 @@ END_THM
|
|||
|
||||
def test_wiki_link_with_colon
|
||||
assert_markup_parsed_as(
|
||||
"<p><span class='newWikiWord'>Instiki:Colon<a href='../../instiki/show/Colon'>?</a></span></p>",
|
||||
'[[Instiki:Colon]]')
|
||||
"<p><a class='existingWikiWord' href='../show/HomePage'>HomePage</a></p>",
|
||||
'[[wiki1:HomePage]]')
|
||||
end
|
||||
|
||||
def test_wiki_link_with_colon_interwiki
|
||||
assert_markup_parsed_as(
|
||||
"<p><a class='existingWikiWord' href='../../instiki/show/HomePage' title='instiki'>HomePage</a></p>",
|
||||
'[[instiki:HomePage]]')
|
||||
end
|
||||
|
||||
def test_list_with_tildas
|
||||
list_with_tildas = <<-EOL
|
||||
* [a](~b)
|
||||
|
|
|
@ -14,7 +14,7 @@ class WebTest < ActiveSupport::TestCase
|
|||
|
||||
def test_pages_by_match
|
||||
add_sample_pages
|
||||
assert_equal 2, @web.select { |page| page.content =~ /me/i }.length
|
||||
assert_equal 3, @web.select { |page| page.content =~ /me/i }.length
|
||||
assert_equal 1, @web.select { |page| page.content =~ /Who/i }.length
|
||||
assert_equal 0, @web.select { |page| page.content =~ /none/i }.length
|
||||
end
|
||||
|
@ -27,9 +27,9 @@ class WebTest < ActiveSupport::TestCase
|
|||
|
||||
def test_delete
|
||||
add_sample_pages
|
||||
assert_equal 2, @web.pages.length
|
||||
assert_equal 3, @web.pages.length
|
||||
@web.remove_pages([ @web.page('EverBeenInLove') ])
|
||||
assert_equal 1, @web.pages(true).length
|
||||
assert_equal 2, @web.pages(true).length
|
||||
end
|
||||
|
||||
def test_initialize
|
||||
|
|
Loading…
Reference in a new issue