Miva, Miva Script, Miva Empresa, Miva Mia amd Miva Merchant are registered trademarks of the Miva Corporation
 
Ivo Truxa - truXoft control systems: advanced programming and custom IT solutions home / about / webdesign / Miva / automation / contact

http://mivo.truxoft.com
MIVO!
miva beyond limits

 

MIVA®  SNIPPETS:  Miva/HTML Code Viewer

by Ivo Truxa, 09/09/2000

  1. Simple snippet to show the code of a page
  2. Same as a function
  3. Source viewer with syntax coloring
  4. Advanced function with syntax checker
  5. TEST IT! Submit an URL to display its source
  6. User Comments

If you want to publish the source code of a MIVA Script or an HTML page, use the following snippet:

<HTML><HEAD><TITLE>MimeConv 2.0</TITLE></HEAD><BODY>
<MIVA STANDARDOUTPUTLEVEL="">
<MvEVAL EXPR="<PRE>">
<MvIMPORT FILE="filename.mv" FIELDS="line" DELIMITER="
  <MvEVAL EXPR="{encodeentities(line) $ asciichar(10)}">
</MvIMPORT>
<MIVA STANDARDOUTPUTLEVEL="html,text,compresswhitespace">
</PRE></BODY></HTML>

Or use the following function to display code from within another page/script:

<MVFUNCTION NAME="showCode" PARAMETERS="file" STANDARDOUTPUTLEVEL="">
 <MvEVAL EXPR="<PRE>">
 <MvIMPORT FILE="{l.file}" FIELDS="line" DELIMITER="
   <MvEVAL EXPR="{encodeentities(line) $ asciichar(10)}">
 </MvIMPORT>
 <MvEVAL EXPR="</PRE>">
</MVFUNCTION>

NOTE: the file should be in the Miva data directory. Use sfcopy() to move it there.

top


Source viewer with syntax coloring

More advanced (but slower) function to display source code uses MvCALL and therefore it can show source of any document on the web. Miva tags, of course, can be displayed only if the server does not parse them. It means - if you want to publish code of a Miva script, you have to save it with such extension that is not parsed by Miva Empresa (e.g. script.txt instead of script.mv)

Have a look at the source of the function



top


Advanced function with partially implemented syntax checker

You can edit the style sheet to customize the colors and you can add more code to distinguish other tags or identifiers with different styles. Or change the CSS CLASS to older (but longer) FONT tags if you want to support older browsers. Color styling can be also use for easier searching of syntax errors. With some modifications a syntax checker could be made.

Unfortunately using MvCALL is not only slower, but it has also some limitations because MvCALL parses the remote document and may mess it up. The following script tries to fix some of such problems and partially implements a spell checker. For example if you move the mouse over some tags, the level of nesting should be displayed under your cursor. More features may be implemented later.

Check the source



top


TEST IT !  Submit an URL to display its source

type a URL:    

NOTE: MvCALL can screw up some tags or even whole documents! Normally you cannot view the source of Miva scripts. You will see just the source of the resulting HTML page. It is possible only if the author let a renamed (non-parsed) copy of the script on the server (e.g. script.mv renamed to script.txt)




top

   

Miva and some other terms used on this page are registerd trademarks of the Miva Corporation
copyright  truXoft  © 1997-2010