我的链接上有while True:
print("--Sleeping for 30 seconds")
time.sleep(30)
submissions = r.get_subreddit(sub).get_random_submission()
print('--Submission Found in ' + sub)
print("--Submission.url: ", submissions.url)
if submissions.url in urlArray.urllist:
print("--This url has already been downloaded")
continue
print("--Adding url to array")
urlArray.urllist.append(submissions.url)
url = urllib.parse.unquote(submissions.url)
#if url doesnt have jpg and doesnt have "gallery" or "/a/"
if(not jpg in url and imgur in url and not "gallery" in url and not "/a/" in url):
print("--Url without jpg format: ", url)
jpgURL = submissions.url + ".jpg"
print("--Remade url is: ", jpgURL)
imgur_name2 = id_gen()
newurl2 = jpgURL.split('/')[-1].split('.')[0]
im.get_image(newurl2).download(path="C:\\Users\\KEVIN\\Pictures\\temp_pics", name=imgur_name2, overwrite=False, size=None)
print("--Downloaded remade url")
if jpg in url and imgur in url:
newurl = url.split('/')[-1].split('.')[0]
imgur_name = id_gen()
temp_pic = imgur_name + ".jpg"
print("--Downloading Image through Imgur")
im.get_image(newurl).download(path="C:\\Users\\KEVIN\\Pictures\\temp_pics", name=imgur_name, overwrite=False, size=None)
if reddit in url:
reddit_gen = id_gen()
reddit_pic = reddit_gen + ".jpg"
print("\n" + "--Downloading through I.Reddit")
request.urlretrieve(url, "C:\\Users\\KEVIN\\Pictures\\temp_pics\\" + reddit_pic)
if not reddit in url and not redd in url and not imgur in url and jpg in url:
print("--Not reddit or imgur but I can download the image")
randomGen = id_gen()
request.urlretrieve(url, "C:\\Users\\KEVIN\\Pictures\\temp_pics\\" + randomGen + ".jpg")
print("--Downloaded", "This image ID is: ", randomGen)
样式。问题是,当我禁用链接时,引导程序样式不会出现我只能获得纯文本。
class: 'btn btn-info'
我尝试做的是更改<%= link_to_if organisme.active?, 'Show', organismereferent_path(organisme), class: 'btn btn-info', :disabled => !organisme.active? %>
link_to_if
button_to
这样可行但现在按钮不会将用户发送到它停留在同一页面上的正确位置。处理这种情况的正确方法是什么?
答案 0 :(得分:2)
<% if organisme.active? %>
<%= link_to 'Show', organismereferent_path(organisme), class: 'btn btn-info'%>
<% else %>
<%= link_to '#', organismereferent_path(organisme), class: 'btn btn-info disabled', :disabled => true %>
<% end %>
或者如果课程足够
<%= link_to 'Show', organismereferent_path(organisme), class: "btn btn-info#{organisme.active? ? ' disabled' : nil }"%>