{"id":23143861,"url":"https://github.com/sh20raj/edgithub","last_synced_at":"2025-04-04T12:15:18.229Z","repository":{"id":173984188,"uuid":"451838507","full_name":"SH20RAJ/edgithub","owner":"SH20RAJ","description":"Embed a file from Github repository just like Github Gist.","archived":false,"fork":false,"pushed_at":"2024-02-08T09:48:16.000Z","size":42,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T06:32:22.560Z","etag":null,"topics":["edgithub","emgithub","github","github-gists"],"latest_commit_sha":null,"homepage":"https://edgithub.vercel.app/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SH20RAJ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-01-25T10:49:33.000Z","updated_at":"2024-04-20T17:32:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"71df2c05-e946-494f-9c62-3e9aaf879a7b","html_url":"https://github.com/SH20RAJ/edgithub","commit_stats":null,"previous_names":["sh20raj/edgithub"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SH20RAJ%2Fedgithub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SH20RAJ%2Fedgithub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SH20RAJ%2Fedgithub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SH20RAJ%2Fedgithub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SH20RAJ","download_url":"https://codeload.github.com/SH20RAJ/edgithub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174467,"owners_count":20896078,"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":["edgithub","emgithub","github","github-gists"],"created_at":"2024-12-17T15:14:24.502Z","updated_at":"2025-04-04T12:15:18.213Z","avatar_url":"https://github.com/SH20RAJ.png","language":"HTML","readme":"# Embed Like Gist\n\nhttps://emgithub.com/\n\nEmbed a file from Github repository just like [Github Gist](https://gist.github.com/). Unlike other websites that do similar work, EmGithub.com is a static site hosted on Github Pages. Fetching target files and highlighting are done on your browser.\n\nRelated post: https://blog.yusanshi.com/2019-12-17-emgithub/\n\n## Get started\n\nThere are two ways to use the service.\n\nSupposed you want to embed the file `https://github.com/pytorch/pytorch/blob/master/torch/nn/cpp.py`. The first way is to visit https://emgithub.com/ and paste the URL. The other is to simply add \"em\" before \"github.com\". For this `cpp.py` file, you edit URL into `https://emgithub.com/pytorch/pytorch/blob/master/torch/nn/cpp.py`, then press Enter.\n\nPermanent links to [a file](https://docs.github.com/en/github/managing-files-in-a-repository/getting-permanent-links-to-files) or [a code snippet](https://docs.github.com/en/github/managing-your-work-on-github/creating-a-permanent-link-to-a-code-snippet) are supported.\n\n**ProTip**\n\n- Use `#` to slice code, use `?ts=` to specify TAB width. An example using both of them: `?ts=2#L4-L12`.\n- The outermost div has a class attribute `emgithub-container`. Do any hacks you want.\n\n![](https://user-images.githubusercontent.com/36265606/114659094-8a070a00-9d25-11eb-9164-779e91f3ae46.gif)\n\n## TODO\n\n- [x] Support more styles\n- [x] Check input\n- [x] Show spinner while loading\n- [x] Add metadata\n- [x] Line count\n- [x] Remember options using localStorage\n- [x] Code slice\n- [ ] Different styles in one page\n\nPR is always welcomed.\n\n## Development\n\n### Test\n\nYou can modify the code and test it by launching an HTTP server in the project directory.\n\n1. Launch an HTTP server.\n\n   ```bash\n   git clone https://github.com/yusanshi/embed-like-gist\n   cd embed-like-gist\n   python -m http.server 8086\n   ```\n\n2. Make the changes.\n\n3. To test the 404 page, visit \u003chttp://localhost:8086/404.html\u003e.\n\n   \u003e Don't be confused by the \"404\". It is how the \"adding em in address bar\" works: after adding the \"em\", the HTTP server (provided by GitHub Pages) can't find the file so it renders `404.html`.\n\n4. To test the real performance when the code is embedded, create a simple HTML file `test.html` in the project root directory like this:\n\n   ```html\n   \u003c!DOCTYPE html\u003e\n   \u003chtml lang=\"en\"\u003e\n     \u003chead\u003e\n       \u003cmeta charset=\"UTF-8\" /\u003e\n       \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /\u003e\n       \u003ctitle\u003eTest\u003c/title\u003e\n     \u003c/head\u003e\n     \u003cbody style=\"padding:5rem\"\u003e\n       \u003ch1\u003eJavaScript, All options on\u003c/h1\u003e\n       \u003cscript src=\"http://localhost:8086/embed.js?target=https%3A%2F%2Fgithub.com%2Fyusanshi%2Fembed-like-gist%2Fblob%2Fmaster%2Fembed.js\u0026style=github\u0026showBorder=on\u0026showLineNumbers=on\u0026showFileMeta=on\u0026showCopy=on\"\u003e\u003c/script\u003e\n       \u003cbr /\u003e\n       \u003ch1\u003ePlain text, All options off\u003c/h1\u003e\n       \u003cscript src=\"http://localhost:8086/embed.js?target=https%3A%2F%2Fgithub.com%2Fyusanshi%2Fembed-like-gist%2Fblob%2Fmaster%2FLICENSE\u0026style=github\"\u003e\u003c/script\u003e\n       \u003cbr /\u003e\n       \u003ch1\u003eAdd more examples yourself...\u003c/h1\u003e\n     \u003c/body\u003e\n   \u003c/html\u003e\n   ```\n\n   Then visit \u003chttp://localhost:8086/test.html\u003e.\n\n## Create your own project\n\nYou may want to create your own **embed-like-gist** for some reasons, like:\n\n- To fit your personal needs.\n- For security. Say if \u003chttps://emgithub.com/\u003e is hacked...\n- For stability. There may be some breaking changes with \u003chttps://emgithub.com/\u003e (I will try to avoid this, but can't make a guarantee).\n\nTo do this, you should decide the server to use.\n\n### Use GitHub Pages\n\nIf you choose to use GitHub Pages just like \u003chttps://emgithub.com/\u003e does, you can fork the project and remove the `CNAME` file. Then go to `Your repository - Settings - GitHub Pages` to setup a custom domain or simply use `username.github.io`.\n\n### Use own web server\n\nIf you choose to use your own web server, such as Apache and Nginx, the most important thing to do is to configure the server to serve `404.html` for a not-found request.\n\nFor example, here is a simple configuration without HTTPS for Nginx:\n\n```nginx\nserver {\n  listen 80;\n  listen [::]:80;\n\n  server_name your_domain.com;\n\n  root /var/www/project_directory;\n\n  location / {\n    try_files $uri /404.html;\n  }\n}\n```\n\n## Credits\n\n- [Highlight.js](https://github.com/highlightjs/highlight.js/) - Javascript syntax highlighter;\n- [highlightjs-line-numbers.js](https://github.com/wcoder/highlightjs-line-numbers.js) - Highlight.js line numbers plugin;\n- [PostScribe](https://github.com/krux/postscribe) - Asynchronously write javascript;\n- Icons made by [Vectors Market](https://www.flaticon.com/authors/vectors-market) and [Dave Gandy](https://www.flaticon.com/authors/dave-gandy) from [www.flaticon.com](https://www.flaticon.com/);\n- Loading animation by [Loading.io](https://loading.io/);\n- CSS style based on [GitHub syntax theme generators](https://github.com/primer/github-syntax-theme-generator);\n- [GitHub Corners](https://github.com/tholman/github-corners).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsh20raj%2Fedgithub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsh20raj%2Fedgithub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsh20raj%2Fedgithub/lists"}