include ../layouts/mixins
mixin project-card(project)

  - var tagService = ""
  each category in project.categories
    if category.name === 'Web Services'
      - tagService = t['Web Service']

  .card
    a.btn-rectangle(href=routes.projects + project.slug title=project.description)
      img.card-logo(src= routes.logos + project.logo, alt=project.logo)
      .title= project.name
      .small!= h.truncate(project.description, 140)
      .tags
        if project.nonfree
          .tag.red= t.Nonfree
        if tagService !== ""
          .tag= tagService
        if project.audit
          if project.audit.rating == 1
            .tag.yellow= t.Audited
          else
            .tag.green= t.Audited
        if project.development_stage
          if project.development_stage == "experimental"
            .tag.yellow= t.Experimental

    a.btn-square(href=project.url)
      i.fa.fa-external-link-square

mixin project-card-all(project)

  .card
    a.btn-rectangle(href=routes.projects + project.slug title=project.description)
      img.card-logo(src= routes.logos + project.logo, alt=project.logo)
      .title= project.name
      .small!= h.truncate(project.description, 140)
      .tags
        if project.nonfree
          .tag.red= t.Nonfree
        if project.audit
          if project.audit.rating == 1
            .tag.yellow= t.Audited
          else
            .tag.green= t.Audited
        if project.development_stage
          if project.development_stage == "experimental"
            .tag.yellow= t.Experimental
        each category in project.categories
         .tag
           if category.name == "Routers" || category.name == "Servers" || category.name == "Web Services"
             = t[category.name]
           else
             = category.name


    a.btn-square(href=project.url)
      i.fa.fa-external-link-square

mixin project-head(project)
  - var subcategories = []
  each subcategory, i in project.categories[0].subcategories
    if i === project.categories[0].subcategories.length - 1
      - subcategories += t[subcategory.name]
    else
      - subcategories += t[subcategory.name] + ', '
  .box
    .card.head.max
      .btn-rectangle
        img.card-logo(src= routes.logos + project.logo, alt=project.logo)
        .title= project.name
        .small= subcategories

    - if(project.description !== '')
      .text-block!= h.marked(project.description)

mixin project-tail(project)

  .section
    .pipe= t['More Info']

    a.bar(href=project.url)
      .label= t['Official Website']
      .icon: i.fa.fa-external-link

    - if(project.onion_url && project.onion_url !== '')
      a.bar(href=project.onion_url)
        .label= t['Onion service']
        .icon: i.fa.fa-external-link

    - if(project.wikipedia_url && project.wikipedia_url !== '')
      a.bar(href=project.wikipedia_url)
        .label= t['Wikipedia Article']
        .icon: i.fa.fa-external-link

    - if(project.privacy_url && project.privacy_url !== '')
      a.bar(href=project.privacy_url)
        .label= t['Privacy Policy']
        .icon: i.fa.fa-external-link

    - if(project.tos_url && project.tos_url !== '')
      a.bar(href=project.tos_url)
        .label= t['Terms of Service']
        .icon: i.fa.fa-external-link

  - if(project.notes && project.notes !== "")
    .section
      .pipe= t['Security Notes']
      .text-block!= h.marked(project.notes)

  - if(project.audit)
    .section.audit
      .pipe= t['Audit Notes']
      .text-block
        != h.marked(project.audit.description)
        p
          = t.Audited + ' ' + project.audit.date + ' ' + t.by + ' ' +  project.audit.author
          a(href=project.audit.url)= " (" + t["Audit Report"] + ")"

  - if(project.protocolsSlugged.length > 0)
    .section
      .pipe= t['Supported Protocols']
      for protocol in project.protocolsSlugged
        a.bar(href=`../../protocols/${protocol.slug}`)
          .label= protocol.name
          .icon
            i.fa.fa-angle-right.ltr
            i.fa.fa-angle-left.rtl

      +filler-bars(project.protocolsSlugged)

  .section
    .pipe= t['Development Info']

    - if(project.license_url !== '')
      a.bar(href=project.license_url)
        .label= t['Project License']
        .icon: i.fa.fa-external-link
    - else
      .bar.warning= t['Project License Unavailable']

    - if(project.source_url !== '')
      a.bar(href=project.source_url)
        .label= t['Source Code']
        .icon: i.fa.fa-external-link
    - else
      .bar.warning= t['Source Code Unavailable']
