logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Configuring htaccess
Author
msaz87



Joined: 07 Jul 2006
Posts: 16

PostPosted: Sun 01 Apr '07 1:52    Post subject: Configuring htaccess Reply with quote

Hey all,

I'm working on configuring my htaccess so it's more attractive and works better for what I'm trying to do. Essentially, I'm making it into a contacts/directory type system.

My question is, I'm going to have a bunch of photos in a folder, each named after an employee and wanted to know if there's anyway to have it display a thumbnail of the file in the full list?

Also, is there any way to rename parts of the list --- IE: rename "Description" to "Job Title" or something?

The way this is going to work is there's a database that will automatically dump the photos of everyone into a certain folder and I am trying to make it wind up looking like a good contact list.

If anyone has any ideas, I'd love to hear them.

Thanks.
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Sun 01 Apr '07 13:30    Post subject: Reply with quote

Dirty trick I've seen used before was injection javascript in the footer and then altering the layout view DOM.
Back to top
msaz87



Joined: 07 Jul 2006
Posts: 16

PostPosted: Mon 02 Apr '07 8:16    Post subject: Reply with quote

I'm not really familiar with how to alter the layout view like that using javascript. Do you by chance have a link to an example or code?

Thanks.
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Mon 02 Apr '07 8:55    Post subject: Reply with quote

sure I whipped this up in about 15min so its not perfect but does the job
Code:

<script type="text/javascript">
   var oFileList = document.body.childNodes[3];
   for(var i = 0; i<oFileList.childNodes.length; i++){
      var oImgNode = oFileList.childNodes[i];
      var oLinkSrc = oFileList.childNodes[(i+2)];
      if(oImgNode.nodeName.toLowerCase() == 'img'){
         if(oImgNode.src.substr(-10).toLowerCase() == 'image2.gif'){
            oImgNode.style.width = '100px';
            oImgNode.src = oLinkSrc;
         }
      }
   }
</script>


just place this in your apache footer file.
Back to top
msaz87



Joined: 07 Jul 2006
Posts: 16

PostPosted: Mon 02 Apr '07 9:30    Post subject: Reply with quote

That script works beautifully, thanks very much.

I have a few more questions, if you don't mind.

The first is whether or you can essentially rename any of the descriptors, IE: change "Name" to "Person" or "Description" to "Job" -- same thing with the "Parent Directory" to "Back" or something.

And finally, is there any way to add into the script you wrote a way to lop off the file extensions from being visible? IE: Instead of "mike_smith.gif" (with his thumbnail next to him) it'd just be "mike_smith"

I appreciate your help.
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Mon 02 Apr '07 13:42    Post subject: Reply with quote

Code:

<script type="text/javascript">
   var oImg=document.getElementsByTagName("img");
   var oLink=document.getElementsByTagName("a");
   //find the image and check if there src = image2.gif, if so transform them & update the associate link
   for (var i=0;i<oImg.length;i++){
      if(oImg[i].src.substr(-10).toLowerCase() == 'image2.gif'){
         var sFileName = oLink[(i+3)].innerHTML;
         sFileName = sFileName.substr(0, sFileName.lastIndexOf('.'));
         oLink[(i+3)].innerHTML = sFileName;
         oImg[i].style.width = '100px';
         oImg[i].src = oLink[(i+3)].href;
      }
   }
   //find the header links and update them
   for (var i=0;i<oLink.length;i++){
      if(oLink[i].innerHTML == 'Description') oLink[i].innerHTML = 'Job Title'
      if(oLink[i].innerHTML == 'Parent Directory') oLink[i].innerHTML = 'Back'
   }
</script>


Should do the renaming of the links.
I also optimized it a bit so it goes faster
Back to top
msaz87



Joined: 07 Jul 2006
Posts: 16

PostPosted: Tue 03 Apr '07 8:52    Post subject: Reply with quote

Oddly enough, that new script doesn't seem to work at all.

Here's two different directories containing the two scripts:
http://www.foothillsbaptist.org/contacts/All/ - the new script
http://www.foothillsbaptist.org/contacts/Engineering/ - the first script

That might not give you much to go by, but the directories are the same, only the scripts in the footers change.

Any ideas? Thanks.
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Tue 03 Apr '07 10:14    Post subject: Reply with quote

Your output looks different from mine.

Code:
IndexOptions FancyIndexing VersionSort FoldersFirst XHTML


are the index options I use.
Back to top
msaz87



Joined: 07 Jul 2006
Posts: 16

PostPosted: Wed 04 Apr '07 5:51    Post subject: Reply with quote

This is the .htaccess I have been using:

Code:
Options +Indexes
   IndexOptions FancyIndexing SuppressDescription SuppressLastModified SuppressSize SuppressHTMLPreamble FoldersFirst NameWidth=*
   HeaderName header.htm
   ReadmeName footer.htm
   IndexIgnore header.htm footer.htm .htaccess direclogo.gif Thumbs.db

<IfModule mod_dir.c>
DirectoryIndex index.html index.htm index.php
</IfModule>


I tried this code using your output:
Code:
Options +Indexes
   IndexOptions FancyIndexing VersionSort FoldersFirst XHTML NameWidth=*
   HeaderName header.htm
   ReadmeName footer.htm
   IndexIgnore header.htm footer.htm .htaccess direclogo.gif Thumbs.db

<IfModule mod_dir.c>
DirectoryIndex index.html index.htm index.php
</IfModule>


But it looks like the VersionSort and XHTML parts cause errors. I imagine this is due to something not being set right in my config, but I don't know what.
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Wed 04 Apr '07 10:28    Post subject: Reply with quote

I just noticed in your source that the tag are UPPERCASE mine are lowercase,

so try:

Code:
<script type="text/javascript">
   var oImg=document.getElementsByTagName("IMG");
   var oLink=document.getElementsByTagName("A");
   //find the image and check if there src = image2.gif, if so transform them & update the associate link
   for (var i=0;i<oImg.length;i++){
      if(oImg[i].src.substr(-10).toLowerCase() == 'image2.gif'){
         var sFileName = oLink[(i+3)].innerHTML;
         sFileName = sFileName.substr(0, sFileName.lastIndexOf('.'));
         oLink[(i+3)].innerHTML = sFileName;
         oImg[i].style.width = '100px';
         oImg[i].src = oLink[(i+3)].href;
      }
   }
   //find the header links and update them
   for (var i=0;i<oLink.length;i++){
      if(oLink[i].innerHTML == 'Description') oLink[i].innerHTML = 'Job Title'
      if(oLink[i].innerHTML == 'Parent Directory') oLink[i].innerHTML = 'Back'
   }
</script>


Silly idea but the html seems to be about the same accept some minor thing I don't touch.
Back to top
msaz87



Joined: 07 Jul 2006
Posts: 16

PostPosted: Wed 04 Apr '07 10:35    Post subject: Reply with quote

Nope. Didn't seem to make a difference.

If this can't be figured out, it wouldn't be the end of the world. The primary thing I wanted to do was get rid of the extensions, but I'm not sure if there's any other way?

Thanks for all your help.
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Wed 04 Apr '07 15:18    Post subject: Reply with quote

I'll give it one more shot:
Code:
<script type="text/javascript">
   var oFileList = document.body.childNodes[3];
   for(var i = 0; i<oFileList.childNodes.length; i++){
      var oImgNode = oFileList.childNodes[i];
      var oLinkSrc = oFileList.childNodes[(i+2)];
      if(oImgNode.nodeName.toLowerCase() == 'img'){
         if(oImgNode.src.substr(-10).toLowerCase() == 'image2.gif'){
          var sFileName = oLinkSrc.innerHTML;
         sFileName = sFileName.substr(0, sFileName.lastIndexOf('.'));
         oLinkSrc.innerHTML = sFileName;
            oImgNode.style.width = '100px';
            oImgNode.src = oLinkSrc;
         }
      }
   }
</script>


I did a quick update of the first code. Haven't tested it myself but it should work.
Back to top
msaz87



Joined: 07 Jul 2006
Posts: 16

PostPosted: Wed 04 Apr '07 21:39    Post subject: Reply with quote

Worked nicely.

Thanks for all your help, sorry to be such a hassle.
Back to top
msaz87



Joined: 07 Jul 2006
Posts: 16

PostPosted: Tue 10 Apr '07 10:36    Post subject: Reply with quote

I ran into another problem... it seems the code only works with displaying images in firefox and not in internet explorer.

Anyone know why or how to resolve it?

Thank you.
Back to top
Jorge



Joined: 12 Mar 2006
Posts: 376
Location: Belgium

PostPosted: Wed 11 Apr '07 19:14    Post subject: Reply with quote

sry can't be of much help on that... I'm running on a mac where I am so no IE for me :p
Back to top


Reply to topic   Topic: Configuring htaccess View previous topic :: View next topic
Post new topic   Forum Index -> Apache