My readers know by now that I'm trully smitten by Model-Glue, so I try to push/evangelize it whenever I can. I thought I'd share some MG code to see if it would help others. The ColdFusion Cookbook site is a MG site and I've attached the source to this entry.
Now - I don't want you to think I'm being humble - but please remember that I'm still a newbie at MG. This is only my second MG site, and it was written very quickly since I wanted to launch the cookbook site as fast as possible. This code example is not best practices. I think I still have a lot to learn about MG. But my hope is that this code will give others some more examples from which to learn MG. (And hey - Joe, Doug, Sean, feel free to rip me a new one on my comments. I want to learn as well! :)
p.s. I forgot to mention. This is the complete source code except for the removal of the serial code for the Captcha component, and I removed my admin authentication code.
Archived Comments
Thanks Ray!
Now I'd like to announce two new products I am releasing:
The Rabid_ModelGlue framework and The Rabid_Cookbook.
It'll take me about 20 minutes to strip out any references to the actual creators, and encrypt the files, but then these incredible NEW products will be available at my website.
Oh.. and don't forget to make a donation to me for honoring your work.
Heh - ok folks - I know everyone loves to pick on him - but if you don't mind, I'd rather this all just stop, ok?
You might want to rename the kill.cfm template on your website--or at least protect the file (maybe you have.)
You probably don't want people deleting comments at will. Also, I'd probably put all those special files into a protected sub-directory and not include those with the source file.
Ah - but I use UUIDs. ;) If a person can guess a UUID for a comment, more power to em. ;)
You are a STUD, Ray!
Is this code set up to use friendly urls by default or something? if so, i dont think it is working (in my configuration).
After figuring out what tables to create, i was able to get the main page to come up fine, but the navigation links were wacked out.
to get past this I had to edit the navagation tabs to insert the ?event= into the url
if not, the href pointed to folders that didn't exist like /FAQ
anyone else have a simular problem?
Wow - I wasn't actually thinking people would _run_ it. I thought they would just look at it. But yes, it is meant to use SES urls. If you have Apache, you can just use the following:
RewriteEngine on
RewriteRule /categories /\?event=categories [PT]
RewriteRule /faq /\?event=faq [PT]
RewriteRule /submit /\?event=submitform [PT]
RewriteRule /category/([0-9]+)/.* /\?event=showentries&id=$1 [PT]
RewriteRule /entry/([0-9]+)/.* /\?event=showentry&id=$1 [PT]
RewriteRule /search /\?event=search [PT]
RewriteRule /rss /\?event=rss [PT]
RewriteRule /downloadwithcomments /\?event=download&comments=true [PT]
RewriteRule /download /\?event=download [PT]
Hi
i am newbi to model-glue application
i have downloaded the modelglue sample application , from where can i get the database scripts?
Vishnu - It wasn't my intent per se that folks would take this code and actually run it. That's why I didn't include the db scripts.
Hi Ray
Can you provide me the SQL Script for the cookbook. so that i can try to run and learn how it is implemented
Not sure how well it will paste, but here goes nothing:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[comments]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[comments](
[id] [int] IDENTITY(1,1) NOT NULL,
[entryidfk] [int] NOT NULL,
[name] [nvarchar](255) NOT NULL,
[emailaddress] [nvarchar](255) NOT NULL,
[comment] [ntext] NOT NULL,
[created] [datetime] NOT NULL,
[token] [nvarchar](35) NOT NULL,
CONSTRAINT [PK_comments] PRIMARY KEY CLUSTERED
(
[id] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[authors]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[authors](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nvarchar](255) NOT NULL,
[emailaddress] [nvarchar](255) NOT NULL,
[website] [nvarchar](255) NOT NULL,
CONSTRAINT [PK_authors] PRIMARY KEY CLUSTERED
(
[id] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[categories]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[categories](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [nvarchar](255) NOT NULL,
[description] [nvarchar](4000) NOT NULL,
CONSTRAINT [PK_categories] PRIMARY KEY CLUSTERED
(
[id] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[entries]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[entries](
[id] [int] IDENTITY(1,1) NOT NULL,
[authoridfk] [int] NOT NULL,
[question] [nvarchar](4000) NOT NULL,
[answer] [ntext] NOT NULL,
[created] [datetime] NOT NULL,
[lastupdated] [datetime] NOT NULL,
CONSTRAINT [PK_entries] PRIMARY KEY CLUSTERED
(
[id] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[entries_categories]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[entries_categories](
[entryidfk] [int] NOT NULL,
[categoryidfk] [int] NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[textblocks]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[textblocks](
[id] [int] IDENTITY(1,1) NOT NULL,
[label] [nvarchar](255) NOT NULL,
[body] [ntext] NOT NULL,
CONSTRAINT [PK_textblocks] PRIMARY KEY CLUSTERED
(
[id] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END