magento2 – Redirect header from API endpoint

I am trying to setup an API endpoint my mobile app can use to redirect to Google Play or Apple App Store depending on the device making the request. I have php code that was working stand alone and have created an endpoint in my module that accepts an anonymous GET request.

How do I pass a custom header via the API response, or does this need to be done with a controller?

class AppStore implements AppStoreInterface {

    /**
     * {@inheritdoc}
     */

    public function appstore()
    {
        // android store
        if (preg_match('#android#i', $_SERVER ('HTTP_USER_AGENT'))) {
            header('Location: market://details?id=com.google.android.apps.maps/...');
            return "android";
        }
        // ios
        if (preg_match('#(iPad|iPhone|iPod)#i', $_SERVER ('HTTP_USER_AGENT'))) {
            header('Location: itms://itunes.apple.com/us/app/....');
            return "ios";
        }
        // for another os
        return "Not supported";
    }
}

7 – Get input from Fulltext Search Filter in views_pre_render for Header

For Drupal 7 I found a workaround to a similar situation here, when combining Core search block forms and search api contextual filters. This “workaround” won’t work when using Search API, if you don’t want the Contextual Filter in your view.

My current setup:
I am using Search API, with a database server, and displaying the results with a Views page. I am using Search: Fulltext search (exposed) and Exposed form in block:Yes for the search block form.

What I am trying to achive:
I would like to put what was searched for in the Header of the view, and also at the top of No Results Behavior like this:

You searched for bananas

The problem:
When using Search: Fulltext search (exposed), the replacement patterns for the input value are not available in the Global Text Area. They are only available by adding a Fulltext Search Contextual Filter. There is an issue for this with a patch for Drupal 8 here.

My question:
Is there a views_pre_render or some other hook that can be used for the Header or No Results region to output the value that was input into the Search: Fulltext search (exposed) form?

There is a dev module to create a token, but it only works for the Results Summary.

Contest – $50 Facebook Video Header

Hi,

I am looking for a Facebook Page Cover Video Header.

The video should be 820 x 462 and be at least 20 seconds long.

I have attached my logo and an optional background image below.

I just want something simple and elegant, I don’t want anything too cheesy. If there is a slight 3d element to the logo fine. Maybe the logo swishing in.
SEMrush

If you want to use the free online tools to generate the video that’s fine as long as the end result looks good the $50 Paypal is yours!

Also if the main animation is only in the first 5/10 seconds that’s fine just extend the video longer to meet the 20 seconds minimum video length.

Thanks

https://www.ayrshirewebsitedesign.com/wp-content/uploads/2013/10/logo-1.png

https://www.ayrshirewebsitedesign.com/wp-content/uploads/2013/10/Background.jpg

 

javascript – Sticky Table Header in Plain JS

/* Sticky table header starts here */

  var table = document.getElementsByTagName("table");
  table = ().slice.call(table);
  var clonedTable = ();

  document.addEventListener("DOMContentLoaded", function () {
    for (i = 0; i < table.length; i++) {
      function init() {
        var wrapper = document.createElement("div"),
          clone = table(i).cloneNode(true),
          parent = table(i).parentNode;
        clone.classList.add("fixed");
        wrapper.classList.add("container");

        for (let j = 0; j < clone.tBodies.length; j++) {
          clone.removeChild(clone.tBodies(j));
        }
        wrapper.appendChild(clone);
        parent.insertBefore(wrapper, table(i));
        wrapper.appendChild(table(i));
        clonedTable.push(clone);

        resizeFixed();
      }

      function resizeFixed() {
        var ths = this.clonedTable(i).querySelectorAll('th'),
          ths2 = table(i).querySelectorAll('th');
        for (var u = 0; u < ths.length; u++) {
          ths(u).style.width = ths2(u).offsetWidth + 'px';
        }
      }

      init();
    }

  });

  window.addEventListener('resize', function () {
    for (let t = 0; t < clonedTable.length; t++) {
      var ths = this.clonedTable(t).querySelectorAll('th'),
        ths2 = table(t).querySelectorAll('th');
      for (var u = 0; u < ths.length; u++) {
        ths(u).style.width = ths2(u).offsetWidth + 'px';
      }
    }
  });

  window.addEventListener('scroll', function () {
    var offset = this.pageYOffset;
    for (var n = 0; n < table.length; n++) {
      var tableOffsetTop = table(n).offsetTop,
          tableOffsetBottom = tableOffsetTop + table(n).offsetHeight - table(n).tHead.offsetHeight;

      if (offset < tableOffsetTop || offset > tableOffsetBottom)
        clonedTable(n).style.display = 'none';

      else if (offset >= tableOffsetTop && offset <= tableOffsetBottom)
        clonedTable(n).style.display = 'table';
    }
  });  // working fine till now

  /* sticky table header script ends here */
body {
  font: 1.2em normal Arial, sans-serif;
  color: #34495E;
  text-align: center;
}

.container {
  width: 90%;
  margin: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

table th,
table td {
  border: 1px solid #eee;
}

th,
td {
  text-align: center;
  padding: 5px 0;
}

.blue {
  border: 2px solid #1ABC9C;
}

.blue thead {
  background-color: #1ABC9C;
}

.purple {
  border: 2px solid #9B59B6;
}

.purple thead {
  background: #9B59B6;
}

thead {
  color: white;
}

th,
td {
  text-align: center;
  padding: 5px 0;
}

tbody tr:hover {
  background: #f1f5f7;
  /* color:#FFFFFF; */
}

.fixed {
  top: 0;
  position: fixed;
  width: auto;
  display: none;
  border: none;
}
<table class="purple">
  <thead>
    <th>Colored Text</th>
    <th>Color Preview</th>
    <th>Color Name</th>
    <th>Hex Value</th>
    <th>RGB Value</th>
  </thead>
  <tbody>
    <tr>
      <td></td>
      <td></td>
      <td>Fuscia</td>
      <td>#f1a4b1</td>
      <td>102, 74, 51</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Print</td>
      <td>#ea12fb</td>
      <td>41, 45, 21</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Fuscia</td>
      <td>#f1a4b1</td>
      <td>102, 74, 51</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Print</td>
      <td>#ea12fb</td>
      <td>41, 45, 21</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Fuscia</td>
      <td>#f1a4b1</td>
      <td>102, 74, 51</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Print</td>
      <td>#ea12fb</td>
      <td>41, 45, 21</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Fuscia</td>
      <td>#f1a4b1</td>
      <td>102, 74, 51</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Print</td>
      <td>#ea12fb</td>
      <td>41, 45, 21</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Fuscia</td>
      <td>#f1a4b1</td>
      <td>102, 74, 51</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Print</td>
      <td>#ea12fb</td>
      <td>41, 45, 21</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
  </tbody>
</table>
<br>
<hr>
<br>
<table class="blue">
  <thead>
    <th>Colored Text</th>
    <th>Color Preview</th>
    <th>Color Name</th>
    <th>Hex Value</th>
    <th>RGB Value</th>
  </thead>
  <tbody>
    <tr>
      <td></td>
      <td></td>
      <td>Fuscia</td>
      <td>#f1a4b1</td>
      <td>102, 74, 51</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Print</td>
      <td>#ea12fb</td>
      <td>41, 45, 21</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Fuscia</td>
      <td>#f1a4b1</td>
      <td>102, 74, 51</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Print</td>
      <td>#ea12fb</td>
      <td>41, 45, 21</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Fuscia</td>
      <td>#f1a4b1</td>
      <td>102, 74, 51</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Print</td>
      <td>#ea12fb</td>
      <td>41, 45, 21</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Fuscia</td>
      <td>#f1a4b1</td>
      <td>102, 74, 51</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Print</td>
      <td>#ea12fb</td>
      <td>41, 45, 21</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Fuscia</td>
      <td>#f1a4b1</td>
      <td>102, 74, 51</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Print</td>
      <td>#ea12fb</td>
      <td>41, 45, 21</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Fuscia</td>
      <td>#f1a4b1</td>
      <td>102, 74, 51</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Print</td>
      <td>#ea12fb</td>
      <td>41, 45, 21</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Pink</td>
      <td>#aa12fa</td>
      <td>55, 84, 100</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>Gold</td>
      <td>#abcdef</td>
      <td>120, 210, 43</td>
    </tr>
  </tbody>
</table>

How to convert a Dataset into an indexed dataset / association-of-associations given a column header?

Given a dataset as such

Input

If "letter" is the header that is chosen, how do I convert it into an indexed dataset / association-of-associations?

i.e. How do I define f such that f(dataset_,columnHeader_) produces the following?

enter image description here

Please note GroupBy is close but fails as you are unable to use Part to work with the result to extract column data. eg:

data = {<|"letter" -> "a", "foo" -> 1, "bar" -> 2|>, <|"letter" -> "b", "foo" -> 3, "bar" -> 4|>, <|"letter" -> "c", "foo" -> 5, "bar" -> 6|>};
dataDS = Dataset(data);
dataDSg= GroupBy(dataDS, Key("letter"));
dataDSg(All, "foo") (* <- produces an error *)

Where as data in the format of an association-of-association works fine

data2 = <|"a" -> <|"foo" -> 1, "bar" -> 2|>, "b" -> <|"foo" -> 3, "bar" -> 4|>, "c" -> <|"foo" -> 5, "bar" -> 6|>|>;
data2DS = data2 // Dataset;
data2DS (All, "foo") (* <- returns a dataset with 1,3,5 *)

tls – How good can X-Frame-Options HTTP header do against click-jacking?

  1. X-Frame-Options HTTP header is used to tell if a webpage is allowed to be used in a frame/iframe.

  2. Frames can be used for click-jacking/UI-redress attacks.

  3. It is advised to set X-Frame-Options to ‘DENY’ to prevent page being used for click-jacking.

But, is it not possible for the attacker to tamper the headers (especially with no SSL) OR provide his own page-that-mimicks-the-original-page into the frame?

Maybe it is useful when the user is logged in to the original site and the attacker’s frame displays a personalized page from the original site to convince the user. But, I suppose a dedicated attacker can mimick that too.

What can you tell about x-frame-options as a security feature and cautions when using it?

How to make the Table Header reference Dynamic in Table.SelectRows

In my table I would like to dynamically refer to a column header when using the Table.SelectRows function. Depending on dropdown list which gives me a parameter value I would like to select the column from which Certain values need to be filtered out. This drop down list consists of a number of buildings.
enter image description here