Skip to content

Commit

Permalink
v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
randyzwitch committed Jul 13, 2020
1 parent 33e56a5 commit 41a6b66
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# streamlit-embedcode

streamlit-embedcode is the easiest way to embed code snippets into your Streamlit app! This component supports the following code sharing services:
streamlit-embedcode is the easiest way to embed code snippets into your Streamlit app! This [static component](https://docs.streamlit.io/en/stable/develop_streamlit_components.html#create-a-static-component) supports the following code sharing services:

- [GitHub gist](https://gist.github.com/)
- [GitLab snippets](https://gitlab.com/explore/snippets)
Expand Down
85 changes: 85 additions & 0 deletions examples/streamlit-embedcode-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,112 @@

github_gist

"---"
"### Example:"
with st.echo():

import streamlit as st
from streamlit_embedcode import github_gist

t = st.text_input(
"Enter GitHub gist URL:",
"https://gist.github.com/randyzwitch/934d502e53f2adcb48eea2423fe4a47e",
)

w = st.slider("width", 300, 800, 710)
github_gist(t, width=w)

elif choice == "gitlab_snippet()":
"""## gitlab_snippet()"""

gitlab_snippet

"---"
"### Example:"
with st.echo():

import streamlit as st
from streamlit_embedcode import gitlab_snippet

t = st.text_input(
"Enter GitLab snippet URL:", "https://gitlab.com/snippets/1995463",
)

w = st.slider("width", 300, 800, 710)
gitlab_snippet(t, width=w)

elif choice == "pastebin_snippet()":
"""## pastebin_snippet()"""

pastebin_snippet

"---"
"### Example:"
with st.echo():

import streamlit as st
from streamlit_embedcode import pastebin_snippet

t = st.text_input(
"Enter Pastebin snippet URL:", "https://pastebin.com/i1YQv94Q",
)

w = st.slider("width", 300, 800, 710)
pastebin_snippet(t, width=w)

elif choice == "codepen_snippet()":
"""## codepen_snippet()"""

codepen_snippet

"---"
"### Example:"
with st.echo():

import streamlit as st
from streamlit_embedcode import codepen_snippet

t = st.text_input(
"Enter CodePen snippet URL:", "https://codepen.io/ste-vg/pen/GRooLza",
)

w = st.slider("width", 300, 800, 750, key="1")
h = st.slider("height", 500, 800, 600, key="2")
codepen_snippet(t, width=w, height=h)

elif choice == "ideone_snippet()":
"""## ideone_snippet()"""

ideone_snippet

"---"
"### Example:"
with st.echo():

import streamlit as st
from streamlit_embedcode import ideone_snippet

t = st.text_input("Enter Ideone snippet URL:", "https://ideone.com/vQ54cr",)

w = st.slider("width", 300, 800, 710, key="1")
ideone_snippet(t, width=w)

elif choice == "tagmycode_snippet()":
"""## tagmycode_snippet()"""

tagmycode_snippet

"---"
"### Example:"
with st.echo():

import streamlit as st
from streamlit_embedcode import tagmycode_snippet

t = st.text_input(
"Enter Ideone snippet URL:",
"https://tagmycode.com/snippet/5965/recursive-list-files-in-a-dir#.Xwyc43VKglU",
)

w = st.slider("width", 300, 800, 710, key="1")
tagmycode_snippet(t, width=w)
8 changes: 4 additions & 4 deletions streamlit_embedcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def github_gist(link, height=600, width=950, scrolling=True):
Example
-------
>>> github_gist("https://gist.github.com/randyzwitch/be8c5e9fb5b8e7b046afebcac12e5087/")
>>> github_gist("https://gist.github.com/randyzwitch/934d502e53f2adcb48eea2423fe4a47e")
"""

gistcreator, gistid = _clean_link(link).split("/")[-2:]
Expand Down Expand Up @@ -71,7 +71,7 @@ def gitlab_snippet(link, height=600, width=950, scrolling=True):
Example
-------
>>> gitlab_snippet("https://gitlab.com/snippets/1990429/", height = 400)
>>> gitlab_snippet("https://gitlab.com/snippets/1995463", height = 400)
"""

snippetnumber = _clean_link(link).split("/")[-1]
Expand Down Expand Up @@ -134,7 +134,7 @@ def codepen_snippet(
Example
-------
>>> pastebin_snippet("https://pastebin.com/AWYbziQF", width = 600, scrolling = False)
>>> codepen_snippet("https://codepen.io/ste-vg/pen/GRooLza", width = 600, scrolling = False)
"""

user, _, slughash = _clean_link(link).split("/")[-3:]
Expand Down Expand Up @@ -200,7 +200,7 @@ def tagmycode_snippet(link, height=600, width=950, scrolling=True):
Example
-------
>>> tagmycode_snippet("https://tagmycode.com/snippet/14040/css-structure#.XvYhunVKglU")
>>> tagmycode_snippet("https://tagmycode.com/snippet/5965/recursive-list-files-in-a-dir#.Xwyc43VKglU")
"""

snippetnumber = _clean_link(link).split("/")[-2]
Expand Down

0 comments on commit 41a6b66

Please sign in to comment.