0
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local ipairs = Luan.ipairs or error()
|
|
4 local String = require "luan:String.luan"
|
|
5 local contains = String.contains or error()
|
|
6 local Parsers = require "luan:Parsers.luan"
|
|
7 local json_string = Parsers.json_string or error()
|
|
8 local Html = require "luan:Html.luan"
|
|
9 local html_encode = Html.encode or error()
|
|
10 local Thread = require "luan:Thread.luan"
|
|
11 local thread_run = Thread.run or error()
|
|
12 local Io = require "luan:Io.luan"
|
|
13 local Http = require "luan:http/Http.luan"
|
|
14 local Shared = require "site:/lib/Shared.luan"
|
|
15 local pub_head = Shared.pub_head or error()
|
|
16 local show_saved = Shared.show_saved or error()
|
|
17 local call_mixpanel = Shared.call_mixpanel or error()
|
|
18 local get_hashtags_list = Shared.get_hashtags_list or error()
|
|
19 local has_facebook = not not Shared.has_facebook
|
|
20 local User = require "site:/lib/User.luan"
|
|
21 local Link = require "site:/lib/Link.luan"
|
|
22 local get_owner_links = Link.get_owner_links or error()
|
|
23 local Pic = require "site:/lib/Pic.luan"
|
|
24 local get_user_pics = Pic.get_user_pics or error()
|
|
25 local Icon = require "site:/lib/Icon.luan"
|
|
26 local get_user_icons = Icon.get_user_icons or error()
|
|
27 local Facebook = require "site:/lib/Facebook.luan"
|
|
28 local fb_track_visit = Facebook.track_visit or error()
|
|
29 local Reporting = require "site:/lib/Reporting.luan"
|
|
30 local maybe_track_visit = Reporting.maybe_track_visit or error()
|
|
31 local should_track_visit = Reporting.should_track_visit or error()
|
|
32 local Logging = require "luan:logging/Logging.luan"
|
|
33 local logger = Logging.logger "main_html"
|
|
34
|
|
35
|
|
36 local function ad_tracking(user)
|
|
37 local referrer = Http.request.headers.referer
|
|
38 if referrer ~= nil and not contains(referrer,"linkmy.style") and maybe_track_visit(user) then
|
|
39 thread_run( function()
|
|
40 if should_track_visit(user) then
|
|
41 call_mixpanel{
|
|
42 event = "Visit"
|
|
43 properties = {
|
|
44 distinct_id = user.email
|
|
45 }
|
|
46 }
|
|
47 if has_facebook then
|
|
48 fb_track_visit(user)
|
|
49 end
|
|
50 end
|
|
51 end )
|
|
52 end
|
|
53 end
|
|
54
|
|
55 return function(user)
|
|
56 ad_tracking(user)
|
|
57 local user_id = user.id
|
|
58 local links = get_owner_links(user_id)
|
|
59 local pics = get_user_pics(user_id)
|
|
60 local icons = get_user_icons(user_id)
|
|
61 local title = user.html_title()
|
|
62 local pic_url = user.get_pic_url()
|
|
63 local bio = user.bio
|
|
64 local is_saved = Http.request.parameters.saved ~= nil
|
|
65 local saved = is_saved and "&saved" or ""
|
|
66 local hashtags_list, hashtags_set = get_hashtags_list(pics)
|
|
67 Http.response.headers["Content-Type"] = "text/html; charset=utf-8"
|
|
68 Io.stdout = Http.response.text_writer()
|
|
69 %>
|
|
70 <!doctype html>
|
|
71 <html main>
|
|
72 <head>
|
|
73 <title>Link My Style | <%=title%></title>
|
|
74 <style hashtag></style>
|
|
75 <script>
|
|
76 'use strict';
|
|
77
|
|
78 window.Path = 'main';
|
|
79 window.Page = 'Home';
|
|
80
|
|
81 let hashtags = <%=json_string(hashtags_set)%>;
|
|
82 </script>
|
|
83 <% pub_head(user) %>
|
|
84 <script>
|
|
85 fbTrack('trackCustom', 'View', {owner:'<%=user.name%>'});
|
|
86 </script>
|
|
87 </head>
|
|
88 <body colored onload="mainInit()">
|
|
89 <% if is_saved then
|
|
90 show_saved("/"..user.name)
|
|
91 end %>
|
|
92 <div pub_background_img></div>
|
|
93 <div pub_content>
|
|
94 <div home><a href="/?source=organic">
|
|
95 <span lms>LinkMyStyle</span>
|
|
96 <br><span small>Increase Affiliate Sales</span>
|
|
97 </a></div>
|
|
98 <% if pic_url ~= nil then %>
|
|
99 <img user src="<%=pic_url%>">
|
|
100 <% end %>
|
|
101 <h1><%=title%></h1>
|
|
102 <% if bio ~= nil then %>
|
|
103 <div bio><%=html_encode(bio)%></div>
|
|
104 <% end
|
|
105 if #icons > 0 then %>
|
|
106 <div icons>
|
|
107 <% for _, icon in ipairs(icons) do %>
|
|
108 <a <%=icon.title_attr()%> href="<%=html_encode(icon.url)%>"><img src="/images/icons/<%=icon.name%>.svg"></a>
|
|
109 <% end %>
|
|
110 </div>
|
|
111 <% end %>
|
|
112 <div links>
|
|
113 <% for _, link in ipairs(links) do %>
|
|
114 <a link href="<%=html_encode(link.url)%>"><%=html_encode(link.title)%></a>
|
|
115 <% end %>
|
|
116 </div>
|
|
117 <% if #hashtags_list > 0 then %>
|
|
118 <div hashtags>
|
|
119 <span select>
|
|
120 <select onchange="mainSelectHashtag(value)">
|
|
121 <option value="">All Photos</option>
|
|
122 <% for _, hashtag in ipairs(hashtags_list) do %>
|
|
123 <option value="<%=hashtag%>">#<%=hashtag%></option>
|
|
124 <% end %>
|
|
125 </select>
|
|
126 </span>
|
|
127 </div>
|
|
128 <% end %>
|
|
129 <div pics>
|
|
130 <% for _, pic in ipairs(pics) do
|
|
131 if pic.is_hidden then
|
|
132 continue
|
|
133 end
|
|
134 local pic_id = pic.id
|
|
135 %>
|
|
136 <span id="p-<%=pic_id%>" <%= pic.class or "" %> >
|
|
137 <a <%=pic.title_attr()%> href="/pic.html?pic=<%=pic_id%><%=saved%>"><img loading=lazy src="<%=pic.get_thumb_url()%>"></a>
|
|
138 </span>
|
|
139 <% end %>
|
|
140 </div>
|
|
141 </div>
|
|
142 </body>
|
|
143 </html>
|
|
144 <%
|
|
145 end
|