GCN - A Community Driven Upgrade to the CSK

Last post 12-10-2008 5:48 PM by pdepaso. 39 replies.

Sort Posts:

  • GCN - A Community Driven Upgrade to the CSK

    04-13-2005, 11:02 AM
    • Contributor
      5,268 point Contributor
    • Redd
    • Member since 06-21-2002, 3:50 PM
    • Greenville SC
    • Posts 1,057

    The GotCommunityNet (GCN) project is a community driven development project based on the C# Visual Studio version of the CSK (the CSVS version).

    GCN 1.1 includes important CSK fixes and common mods. It remains largely compatible with the CSK 1.0. The GCN also includes an upgrade option to convert your CSK 1.0 database to GCN 1.1 while preserving your content.

    For more on the GCN visit these resources:

    The GCN Forums: Support and discussion of GCN

    The GCN project Workspace: Download GCN 1.1 here

    The GCN Documentation: See the what's new section to see what mods and fixes are in GCN 1.1

    Download Mirror Location: Stephen Redd hosts a copy of the GCN 1.1 downloads for those times when the workspace is offline (at the time of this writing this is about every other day Stick out tongue [:P])

    GotCommunityNet official site: The official web site of the GCN project

     

    A GCN 2.0 project for the ASP.NET 2.0 platform is currently under discussion, but no formal schedule has been released.

    Stephen M. Redd
    http://www.reddnet.net
  • Re: GCN - A Community Driven Upgrade to the CSK

    05-03-2005, 3:56 PM
    • Participant
      868 point Participant
    • BillKrat
    • Member since 08-19-2003, 7:30 PM
    • Amarillo, tx
    • Posts 176

    The following steps will permit you to get GCN 1.1 up and running under ASP.NET 2.0.   It is a work in progress and I'll update as I go along - the objective is to get GCN 1.1 running under ASP.NET 2.0, prior to making any modifications so developers can unzip, apply changes, and have it run under ASP.NET 2.0 

    I am running the GCN under ASP.NET 2.0 using SQL Server 2005

    Note: The following assumes that you have Visual Studio 2005 (click here for 180 day trial version) and have converted the project to ASP.NET 2.0. 

    Jody has provided step by step procedures for the conversion on the following post: 
    http://forums.asp.net/1111663/ShowPost.aspx 

    AFTER PROJECT CONVERSION

    /Communities/Common/Images/HtmlTextBoxUserImages
       ---------------------------------------------------
       Images won't upload in HtmlTextBox editor
       ---------------------------------------------------
       + Turned on write access to folder     2005-05-13

    /Scripts

      ---------------------------------------------------
      When entering Edit Section the default (general) panel disappears
      ---------------------------------------------------

      + tabstrip.js    2005-05-11
         -
    Modified Line 7 ... Changed (i=2; i <divs.length; i++) to
    (i=3; i < divs.length; i++)


    /App_code/Engine/Framework/BaseClasses

      ---------------------------------------------------
      Only default skin loads without error (can't find fail over files)
      ---------------------------------------------------

     + SkinnedCommunityControl.cs    2005-05-11
       
    - Modified Line 172 ....  Changed exception from FileNotFoundException to catch (HttpException fnfEx)     
        - Modified Line 244 ....  Changed exception from FileNotFoundException to
    catch (HttpException fnfEx)


    /App_code/Engine/Framework/ContentPages/Controls/   

     + Web.config
        - Modified connection string as applicable


      ---------------------------------------------------
      ButtonType will become ambiguous under ASP.NET 2.0
      ---------------------------------------------------

    + HtmlTextBox.cs
        - Added line 17 ........ using ASPNET.StarterKit.Communities;
        - Modified line 1527 ... changed ButtonType.Image to HtmlTextBoxControls.ButtonType.Image
                                        ... changed (ButtonType) to (HtmlTextBoxControls.ButtonType)
        - Modified line 1532 ... changed ButtonType.Image to HtmlTextBoxControls.ButtonType.Image
        - Modified line 1845 ... changed ButtonType.FormButton to HtmlTextBoxControls.ButtonType.FormButton
        - Modified line 2704 ... changed ButtonType.FormButton to HtmlTextBoxControls.ButtonType.FormButton


      ----------------------------------------------------------------------------------
      Resource manager will not find HtmlTextBox.resx resource under ASP.NET 2.0
      ----------------------------------------------------------------------------------

     + HtmlTextBox.resx  
        - Copy from CSKDotNet\Engine\Framework\ContentPages\Controls to \App_GlobalResources

     + HtmlTextBox.cs
        - Added line 1799 ... return Resources.HtmlTextBox.ResourceManager.GetString(key).ToString();
        - Remarked out remaining code in GetResourceStringFromResourceManager()


      ----------------------------------------------------------------------------------
      Images not appearing (mapping issue)
      ----------------------------------------------------------------------------------
      SOLUTION #1:  Manually applied the Redd's patches (differences between supplied files and GCN 1.1)  took about 20 minutes and worked great!  The link follows:    http://www.reddnet.net/Programming/CSK+Stuff/CSK+Files/CSK+1.0/646.aspx


      SOLUTION #2:  Apply the following code changes (areas in red are new/modified code):

    http://forums.asp.net/1118595/ShowPost.aspx#1118595 explains why the code below fixes the images issue.
     
    Engine/Framework/BaseClasses/ 
      + CommunitiesModule.cs

    public class CommunitiesModule : IHttpModule {

    ADD THE FOLLOWING CODE AFTER THE ABOVE STATEMENT:

            // WK.2005.11.19 IMAGE HANDLING UPDATE
            static public string GetHandledImageName(string tsFileName) {
                return tsFileName + ".img.aspx";
            }

     
    private void Application_BeginRequest(object source, EventArgs e) {
        ...
        ...
        // Figure out the page and add to Context
        if (requestPath.EndsWith(".aspx")) {   
    <<- Find this line

    ADD THE FOLLOWING CODE AFTER THE ABOVE STATEMENT:  

                    // WK.2005.11.19  IMAGE HANDLING UPDATE
                    // .img.aspx is a programmatically assigned extension that ends
                    // with .aspx so that IIS will process it.  Once here we can
                    // rewrite the context to the actual image name (strip off the
                    // .img.aspx) so that the application can process it as normal.
                    if (requestPath.EndsWith(".img.aspx")) {
                        Context.RewritePath(requestPath.Replace(".img.aspx",""));
                        ImageHandler loImage = new ImageHandler();
                        loImage.ProcessRequest(HttpContext.Current);
                    }


    Engine/Framework/ContentPages/Controls
      +
    Logo.cs

    void RenderLogoImage(HtmlTextWriter writer) {
        writer.AddAttribute(HtmlTextWriterAttribute.Href, CommunityGlobals.ResolveBase("default.aspx"));
        writer.RenderBeginTag(HtmlTextWriterTag.A);
        // WK.2005.11.19 Add CommunitiesModule method reference
        //writer.Write(String.Format("<img src=\"{0}\" border=\"0\" />", objSectionInfo.Logo));
        writer.Write(String.Format("<img src=\"{0}\" border=\"0\" />", CommunitiesModule.GetHandledImageName(objSectionInfo.Logo)));
        writer.RenderEndTag();
    }


    Engine/Framework/Images/Components
      + ImageUtility.cs

       
       public static string BuildImagePath(int id, string fileName) {
                string extension = Path.GetExtension(fileName).ToLower();
                //WK.2005.11.19  New image handler support
                //return id.ToString() + extension;
                return id.ToString() + extension +".img.aspx";
          }

          public static string BuildFullImagePath(int sectionID, int imageID, string fileName) {
                string path = SectionUtility.GetSectionPath(sectionID);
                path = path.Remove( path.LastIndexOf("/"), path.Length - path.LastIndexOf( "/" ) );
                string extension = Path.GetExtension(fileName).ToLower();
                // WK.2005.11.19 New image handler support
                //return String.Format("{0}/{1}{2}", path, imageID, extension);
                return String.Format("{0}/{1}{2}.img.aspx", path, imageID, extension);
         }


    Admin/EditSections
      +SectionAppearance.ascx.cs
     
    protected void Page_Load(object sender, System.EventArgs e)
        ...
        ...
       if (Section.Logo != String.Empty)
             ImgLogoPreview.ImageUrl = ResolveUrl(
    "~/" + Section.Logo
    );
       else

    CHANGE THE ABOVE LINE TO

       if (Section.Logo != String.Empty)
             ImgLogoPreview.ImageUrl = ResolveUrl(
    "~/" + Section.Logo + ".img.aspx"
    );
       else


     

  • Re: GCN - A Community Driven Upgrade to the CSK

    12-21-2005, 6:42 PM
    • Member
      327 point Member
    • dkzeng
    • Member since 04-30-2005, 1:46 AM
    • Posts 64

    hi,billcrat :

    i mod my code as your code which high light with red color.  but i try above at least 2 hour to test .but i also failed to display image in my page except home link logo.img.asp.illustrate here:



    at last, i found a bug in    Engine..../...../ImageHandler.cs,...

          // Get image parameters from query string
                if (context.Request.QueryString["width"] != null)
                    width = Int32.Parse(context.Request.QueryString["width"]);
                   
                if (context.Request.QueryString["height"] != null)
                    height = Int32.Parse(context.Request.QueryString["height"]);

    track again and again , found height always equal to -1 except home link, such as:

    home link logo image:http://221.10.254.207/rocky/ad.jpg.img.aspx

    gallery :http://221.10.254.207/Rocky/Photo+Gallery/9.jpg.img.aspx?Width=100&Height=-1

    gallery2:http://221.10.254.207/Rocky/Photo+Gallery/7.jpg.img.aspx?Width=100&Height=-1

    i do not have a solution ,i did only a way to solve this issue: force to set Height =100px because i do not have enough alknowlege . any body have a good solution , please try... 

    i want to fly ...
  • Re: GCN - A Community Driven Upgrade to the CSK

    12-22-2005, 12:05 AM
    • Participant
      868 point Participant
    • BillKrat
    • Member since 08-19-2003, 7:30 PM
    • Amarillo, tx
    • Posts 176

    [dkzeng ] i mod my code as your code which high light with red color.  but i try above at least 2 hour to test .but i also failed to display image in my page except home link logo.img.asp.illustrate here:

    Hi dkzeng,

    This is going to be a tough one to isolate - particularly since there are numerous affected files that must all be in sync...  My modifications were based on a "clean" install of the application.   If you do a right-click on your examples you'll find that your using "ShowImage.aspx" to display your images; my code will never run.  

    http://221.10.254.207/4kzeng/freeupload/ShowImage.aspx?id=25
    http://221.10.254.207/4kzeng/freeupload/ShowImage.aspx?id=26

    This suggest that there may be an incompatible mismatch of patches to resolve the image issue which could be causing your height bug (I have not encountered any issues and this is the first report I've received).

    Wish I could be of more help...

     

     

     

     

     

     

  • Re: GCN - A Community Driven Upgrade to the CSK

    12-22-2005, 8:12 AM
    • Member
      327 point Member
    • dkzeng
    • Member since 04-30-2005, 1:46 AM
    • Posts 64

    today , i fix the bug successfully, it cost me 2 day to debug again and again ,at last , i solved it .

    why the image can't display except the first one .

    because the code :

    Engine/image/compoments/imagehandler.cs
    private void DisplaySectionImage(HttpContext context, int sectionID, int imageID, int width, int height, bool thumbnail) {
         context.Response.BinaryWrite( ImageUtility.GetSectionImage(sectionID, imageID, width, 100, thumbnail));
        }

    the BinaryWrite the first image , it didn't mix any other message ,so the first image display right propertly.

    but when the coming image would mix some other info-message about http protocols.so the image cannot display because those info cause it corrupted .

    this can explain why in local host can display sucessful but remote do not ,because network in local much less of other info.

    Mod as here to solve this issue:

      context.Response .Clear ();
      context.Response.BinaryWrite( ImageUtility.GetSectionImage(sectionID, imageID, width, 100, thumbnail));
       context.Response .End();

     

    i want to fly ...
  • Re: GCN - A Community Driven Upgrade to the CSK

    12-22-2005, 8:38 AM
    • Member
      10 point Member
    • daviddoughty
    • Member since 12-22-2005, 1:31 PM
    • Posts 2

    Bill

    I have asked my ISP to make the IIS changes to allow images to be displayed but don't hold out much hope they'll do it.

    In the meantime I'm trying your mods. I'm using vb with .net framework 1.1 and so far have managed to get the images saving with the .img.aspx extension but I'm having problems getting them to display - Is Application_BeginRequest in CommunitiesModule the only place the .img.aspx extension gets dealt with?

    David

  • Re: GCN - A Community Driven Upgrade to the CSK

    12-22-2005, 8:48 AM
    • Member
      327 point Member
    • dkzeng
    • Member since 04-30-2005, 1:46 AM
    • Posts 64

    i am sorry to post again , because i could not edit my post ,the " 100" come with my first mistake idea .

    above my post ,should to :

    Engine/image/compoments/imagehandler.cs
    private void DisplaySectionImage(HttpContext context, int sectionID, int imageID, int width, int height, bool thumbnail) {
    //find this line and add "...Clear();"
       context.Response .Clear ();
                context.Response.BinaryWrite( ImageUtility.GetSectionImage(sectionID, imageID, width, height, thumbnail));

    //add "...End();"
       context.Response .End();

            }

    in the same file mod again
     private void DisplayCommunityImage(HttpContext context, string fileName) {
    ............
        context.Response.ContentType = dr["Image_contenttype"].ToString();
       // find this line  and add ".....Clear();" again.
        context.Response .Clear ();
        context.Response.BinaryWrite((byte[])buffer );
       //add "....End()" again 
        context.Response .End ();

     

    by the way , and my slowly web site , you take a look after fixed

    http://221.10.254.207/rocky

     

    i want to fly ...
  • Re: GCN - A Community Driven Upgrade to the CSK

    12-22-2005, 10:00 AM
    • Participant
      868 point Participant
    • BillKrat
    • Member since 08-19-2003, 7:30 PM
    • Amarillo, tx
    • Posts 176

    Hi David,

    [David] Is Application_BeginRequest in CommunitiesModule the only place the .img.aspx extension gets dealt with?

    Yes, it is the only place - all of the code modifications are about getting the .img.aspx extension attached to any images.   This is where we gain our independence from ISPs because an .aspx extension will always be processed by .NET and by default the file does not have to exists -  all we have to do is then send the image to the response.stream via BinaryWrite.

    Your timing may be perfect because it appears that dkzeng may have found the answer to your problem.   Can you try his mod and let us know if it fixes it?   If it doesn't we'll brainstorm and see if we can't get it figured out.

    Engine/Framework/image/components/imagehandler.cs
    private void DisplaySectionImage(HttpContext context, int sectionID, int imageID, int width, int height, bool thumbnail) {
       //find this line and add "...Clear();"
       context.Response .Clear ();
                context.Response.BinaryWrite( ImageUtility.GetSectionImage(sectionID, imageID, width, height, thumbnail));

       //add "...End();"
       context.Response .End();

    }

  • Re: GCN - A Community Driven Upgrade to the CSK

    12-22-2005, 10:57 AM
    • Member
      10 point Member
    • daviddoughty
    • Member since 12-22-2005, 1:31 PM
    • Posts 2

    Yep - that did it!

    Thanks for that Bill.

    If anayone wants the vb code then let me know

  • Re: GCN - A Community Driven Upgrade to the CSK

    12-22-2005, 12:10 PM
    • Participant
      868 point Participant
    • BillKrat
    • Member since 08-19-2003, 7:30 PM
    • Amarillo, tx
    • Posts 176

    Your welcome, but the credit needs to go to dkzeng - looks like he saved us all a bunch of debugging brain-strain time!

    Thanks dkzeng!

     

     

  • Re: GCN - A Community Driven Upgrade to the CSK

    12-22-2005, 12:56 PM
    • Member
      327 point Member
    • dkzeng
    • Member since 04-30-2005, 1:46 AM
    • Posts 64

    haha, billcrat ,you are a kind man answered my question again and again,cheers!

     

    i want to fly ...
  • Re: GCN - A Community Driven Upgrade to the CSK

    03-16-2006, 10:36 PM
    • Participant
      868 point Participant
    • BillKrat
    • Member since 08-19-2003, 7:30 PM
    • Amarillo, tx
    • Posts 176

    Can't edit original post so I'll do a continuation.   Found two areas that would still not display images - the fixes follow:

    Engine\Framework\Topics\Controls\DisplayTopic.cs

            protected override void RenderContents(HtmlTextWriter tw) {
                string imageTag;
                string imagePath;

                // Calculate topic path
                string topicPath = String.Format("~/Topic.aspx?topic={0}", Context.Server.UrlEncode(_name));
                topicPath = Page.ResolveUrl(topicPath);
                
                
                tw.AddAttribute(HtmlTextWriterAttribute.Href, topicPath);
                tw.RenderBeginTag(HtmlTextWriterTag.A);
                if (Image == String.Empty)
                    tw.Write( _name );
                else {
                    imagePath = Page.ResolveUrl( "~/" + _image);
                    imageTag = String.Format("<img src=\"{0}.img.aspx\" ALT=\"{1}\" border=\"0\">", imagePath, _name);
                    tw.Write(imageTag);
                }
                tw.RenderEndTag();
            }
        }

    ADMIN | EDIT IMAGES
    GetAllCommunityImages stored procedure updated to support new extension

    ALTER PROCEDURE [dbo].[Community_ImagesGetCommunityImages]
    (
      @communityID int
    )
    AS
    SELECT
         Image_ID,
         Image_FileName+'.img.aspx' as Image_FileName
    FROM
         Community_CommunityImages
    WHERE
         Image_CommunityID = @communityID
    ORDER BY
         Image_DateCreated DESC

  • Re: GCN - A Community Driven Upgrade to the CSK

    04-07-2006, 6:05 PM
    • Member
      10 point Member
    • markem
    • Member since 04-07-2006, 9:57 PM
    • Posts 2

    During the conversion, I found I could leave the image map to the engine the same, as long as I changed the web.config in the sub directories to the following:

     
    <configuration>

        <system.web>
        <httpHandlers>
       <add verb="GET" path="*.jpg" type="System.Web.StaticFileHandler" />
    <add verb="GET" path="*.jpeg" type="System.Web.StaticFileHandler" />
    <add verb="GET" path="*.gif" type="System.Web.StaticFileHandler" />
        </httpHandlers>
       
        </system.web>
    </configuration>

     Also, by adding changing the writing of the header in the page_init of communityDefault.aspx.cs to the following, I can use some of the new .NET 2.0 controls that require a server html head:

     

     

     
                StringBuilder objBuilder = new StringBuilder();
                objBuilder.Append("&lt;!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n");
                objBuilder.Append("&lt;html lang=\"en-us\"&gt;");
                Controls.Add(new LiteralControl(objBuilder.ToString()));	   
                HtmlHead head = new HtmlHead();
                head.ID = "pageHead";
                head.Title = objPageInfo.Title;
                Controls.Add(head);
                
                HtmlLink link = new HtmlLink();
                link.Href = CommunityGlobals.ResolveBase("Communities" + "/" + objSectionInfo.Style);
                link.ID = "communityStyleSheet";
                link.Attributes.Add("type", "text/css");
                link.Attributes.Add("rel", "stylesheet");
                head.Controls.Add(link);
    
                HtmlMeta meta = new HtmlMeta();
                meta.ID = "metaLanguage";
                meta.Name = "Language";
                meta.Content = "en-US";
                head.Controls.Add(meta);
    
                meta = new HtmlMeta();
                meta.ID = "metaKEYWORDS";
                meta.Name = "KEYWORDS";
                meta.Content = Server.HtmlEncode(objPageInfo.MetaKeys);
                head.Controls.Add(meta);
    
                meta = new HtmlMeta();
                meta.ID = "metaDESCRIPTION";
                meta.Name = "DESCRIPTION";
                meta.Content = Server.HtmlEncode(objPageInfo.MetaDesc);
                head.Controls.Add(meta);
    
                meta = new HtmlMeta();
                meta.ID = "metaPAGETYPE";
                meta.Name = "PAGETYPE";
                meta.Content = Server.HtmlEncode(objPageInfo.Content);
                head.Controls.Add(meta);
    
                meta = new HtmlMeta();
                meta.ID = "metaASPNETStarterKit";
                meta.Attributes.Add("ASPNETSTARTERKIT", "CommunitySK");
                meta.Attributes.Add("Version", "CSVS 1.0");
               head.Controls.Add(meta);
               
                //objBuilder = new StringBuilder();
                objBuilder = new StringBuilder();
               
                // Add the Page Head to the Page
                objBuilder.Append( "\n<body marginheight=\"0\" marginwidth=\"0\" leftmargin=\"0\" rightmargin=\"0\" class=\"pageBody\"&gt;\n" );
                //Controls.Add( new LiteralControl( objBuilder.ToString() ) ); 
                Controls.Add(new LiteralControl(objBuilder.ToString()));
  • Re: GCN - A Community Driven Upgrade to the CSK

    04-10-2006, 7:31 PM
    • Participant
      868 point Participant
    • BillKrat
    • Member since 08-19-2003, 7:30 PM
    • Amarillo, tx
    • Posts 176

    To ensure that the issue with images is fully understood by developers new to the CSK that might read your message  I would like to note that the <httphandler> only works with mapped files on IIS; if ASP.NET is not handling the specified extensions then the code will never run.  

    If you found that the following configuration runs on your local system (and remote server) then you have the necessary mappings.  There are cases, such as mine, where ISPs have heavy security constraints and won't permit mapping - thus the reason for the changing the extension to img.aspx (which will be handled by ASP.NET regardless of mappings).

    During the conversion, I found I could leave the image map to the engine the same, as long as I changed the web.config in the sub directories to the following:

    <configuration>
        <system.web>
           <httpHandlers>
              <add verb="GET" path="*.jpg" type="System.Web.StaticFileHandler" />
              <add verb="GET" path="*.jpeg" type="System.Web.StaticFileHandler" />
              <add verb="GET" path="*.gif" type="System.Web.StaticFileHandler" />
        </httpHandlers>

     

  • Re: GCN - A Community Driven Upgrade to the CSK

    04-13-2006, 11:14 AM
    • Member
      10 point Member
    • markem
    • Member since 04-07-2006, 9:57 PM
    • Posts 2
    Yes, sorry. This does assume that you are setting up the CSK as it was originally developed to handle images. Adding the mappings can be a big pain in an ISP environment, and even if you do control the server, it can be a pain. Whenever I have time (more than likely never :) ), I intend to look at using an axd handler for image handling.
Page 1 of 3 (40 items) 1 2 3 Next >