You are not logged in.

#1 2005-07-16 23:03:59

dust
Member
Registered: 2005-06-04
Posts: 152
Website

importing mark up from a file without cgi

Hmm, title seems wrong, but anyway. What I have is a held doc project I'm working on, and its basically converting a mess of different file formats into a structured html file. Unfortunately, I haven't been able to convince my boss to give me a server to put this on so that I can create ruby scripts to do what I want, but instead has decided to just give me some shared drive space sad .

So my basic question is, anyone know a way using html or javascript to import things into every file so I don't have to copy+paste maintain everythingt things like the navigation menu that appears on all pages?


Writing stories for a machine.

Offline

#2 2005-07-16 23:09:19

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: importing mark up from a file without cgi

Javascript includes are one option, though they don't always work.

dreamweaver style templates... dunno if any linux editors support these, maybe nvu.

You could try pycludes:

http://www.buchuki.com/pycludesparser.html

Dusty

Offline

#3 2005-07-16 23:31:06

dust
Member
Registered: 2005-06-04
Posts: 152
Website

Re: importing mark up from a file without cgi

Thanks dusty, unfortunately I can't use a scripting language that browsers don't natively understand, nor 34d party apps for this hmm . Other wise I would have done it in ruby ^^ .

I guess the reason I'm having so much trouble is because I can't seem to figure out how javascript wants me to create the string I want all the pages to share in way that can be included easily. All it is is an unordered list contained within a div tags. I thought that just putting down the whole statement as a string variable in a .js file, along with a method to simple write that varaible to the document, and finally importing that script and calling the method would work, but its not >< . Here's an example:

function write_nav() {
 nav_statement = "<div id="navigation"> 
a_bunch_of_tags_and_stuff... 
</div> ";

 document.write(nav_statement);
}

# then in the html files
<head>
<script src="scripts/nav_write.js"></script>
</head>
<body>
<script type="text/javascript">write_nav();</script>
</body>

Writing stories for a machine.

Offline

#4 2005-07-17 02:54:03

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: importing mark up from a file without cgi

dust wrote:

Thanks dusty, unfortunately I can't use a scripting language that browsers don't natively understand, nor 34d party apps for this hmm . Other wise I would have done it in ruby ^^ .

I guess the reason I'm having so much trouble is because I can't seem to figure out how javascript wants me to create the string I want all the pages to share in way that can be included easily. All it is is an unordered list contained within a div tags. I thought that just putting down the whole statement as a string variable in a .js file, along with a method to simple write that varaible to the document, and finally importing that script and calling the method would work, but its not >< . Here's an example:

function write_nav() {
 nav_statement = "<div id="navigation"> 
a_bunch_of_tags_and_stuff... 
</div> ";

 document.write(nav_statement);
}

# then in the html files
<head>
<script src="scripts/nav_write.js"></script>
</head>
<body>
<script type="text/javascript">write_nav();</script>
</body>

with a string that is quoted in the form of foo = "bar" you cannot use " within the string. So foo = "<bar where="there" />" will cause an error.

But foo = "<bar where='there' />" is perfectly save, and valid.

Offline

#5 2005-07-17 20:52:25

dust
Member
Registered: 2005-06-04
Posts: 152
Website

Re: importing mark up from a file without cgi

Ah, I forgot to escap the " in the example like I have it in the actual file, but even with that it won't work?


Writing stories for a machine.

Offline

#6 2005-07-17 21:35:24

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: importing mark up from a file without cgi

why not build the html dynamically. Write some ruby (or insert fav language here) to do the including for you.
Maybe a simple string replacement. Put in markers like {header} {navbar}.
and have the scripts just replace those instances. Hell, you could probably do it with a few lines of sed.
Then you just have input files, and output files. Maybe not quite as elegent, but probably far more workabe.


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#7 2005-07-17 21:46:45

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: importing mark up from a file without cgi

cactus wrote:

why not build the html dynamically. Write some ruby (or insert fav language here) to do the including for you.
Maybe a simple string replacement. Put in markers like {header} {navbar}.
and have the scripts just replace those instances. Hell, you could probably do it with a few lines of sed.
Then you just have input files, and output files. Maybe not quite as elegent, but probably far more workabe.

That's what pycludes does.

Dusty

Offline

#8 2005-07-17 21:57:36

dust
Member
Registered: 2005-06-04
Posts: 152
Website

Re: importing mark up from a file without cgi

Like I explained earlier, if I had a server I could plop this project on that I could install ruby, hell I'd even take perl, for this I would. Unforuntately I don't have that luxury.


Writing stories for a machine.

Offline

#9 2005-07-17 21:58:32

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: importing mark up from a file without cgi

you cant work on it on your desktop, then upload it to the server? I was not talking about a web fired script, but a CLI activated one..ie..you run it yourself before hand.


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#10 2005-07-18 00:12:13

dust
Member
Registered: 2005-06-04
Posts: 152
Website

Re: importing mark up from a file without cgi

Hmm, interesting suggestion, thanks.


Writing stories for a machine.

Offline

Board footer

Powered by FluxBB