|
MetaGenerator Object v2.0 [VBScript]purpose:An object that creates meta tags.
* allows custom meta tags,
* can create an unlimited number of tags at one time (configurable),
* allows HTTP-EQUIV or NAME meta tags to be created.
syntax:set object = new MetaGenerator example usage: '************************ START CLASS CALLING CODE *************************
'declare class variable
Dim a
'load class instance
Set a = New MetaGenerator
'set the number of visible inputs on the form (default is 5)
a.MetaFormInputs = 4
'calling execute will either generate tags or show the form.
'The class determines what it will do.
a.Execute
'free class instance
Set a = Nothing
'************************* END CLASS CALLING CODE **************************
source code: '*********************** START CLASS DEFINITION ************************
Class MetaGenerator
'************************* START DOCUMENTATION *************************
' ---------------------------
' MetaGenerator Object v2.0
' http://www.aspemporium.com/
' ---------------------------
'
'
' PURPOSE:
' Provides an interface to create an unlimited number of meta tags
' that can be copied and pasted into a html document.
'
'
' PROPERTIES:
' MetaFormInputs [= int]
' Optional. Read/Write. Integer. The number of form
' inputs to display. Default if not set is 5.
'
' Version
' Optional. Read Only. String. Returns the version as
' as "major.minor".
'
'
' METHODS:
' Execute()
' Required. Returns Void. The class will determine it's
' own action: display form or create meta tags.
'
'
' VERSION HISTORY:
' 2.0 5/14/2001
' - VBScript class
' - allows custom meta tags
' - can create an unlimited number of tags at one time (configurable)
' - allows HTTP-EQUIV or NAME meta tags to be created
'
' 1.0 1/15/2000
' initial release
'
'
' NOTES:
' This application does not require any of the include files
' that are colored green below. These include files are used
' to create the ASP Emporium website layout. To use this code
' as is, delete all includes below. No database is required
' for this example to function properly.
'
'
'************************** END DOCUMENTATION **************************
Public MetaFormInputs
Public Property Get Version
Version = "2.0"
End Property
Public Sub Execute
If Request.QueryString.Count > 0 Then
ResolveAndDisplayTags
Else
Show_Form
End If
End Sub
Private Sub Class_Initialize
MetaFormInputs = 5
End Sub
Private Sub ResolveAndDisplayTags
Dim i, s
For i = 1 to Request.QueryString("metatype").Count
If Len(Request.QueryString("metatype")(i)) > 0 And _
Len(Request.QueryString("metaname")(i)) > 0 And _
Len(Request.QueryString("metacontent")(i)) > 0 Then
s = s & Server.HTMLEncode("<META " & _
UCase(Request.QueryString("metatype")(i)) & _
"=""" & Request.QueryString("metaname")(i) & _
""" CONTENT=""" & _
Request.QueryString("metacontent")(i) & _
""" />") & vbCrLf & vbCrLf
End If
Next
If InStr(s, "META") Then
Response.Write("<FORM><TEXTAREA COLS=70 ")
Response.Write("ROWS=10 STYLE=""font-size:9pt;"">")
Response.Write(s)
Response.Write(Server.HTMLEncode("<META NAME=""generator"" "))
Response.Write(Server.HTMLEncode("CONTENT=""MetaGenerator "))
Response.Write(Server.HTMLEncode("Object v" & Version & """ />"))
Response.Write("</TEXTAREA></FORM>")
Response.Write("<A HREF=""" & _
request.servervariables("PATH_INFO") & _
""">do it again</A>")
Else
Show_Form
End if
End Sub
Private Sub Show_Form
dim i
%>
<FORM METHOD="GET" NAME=frm1
ACTION="<% = request.servervariables("PATH_INFO") %>">
<TABLE ALIGN=CENTER CELLPADDING=1 CELLSPACING=1 BORDER=0
BGCOLOR="#60786B" STYLE="font-size:10pt;font-family:tahoma;">
<TR>
<TH COLSPAN=2 BGCOLOR="#EEEEEE">meta type</TH>
<TH BGCOLOR="#EEEEEE">name</TH>
<TH BGCOLOR="#EEEEEE">content</TH>
</TR>
<%
For i = 1 to MetaFormInputs
%>
<TR>
<TD BGCOLOR="#EEEEEE"> <% = i %>.) </TD>
<TD BGCOLOR="#FFFFEE">
<SELECT NAME="metatype">
<OPTION VALUE="">--select--</OPTION>
<OPTION VALUE="name">NAME</OPTION>
<OPTION VALUE="http-equiv">HTTP-EQUIV</OPTION>
</SELECT>
</TD>
<TD BGCOLOR="#FFFFEE">
<INPUT TYPE=TEXT NAME="metaname"
VALUE="" SIZE=25>
</TD>
<TD BGCOLOR="#FFFFEE">
<TEXTAREA NAME="metacontent" COLS=35
WRAP=VIRTUAL ROWS=2></TEXTAREA>
</TD>
</TR>
<%
Next
%>
</TABLE><BR><CENTER>
<INPUT TYPE=SUBMIT VALUE="Create The Tags Above">
<INPUT TYPE=BUTTON VALUE="Generate Some Tags For Me"
ONCLICK="javascript:generateTags();">
</CENTER></FORM>
<SCRIPT LANGUAGE=javascript>
function generateTags() {
var t = "";
var s = navigator.appName;
if (s.toLowerCase() != "microsoft internet explorer") {
t += "The tag generation code only works for IE! ";
t += "Enter some tags yourself and click ";
t += "the \"Create the tag above\" button. Sorry. ";
t += "Due to time constraints I didn't have time ";
t += "to create netscape specific code here - I figured ";
t += "95% of my traffic uses IE 5 or 6 so why bother...";
alert(t);
return;
}
var frmname = document.frm1.metaname;
var frmcont = document.frm1.metacontent;
var frmtype = document.frm1.metatype;
frmtype.metatype[0].selectedIndex = 1;
frmname.metaname[0].value = "keywords";
frmcont.metacontent[0].value =
"asp code, bad attempts at humor, vbscript, jscript, COM";
frmtype.metatype[1].selectedIndex = 1;
frmname.metaname[1].value = "description";
frmcont.metacontent[1].value =
"The ASP Emporium: free VBScript and JScript source code";
frmtype.metatype[2].selectedIndex = 2;
frmname.metaname[2].value = "refresh";
frmcont.metacontent[2].value =
"0; URL=/aspEmporium/index.asp";
document.frm1.submit();
}
</SCRIPT>
<%
End Sub
End Class
'************************ END CLASS DEFINITION *************************
|