@using OurUmbraco.Project
@using Umbraco.Web
@{
    var ProjectsProvider = new OurUmbraco.MarketPlace.NodeListing.NodeListingProvider();
    var projectId = int.Parse(Request.QueryString["project_id"]);

    var qs = Request.RawUrl.Substring(Request.RawUrl.IndexOf('?') + 1).Replace("&project_id=" + projectId, "");
    var callback = Request.QueryString["callback"];

    var Project = ProjectsProvider.GetListing(projectId, false);
    var node = new umbraco.NodeFactory.Node(projectId);
    var parentId = node.Parent.Id;
    
    var pUrl = "repo/project?id=";

    string descCssClass = "noWrap";
    string ProjectCompatitbleWithUmbraco = "4.0";
    string ProjectCompatitbleWithDotNet = "4.0";
    string ProjectCompatitbleWithMediumTrust = "No";

    if (Project.Description.Length > 2000) { descCssClass = "wrap"; }

    int currentReleaseFile = 0;
    if (int.TryParse(Project.CurrentReleaseFile, out currentReleaseFile))
    {
        var file = Project.PackageFile.Where(x => x.Id == currentReleaseFile).FirstOrDefault();
        if (file != null)
        {
            var ct = "This project is compaitible with ";
            var c = file.UmbVersion.Count;

            var coms = file.UmbVersion;

            if (c > 2)
            {
                coms = file.UmbVersion.Take(2).ToList();
            }

            foreach (var com in coms)
            {

                ct += com.Name + ", ";
            }

            ct = ct.Trim().TrimEnd(',');

            if (c > 2)
            {
                ct += " and " + (c - 2) + " other versions.";
            }

            ProjectCompatitbleWithUmbraco = ct;
            ProjectCompatitbleWithDotNet = file.DotNetVersion;
            ProjectCompatitbleWithMediumTrust = (file.SupportsMediumTrust) ? "Yes" : "No";
        }
    }
}
<script type="text/javascript">
    jQuery("#projectDescriptionText a").click(function(event){event.preventDefault(); });
</script>

<ul id="breadcrumb">
    <li><a href="/repo?@qs">Repository</a> &rarr;</li>
  <li><a href="/repo_category?@qs&category_id=@parentId">@Project.GetCategoryName()</a> &rarr;</li>
    <li>@Project.Name</li>
</ul>

<div id="project">
    @if (currentReleaseFile != 0)
    {
        <h1 class="projectName">
            <span>@Project.Name</span>
            <a href="#" title="@Project.Name" rel="@Project.ProjectGuid" class="btn">Install package</a>
        </h1>
    }
    else
    {
        <span style="color: red;">Unfortunately, this package has no current release file to install at the moment.</span><br />
            <a href="https://our.umbraco.org/@node.NiceUrl" target="_blank">Go to the package page to learn more</a>}
    <div class="meta">

        <div class="box">

            <dl class="projetProps summary">
                <dt>Project owner:</dt>
                @{
                    var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
                    var ownerName = umbracoHelper.MembershipHelper.GetById(Project.VendorId).Name;
                }
            <dd>@ownerName</dd>

                <dt>Package downloads</dt>
                <dd>@Project.Downloads</dd>

                <dt>Package karma</dt>
                <dd>@Project.Karma</dd>

                <dt>Compatibility:</dt>
                <dd>
                    @ProjectCompatitbleWithUmbraco<br />
                    .NET Version: @ProjectCompatitbleWithDotNet<br />
                    Supports Medium Trust: @ProjectCompatitbleWithMediumTrust
                </dd>
                <dt>Created:</dt>
                <dd>
                    @Project.CreateDate.ToString("D")
                </dd>

                @if (Project.Stable)
                {
                    <dt>Is Stable:</dt>
                                <dd>
                                    <span class="green">Project is stable</span>
                                </dd>
                }
                <dt>Current version</dt>
                <dd>
                    @Project.CurrentVersion
                </dd>
                @if (!string.IsNullOrEmpty(Project.LicenseName))
                {
                    <dt>License</dt>
                                <dd>
                                    <a target="_blank" href="@Project.LicenseUrl">@Project.LicenseName</a>
                                </dd>
                }
            </dl>
        </div>
    </div>
    <div>

        <div id="projectDescriptionText" class="@descCssClass">
            @Html.Raw(Project.Description)
        </div>

        <div class="divider" style="clear:left;"></div>

        @if (Project.ScreenShots.Count() > 0)
        {

            <div id="projectScreenshots">
                <h2>Screenshots</h2>
                @foreach (var image in Project.ScreenShots)
                {
                    <a href="@image.Path" class="projectscreenshot" rel="shadowbox[gallery]">
                        <img src="@image.Path?bgcolor=fff&width=100&height=100&format=png" style="border:0;" />
                    </a>
                }
            </div>

            <div class="divider" style="clear:left;"></div>
        }

    </div>
