diff --git a/.github/workflows/generator-generic-ossf-slsa3-publish.yml b/.github/workflows/generator-generic-ossf-slsa3-publish.yml new file mode 100644 index 0000000..a249449 --- /dev/null +++ b/.github/workflows/generator-generic-ossf-slsa3-publish.yml @@ -0,0 +1,68 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow lets you generate SLSA provenance file for your project. +# The generation satisfies level 3 for the provenance requirements - see https://slsa.dev/spec/v0.1/requirements +# The project is an initiative of the OpenSSF (openssf.org) and is developed at +# https://github.com/slsa-framework/slsa-github-generator. +# The provenance file can be verified using https://github.com/slsa-framework/slsa-verifier. +# For more information about SLSA and how it improves the supply-chain, visit slsa.dev. + +name: SLSA generic generator +on: + workflow_dispatch: + release: + types: [created] + +permissions: read-all + +jobs: + build: + runs-on: ubuntu-latest + outputs: + digests: ${{ steps.hash.outputs.digests }} + + steps: + - uses: actions/checkout@v3 + + # ======================================================== + # + # Step 1: Build your artifacts. + # + # ======================================================== + - name: Build artifacts + run: | + # These are some amazing artifacts. + echo "artifact1" > artifact1 + echo "artifact2" > artifact2 + + # ======================================================== + # + # Step 2: Add a step to generate the provenance subjects + # as shown below. Update the sha256 sum arguments + # to include all binaries that you generate + # provenance for. + # + # ======================================================== + - name: Generate subject + id: hash + run: | + set -euo pipefail + + # List the artifacts the provenance will refer to. + files=$(ls artifact*) + # Generate the subjects (base64 encoded). + echo "::set-output name=digests::$(sha256sum $files | base64 -w0)" + + provenance: + needs: [build] + permissions: + actions: read # To read the workflow path. + id-token: write # To sign the provenance. + contents: write # To add assets to a release. + uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.2.0 + with: + base64-subjects: "${{ needs.build.outputs.digests }}" + upload-assets: true # Optional: Upload to a new release diff --git a/src/main/java/org/launchcode/techjobs/mvc/controllers/ListController.java b/src/main/java/org/launchcode/techjobs/mvc/controllers/ListController.java index 71cb0cd..201e5e2 100644 --- a/src/main/java/org/launchcode/techjobs/mvc/controllers/ListController.java +++ b/src/main/java/org/launchcode/techjobs/mvc/controllers/ListController.java @@ -18,10 +18,8 @@ @Controller @RequestMapping(value = "list") public class ListController { - static HashMap columnChoices = new HashMap<>(); static HashMap tableChoices = new HashMap<>(); - public ListController () { columnChoices.put("all", "All"); columnChoices.put("employer", "Employer"); @@ -29,6 +27,8 @@ public ListController () { columnChoices.put("positionType", "Position Type"); columnChoices.put("coreCompetency", "Skill"); + + tableChoices.put("all",JobData.findAll()); tableChoices.put("employer", JobData.getAllEmployers()); tableChoices.put("location", JobData.getAllLocations()); tableChoices.put("positionType", JobData.getAllPositionTypes()); diff --git a/src/main/java/org/launchcode/techjobs/mvc/controllers/SearchController.java b/src/main/java/org/launchcode/techjobs/mvc/controllers/SearchController.java index d75fd42..29619d1 100644 --- a/src/main/java/org/launchcode/techjobs/mvc/controllers/SearchController.java +++ b/src/main/java/org/launchcode/techjobs/mvc/controllers/SearchController.java @@ -1,12 +1,17 @@ package org.launchcode.techjobs.mvc.controllers; +import org.launchcode.techjobs.mvc.models.Job; +import org.launchcode.techjobs.mvc.models.JobData; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; -import static org.launchcode.techjobs.mvc.controllers.ListController.columnChoices; +import java.util.ArrayList; +import static org.launchcode.techjobs.mvc.controllers.ListController.columnChoices; /** * Created by LaunchCode @@ -14,13 +19,23 @@ @Controller @RequestMapping("search") public class SearchController { - @GetMapping(value = "") public String search(Model model) { model.addAttribute("columns", columnChoices); return "search"; } - // TODO #3 - Create a handler to process a search request and render the updated search view. - + @PostMapping("results") + public String displaySearchResults(Model model, @RequestParam String searchType, @RequestParam String searchTerm){ + ArrayList jobsReturned = new ArrayList<>(); + if(searchTerm.toLowerCase().equals("all") || searchTerm.isEmpty()){ + jobsReturned = JobData.findAll(); + model.addAttribute("jobs",jobsReturned); + } else { + jobsReturned = JobData.findByColumnAndValue(searchType,searchTerm); + model.addAttribute("columns",columnChoices); + } + model.addAttribute("jobs",jobsReturned); + return "search"; + } } diff --git a/src/main/resources/templates/fragments.html b/src/main/resources/templates/fragments.html index 47aca7e..85530b1 100644 --- a/src/main/resources/templates/fragments.html +++ b/src/main/resources/templates/fragments.html @@ -7,8 +7,9 @@ - TechJobs + + diff --git a/src/main/resources/templates/list-jobs.html b/src/main/resources/templates/list-jobs.html index 9cd974d..92dac9a 100644 --- a/src/main/resources/templates/list-jobs.html +++ b/src/main/resources/templates/list-jobs.html @@ -2,7 +2,8 @@ - + +
@@ -11,8 +12,35 @@

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
ID
Name
Employer
Location
Position
Skill
+
- \ No newline at end of file diff --git a/src/main/resources/templates/list.html b/src/main/resources/templates/list.html index 9bb81de..5823316 100644 --- a/src/main/resources/templates/list.html +++ b/src/main/resources/templates/list.html @@ -1,36 +1,37 @@ - + - -
+ +
-
-

-

View Jobs By Category

-
+
+

+

View Jobs By Category

+
- - - - - - - - - - - - - -
-
    -
  • - -
  • -
-
- - + + + + + + + + + + + +
+
  • + View All +
  • +
    +
      +
    • + +
    • +
    +
    + \ No newline at end of file diff --git a/src/main/resources/templates/search.html b/src/main/resources/templates/search.html index 5ce00d0..abed8b4 100644 --- a/src/main/resources/templates/search.html +++ b/src/main/resources/templates/search.html @@ -3,7 +3,6 @@ -
    @@ -31,14 +30,40 @@

    Search by:

    + -
    - + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ID
    Name
    Employer
    Location
    Position
    Skill
    +
    - \ No newline at end of file