Permalink
Browse files

fix #112 again

  • Loading branch information...
1 parent d821d58 commit 3cc7a233dadcc142b1cbf554aa6680fd78b2f8d1 @bendetat committed Apr 30, 2012
View
BIN docs/markdown-tests/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
39 docs/markdown-tests/test-link-and-resource-behaviour.md
@@ -0,0 +1,39 @@
+# Testing link and resource behaviour in the Awesomium preview control
+
+See `DocumentView.xaml.cs`, specifically:
+
+- `WebControlLinkClicked()`, and
+- `WebControlResourceRequest()`
+
+
+## Working scenarios
+
+### Resource request for remote resources
+This should show the Daring Fireball logo, deep-linked from the site itself:
+
+![DF](http://daringfireball.net/graphics/logos/)
+
+### Resource request for local resources
+This should show the MarkPad icon, stored alongside this document:
+
+<img alt="MarkPad icon" src="icon.png"/>
+
+### Links for remote resources
+This link to the [Code52](http://code52.org) site should open in a new browser window or tab.
+
+### Links for local resources that do not exist
+- Clicking this link to a non-existent url [should do nothing](abcd)
+- Clicking this links to an empty url [should flash an error but immediately re-render the page]()
+- Right-clicking the preview pane and selecting *Refresh*, or left-clicking the preview and pressing `F5` should also flash an error but immediately re-render the page
+
+
+## Broken or unreliable scenarios
+### Links for local resources that exist
+This is a [link to the local MarkPad icon](icon.png). Usually the file will open using `Process.Start()` (preferred behaviour), but sometimes it will open in the preview. This behaviour is erratic but appears to be an upstream issue with the Awesomium control.
+
+### Alt text for images where the image is not found
+Alt text is not displayed for images. The following `img` tags should render as the text "This image is missing" but instead an empty box is displayed. This appears to be an upstream issue with the Awesomium control.
+
+- ![This image is missing](missing.jpg)
+- <img alt="This image is missing" src="missing.jpg"/>
+
View
10 src/MarkPad/Document/DocumentView.xaml.cs
@@ -205,7 +205,15 @@ ResourceResponse WebControlResourceRequest(object o, ResourceRequestEventArgs e)
}
ResourceResponse GetLocalResource(string url)
{
- if (string.IsNullOrWhiteSpace(url)) return null;
+ if (string.IsNullOrWhiteSpace(url))
+ {
+ string result = null;
+ var encoding = new System.Text.UTF8Encoding();
+
+ (DataContext as DocumentViewModel).ExecuteSafely(vm => result = vm.Render);
+
+ return new ResourceResponse(encoding.GetBytes(result), "text/html");
+ }
var resourceFilename = GetResourceFilename(url);
if (!File.Exists(resourceFilename)) return null;

0 comments on commit 3cc7a23

Please sign in to comment.