{"id":19388883,"url":"https://github.com/james2doyle/pyro-sniffer-plugin","last_synced_at":"2025-06-28T18:09:33.676Z","repository":{"id":145775502,"uuid":"10774834","full_name":"james2doyle/pyro-sniffer-plugin","owner":"james2doyle","description":"Sniff information from the user agent for use in the frontend. Useful for adding classes or conditional loading.","archived":false,"fork":false,"pushed_at":"2014-07-04T14:44:23.000Z","size":188,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-07T08:48:55.833Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/james2doyle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-18T22:24:12.000Z","updated_at":"2020-01-30T22:37:16.000Z","dependencies_parsed_at":"2023-03-23T17:00:44.737Z","dependency_job_id":null,"html_url":"https://github.com/james2doyle/pyro-sniffer-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Fpyro-sniffer-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Fpyro-sniffer-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Fpyro-sniffer-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Fpyro-sniffer-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/james2doyle","download_url":"https://codeload.github.com/james2doyle/pyro-sniffer-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240549434,"owners_count":19819131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T10:13:57.640Z","updated_at":"2025-02-24T20:00:01.423Z","avatar_url":"https://github.com/james2doyle.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"pyro-sniffer-plugin\n===================\n\nSniff information from the user agent for use in the frontend. Useful for adding classes or conditional loading.\n\nThis plugin is **not** built on the [CodeIgniter User Agent Library](http://ellislab.com/codeigniter/user-guide/libraries/user_agent.html).\n\nThe reason I did not use the built in CodeIgniter lib, was because Pyro is only going to have CodeIgniter for a few more months(right?!?!), and I also want to have the information returned in a different way. This plugin is pretty small and only really gets information that is helpful to be used in CSS and Javascript (CSS custom classes and js feature detection/fallbacks).\n\nIf you are looking for a plugin that uses the user agent library, check out [this plugin called Agent](https://www.pyrocms.com/store/details/agent_plugin).\n\n### Usage\n\n```html\n\u003cbody class=\"{{ sniffer:get key=\"browser|platform|type\" }}\"\u003e\n```\n\nOn my Mac running Google Chrome, this would return:\n\n```html\n\u003cbody class=\" google-chrome mac desktop\"\u003e\n```\n\nOn my iPhone, this would return:\n\n```html\n\u003cbody class=\" apple-mobile-safari ios mobile\"\u003e\n```\n\n#### conditional content\n\nThis works in 2.2/develop. Not sure about 2.3 or 2.1.\n\n```html\n{{ if { sniffer:get key=\"type\" } == 'desktop' }}\n\u003cdiv class=\"huge-slider\"\u003e\n  \u003cdiv class=\"slide\"\u003e\n    \u003cimg src=\"img/kitten1.jpg\" width=\"1400\" height=\"500\"\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"slide\"\u003e\n    \u003cimg src=\"img/puppy1.jpg\" width=\"1400\" height=\"500\"\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"slide\"\u003e\n    \u003cimg src=\"img/snake1.jpg\" width=\"1400\" height=\"500\"\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n{{ else }}\n\u003cdiv class=\"mobile-logo\"\u003e\n  \u003cimg src=\"img/mobile-logo.png\" width=\"200\" height=\"200\"\u003e\n\u003c/div\u003e\n{{ endif }}\n```\n\nhere is the full dump of the `$results` object for my machine:\n\n```php\n$results = array (\n  ['useragent'] =\u003e 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.44 Safari/537.36' // full ua string\n  ['name'] =\u003e 'Google Chrome' // name of the browser\n  ['browser'] =\u003e 'google-chrome' // CSS safe browser name\n  ['version'] =\u003e '28.0.1500.44' // bowser version\n  ['type'] =\u003e 'desktop' // device form factor\n  ['platform'] =\u003e 'mac' // OS platform\n  ['pattern'] =\u003e '#(?Version|Chrome|other)[/ ]+(?[0-9.|a-zA-Z.]*)#' // match pattern\n);\n```\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames2doyle%2Fpyro-sniffer-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjames2doyle%2Fpyro-sniffer-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames2doyle%2Fpyro-sniffer-plugin/lists"}