[TWC] How to display local .txt file (no iframe)

213 views
Skip to first unread message

julien23

unread,
Apr 10, 2015, 3:18:38 AM4/10/15
to tiddl...@googlegroups.com
Hi all

I would like to display in line .m file

For now I am doing this with iframe :

[[ScoreCalculation14.m]]

!Description
<html><iframe src="..\satt_prop14_dev\matlab\ScoreCalculation14.m" frameborder="0" width="100%" height="1100"></iframe></html>

!type
application
!file
..\satt_prop14_dev\matlab\ScoreCalculation14.m

!Link
<<tiddler templateNewFileLink with: {{tiddler.title}}>>


But it is not satisfying : I have to adjust manually the height, text does not wrap ...

I have InlineJavascriptPlugin activated
I have tried several <script> but I end to nothing.

Could you please help me ?

Regards

JBo


Shankar

unread,
Apr 11, 2015, 1:03:30 PM4/11/15
to tiddl...@googlegroups.com
Try putting it under

{{{
contents of your .m file goes here ...
}}}

Two caveats:  1. I likely missed your question - this is too trivial a solution, 2. it is possible that the {{{ .... }}} is a concoction I might have whipped up.  I have been using and customizing Tiddly Wiki (Classic) for so long now, I no longer can distinguish between what came pre-packaged, what came with Eric Shulman's help, what I came up with!  But this seems a relatively simple fix, if the above does not work - get back here.
Cheers; 'best,
shankar

Mat

unread,
Apr 11, 2015, 3:45:08 PM4/11/15
to tiddl...@googlegroups.com
Maybe something like this. I get this to work with a local txt file:

 <object data="..\satt_prop14_dev\matlab\ScoreCalculation14.m" type="..whateveritis..">
  Text showing if file does not show up.
 </object>

<:-)

Eric Shulman

unread,
Apr 11, 2015, 4:02:15 PM4/11/15
to tiddl...@googlegroups.com
Excellent solution!  This works for me using Win7/Chrome.  Note that TWClassic needs to have <html>...</html> markers around any HTML syntax, and if you want to use wiki syntax to format the "file not found" text (the content within the <object>...</object> block), then you will need to install

Also, if you don't specify the type="...", the browser defaults to "text/plain".  The type param is only required if you want the browser to attempt to display the file content using an addon "viewer" that was previously installed (e.g., PDF, Excel, Word)

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

"Inside TiddlyWiki: The Missing Manual"
Note: the IndieGogo funding campaign has ended,
but direct fundraising continues below...

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:

julien23

unread,
Apr 13, 2015, 3:21:10 AM4/13/15
to tiddl...@googlegroups.com
Hi all

Thank you for answers.

<html>
<object data="..\satt_prop14_dev\matlab\ScoreCalculation14.m" type="txt">
  File not found.
 
</object>
</html>

works on win7/FF36
win7/Chrome "File not found." not my main browser, maybe it is not configured for local files.

but anyway, I have the same issue than with iframe : the file content is exiguous and delimited with both horizontal and vertical scrollbar.

see TW14_2015_04_13.pdf

and even if I manually fit width and height to file content...
<object style="width:650px; height:264em;" data="..\satt_prop14_dev\matlab\ScoreCalculation14.m" type="txt">
... then when I print, object is truncated to one page.

It does not display inline like for example

{{{
contents of your
.m file goes here ...
}}}

I think I am looking for a script that fetch the file content and send it as output.

I have tried to tweak the [AliasScript] Eric did me earlier.
<script>
out
=store.getValue("$1","alias")
wikify
(out.toString(),place); //Final output
</script>

with this code :
<script>
document
.include = function (url) {
 
if ('undefined' == typeof(url)) return false;
 
var p,rnd;
 
if (document.all){
   
// For IE, create an ActiveX Object instance
   p
= new ActiveXObject("Microsoft.XMLHTTP");
 
}
 
else {
   
// For mozilla, create an instance of XMLHttpRequest.
   p
= new XMLHttpRequest();
 
}
 
// Prevent browsers from caching the included page
 
// by appending a random  number (optional)
 rnd
= Math.random().toString().substring(2);
 url
= url.indexOf('?')>-1 ? url+'&rnd='+rnd : url+'?rnd='+rnd;
 
// Open the url and write out the response
 p
.open("GET",url,false);
 p
.send(null);
 document
.write( p.responseText );
}
document
.include('../satt_prop14_dev/matlab/ScoreCalculation14.m');
</script>

I display the file content as text. It wraps properly. But don't manage to make it wikify so far ...

Looking forward to read from you

JBo

julien23

unread,
Apr 13, 2015, 3:47:16 PM4/13/15
to tiddl...@googlegroups.com
Hi all

I finally managed something ... experts might find it dirty :-)

<<tiddler UrlContentScript with:../satt_prop14_dev/matlab/ScoreCalculation14.m>>

[[UrlContentScript]]
<script>
var p;

 if (document.all){
   // For IE, create an ActiveX Object instance
   p = new ActiveXObject("Microsoft.XMLHTTP");
 }
 else {
   // For mozilla, create an instance of XMLHttpRequest.
   p = new XMLHttpRequest();
 }
 p.open("GET","$1",false);
 p.send(null);
wikify(p.responseText,place);
</script>

julien23

unread,
Apr 13, 2015, 4:14:07 PM4/13/15
to tiddl...@googlegroups.com
[Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///S:/satt_prop14/index.html line 17349 > eval line 76 > eval :: _out :: line 13" data: no]
not perfect ...
I get this error depending on files


On Monday, April 13, 2015 at 9:47:16 PM UTC+2, julien23 wrote:
Hi all

I finally managed something ... experts might find it dirty :-)

<script>
var url = '../satt_prop14_dev/matlab/ScoreCalculation14.m';

 
if ('undefined' == typeof(url)) return false;
 
var p,rnd;
 
if (document.all){
   
// For IE, create an ActiveX Object instance
   p
= new ActiveXObject("Microsoft.XMLHTTP");
 
}
 
else {
   
// For mozilla, create an instance of XMLHttpRequest.
   p
= new XMLHttpRequest();
 
}

 p
.open("GET",url,false);
 p
.send(null);
var urlContent = p.responseText.toString();
wikify
(urlContent,place)
</script>

julien23

unread,
Apr 14, 2015, 3:17:23 AM4/14/15
to tiddl...@googlegroups.com
Hi all

Exception was caused by "\" instead of "/" in the url.

Can you please help me with a last thing ?

At the end of [[UrlContentScript]], I don't manage to concatenate "{{{" + p.responseText + "}}}" to keep indentations.

How do I do that ?


Looking forward to read from you

JBo




Reply all
Reply to author
Forward
0 new messages