Merge pull request #16692 from owncloud/add_social_media_buttons

Add social media buttons
This commit is contained in:
Björn Schießle 2015-06-18 14:41:58 +02:00
commit 7a0917e5b2
11 changed files with 650 additions and 6 deletions

View File

@ -0,0 +1,49 @@
.js-gs-share, .gs-share [aria-hidden="true"], .gs-share-form[aria-hidden="true"] {
display: none;
}
.js-gs-share-enabled .js-gs-share {
display: inline;
float: left;
}
.gs-share .js-gs-share[href] {
display: inline;
}
.gs-share [aria-hidden="false"], .gs-share-form[aria-hidden="false"] {
display: block;
margin-top: 40px;
}
.gs-share {
position: relative;
}
.gs-share-form {
background: #FFF;
border: 1px solid #000;
border-radius: 5px;
padding: 5px;
position: absolute;
z-index: 1;
}
.gs-share [for="gs-account"], .gs-share [type="text"] {
display: block;
margin-bottom: 8px;
}
.gs-share [type="submit"] {
display: block;
margin-top: 8px;
}
.gs-share--icon {
border: none;
cursor: pointer;
min-height: 32px;
padding: 0;
padding-left: 33px;
background: transparent url('../../../img/gs-share.png') no-repeat left center;
}

View File

@ -0,0 +1,32 @@
#fileSharingSettings img {
cursor: pointer;
}
#fileSharingSettings xmp {
margin-top: 0;
}
[class^="social-"], [class*=" social-"] {
background-repeat: no-repeat;
background-position: 2px;
min-width: 16px;
min-height: 16px;
padding-left: 29px;
background-size: 24px;
}
.social-gnu {
background-image: url('../img/social-gnu.svg');
}
.social-diaspora {
background-image: url('../img/social-diaspora.svg');
}
.social-twitter {
background-image: url('../img/social-twitter.svg');
}
.social-facebook {
background-image: url('../img/social-facebook.svg');
}
.social-googleplus {
background-image: url('../img/social-googleplus.svg');
}

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="32"
height="32"
id="svg3937"
inkscape:version="0.91 r13725"
sodipodi:docname="social-diaspora.svg">
<metadata
id="metadata4166">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs4164" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview4162"
showgrid="false"
inkscape:zoom="13.549078"
inkscape:cx="-5.9149036"
inkscape:cy="9.8488708"
inkscape:current-layer="svg3937" />
<path
d="m 15.956724,31 c -0.896548,4.3e-5 -1.344812,-0.448233 -1.344812,-1.344828 L 14.715361,19 5.612032,24.689655 C 4.9223812,25.172463 4.336189,25.034532 3.8534355,24.275862 L 3.3362024,23.448276 C 2.8534488,22.758671 2.991377,22.172465 3.7499869,21.689655 L 13.163651,16 3.6465383,10.310345 C 2.9568974,9.8966152 2.8189693,9.3104089 3.2327538,8.551724 L 3.8534355,7.517241 C 4.1982609,6.965584 4.7499735,6.896618 5.5085834,7.310345 L 14.715361,13 14.611912,2.344828 c 0,-0.89648 0.448264,-1.344756 1.344812,-1.344828 l 0.827569,0 c 0.896538,7.2e-5 1.344812,0.448348 1.344812,1.344828 L 18.025656,13 27.128985,7.206897 c 0.620651,-0.344761 1.206854,-0.206831 1.758596,0.413793 l 0.517233,0.827586 c 0.344796,0.7586846 0.206898,1.344891 -0.413784,1.758621 L 19.473917,16 l 9.620561,5.793103 c 0.689611,0.413845 0.827549,0.965568 0.413785,1.655173 L 28.99103,24.37931 c -0.482784,0.75867 -1.103465,0.896601 -1.862045,0.413793 L 18.025656,19 18.129105,29.655172 c 0,0.896595 -0.448274,1.344871 -1.344812,1.344828 l -0.827569,0"
id="star"
style="opacity:0.5;fill:#000000;fill-opacity:1"
inkscape:connector-curvature="0" />
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
enable-background="new 0 0 56.693 56.693"
height="32"
id="Layer_1"
version="1.1"
viewBox="0 0 32 32"
width="32"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="social-facebook.svg"><metadata
id="metadata5818"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs5816" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview5814"
showgrid="false"
inkscape:zoom="11.271233"
inkscape:cx="5.0995367"
inkscape:cy="28.322502"
inkscape:current-layer="Layer_1" /><path
d="m 22.396887,16.008872 -4.203409,0 0,14.991128 -6.230193,0 0,-14.991128 -2.963285,0 0,-5.292784 2.963285,0 0,-3.429613 C 11.963285,4.831822 13.128489,1 18.251639,1 l 4.613498,0.01774 0,5.140971 -3.349714,0 c -0.547114,0 -1.320959,0.273067 -1.320959,1.44026 l 0,3.118099 4.749536,0 z"
id="path5812"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccscccssccc"
style="fill:#000000;fill-opacity:1;opacity:0.5" /></svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32"
height="32"
id="svg2880"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="social-gnu.svg"
inkscape:export-filename="/home/robmyers/Desktop/social_logo_competition/gnu-social-logo.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs2882">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective2888" />
<inkscape:perspective
id="perspective2859"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="17.21204"
inkscape:cx="13.854211"
inkscape:cy="18.472465"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1022"
inkscape:window-height="730"
inkscape:window-x="0"
inkscape:window-y="49"
inkscape:window-maximized="0" />
<metadata
id="metadata2885">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-119.19595,-352.32438)">
<path
style="opacity:0.5;fill:#000000;fill-opacity:1;stroke:none"
d="m 125.14074,354.32438 c -2.18531,0 -3.94479,1.75948 -3.94479,3.94479 l 0,15.76964 c 0,2.18531 1.75948,3.94419 3.94479,3.94419 l 11.72461,0 c -0.0131,4.46851 -6.05322,6.34138 -6.05322,6.34138 0,0 10.21217,-0.0335 11.65719,-6.34138 l 2.12751,0 c 2.18532,0 3.94479,-1.75888 3.94479,-3.94419 l 0,-15.76964 c 0,-2.18531 -1.75947,-3.94479 -3.94479,-3.94479 l -19.45609,0 z m 5.66602,3.16145 c 0.042,-0.007 0.0803,-0.007 0.11455,0 0.0366,0.007 0.0681,0.022 0.0943,0.0454 0.41895,0.37367 -0.69461,0.73954 -0.60497,2.57737 0.0394,0.80713 -0.2017,1.43484 1.34476,1.43484 1.03195,0 0.60505,-0.91938 1.90498,-0.91938 0.77317,0 1.0581,0.49786 1.16578,0.90268 0.10769,-0.40482 0.39265,-0.90268 1.16577,-0.90268 1.29994,0 0.87304,0.91938 1.90498,0.91938 1.54648,0 1.3054,-0.62771 1.34477,-1.43484 0.0896,-1.83783 -1.02452,-2.2037 -0.60556,-2.57737 0.41895,-0.37366 2.21932,1.81578 2.26414,2.66745 0.0469,0.89057 0.0697,2.29462 -1.25467,3.02244 1.47777,1.45682 1.67588,3.38756 1.67588,3.38756 l -2.55469,-0.0447 c 0,0 -0.58278,-2.64503 -3.67572,-2.51054 -3.09293,0.13447 -3.49614,0.67255 -3.49614,3.94479 0,3.27223 1.43378,4.39676 3.63037,4.48234 3.45154,0.13448 3.13818,-1.79282 3.13818,-1.79282 l -1.61383,0.0895 -0.89671,-2.42045 5.51329,0 c 0,2.64468 -1.12011,6.76843 -6.36465,6.49949 -5.24455,-0.26896 -6.41052,-4.39271 -6.45534,-7.17187 -0.0246,-1.52551 0.22386,-3.24602 1.47363,-4.46265 -1.31045,-0.72721 -1.2678,-2.13094 -1.2678,-3.02303 0,-1.10312 1.42517,-2.61621 2.05473,-2.71279 z"
id="path4639"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="32"
id="Layer_1"
version="1.1"
viewBox="0 0 32 32"
width="32"
xml:space="preserve"
inkscape:version="0.91 r13725"
sodipodi:docname="social-googleplus.svg"><metadata
id="metadata4721"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs4719" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview4717"
showgrid="false"
inkscape:zoom="14.120039"
inkscape:cx="16.803685"
inkscape:cy="25.296916"
inkscape:current-layer="Layer_1" /><style
type="text/css"
id="style4709"><![CDATA[
.st0{fill-rule:evenodd;clip-rule:evenodd;}
]]></style><path
d="m 12.260365,1.00001 c -1.044403,0 -2.164648,0.121381 -3.360551,0.364723 C 7.692812,1.648864 6.529074,2.249513 5.409199,3.171551 3.776833,4.74759 2.962354,6.502187 2.962354,8.437552 c 0,1.600734 0.575619,3.003332 1.728237,4.209224 1.099897,1.293294 2.698442,1.953874 4.796683,1.980234 0.39512,0 0.817861,-0.0267 1.265423,-0.0775 -0.07353,0.20755 -0.154327,0.43048 -0.240621,0.67688 -0.0985,0.23057 -0.147948,0.52213 -0.147948,0.8698 0,0.57798 0.128855,1.07502 0.388569,1.48762 0.221977,0.42453 0.475109,0.82365 0.759795,1.19768 -0.920096,0.0244 -2.074179,0.14101 -3.465144,0.34467 -1.405117,0.24362 -2.74619,0.73028 -4.021172,1.45781 C 2.888819,21.26184 2.103483,22.04929 1.67146,22.94303 1.222511,23.83815 1,24.65257 1,25.38066 1,26.87734 1.688069,28.1616 3.060444,29.23708 4.421998,30.38637 6.482307,30.97531 9.242318,31 c 3.296919,-0.0505 5.820381,-0.83703 7.567065,-2.36284 1.686196,-1.47532 2.530304,-3.16622 2.530304,-5.07578 -0.02608,-1.34436 -0.332749,-2.43326 -0.922377,-3.26734 -0.625976,-0.82049 -1.354352,-1.56623 -2.184547,-2.24687 l -1.336959,-1.0958 c -0.192565,-0.19229 -0.392744,-0.41698 -0.59613,-0.67308 -0.241401,-0.26887 -0.361472,-0.60732 -0.361472,-1.02047 0,-0.42231 0.118073,-0.79294 0.352259,-1.11314 0.199779,-0.30855 0.415557,-0.58393 0.651408,-0.827 0.410103,-0.35849 0.796786,-0.711889 1.160829,-1.056231 0.329081,-0.34684 0.640495,-0.724448 0.932673,-1.134274 0.599894,-0.846566 0.912101,-1.973756 0.934299,-3.383312 0,-0.768597 -0.08672,-1.441865 -0.259587,-2.018173 C 17.498927,5.148549 17.257171,4.650391 16.984971,4.226692 16.700007,3.779685 16.410431,3.400399 16.113536,3.09296 15.80471,2.79773 15.527026,2.574136 15.278412,2.420417 l 2.429503,0 L 20.140669,1 12.260365,1 Z m 12.417942,0.168542 0,4.135521 -4.133895,0 0,2.002999 4.133895,0 0,4.133894 2.00354,0 0,-4.133894 4.133895,0 0,-2.002999 -4.133895,0 0,-4.135521 -2.00354,0 z M 9.822733,2.304994 c 0.806887,0.02581 1.520753,0.264821 2.141734,0.712105 0.608218,0.474477 1.099244,1.092424 1.472443,1.849089 0.794402,1.577704 1.192261,3.145874 1.192261,4.698051 0,0.360713 -0.02983,0.802452 -0.08671,1.329371 -0.0949,0.526364 -0.308925,1.039903 -0.643279,1.540185 -0.690627,0.706445 -1.554617,1.080265 -2.592084,1.118555 -0.821594,0 -1.551253,-0.25054 -2.188883,-0.752206 C 8.478088,12.299585 7.957919,11.690036 7.553643,10.971107 6.719841,9.429474 6.303937,7.947693 6.303937,6.523431 6.277017,5.444621 6.562813,4.468801 7.159655,3.59643 7.86804,2.76124 8.754744,2.330799 9.822733,2.304994 Z m 1.66754,17.540326 c 0.08939,-4e-5 0.159034,0.003 0.209187,0.009 0.337683,0 0.633039,0.0118 0.884983,0.0385 1.468658,1.02609 2.547169,1.89084 3.238073,2.59534 0.650949,0.74279 0.977113,1.61238 0.977113,2.61322 0,1.23142 -0.476766,2.23692 -1.430714,3.01967 -0.977255,0.7944 -2.395196,1.20356 -4.252037,1.2302 C 9.046107,29.32465 7.415497,28.8642 6.222646,27.96768 4.968474,27.07062 4.343209,25.92939 4.343209,24.54481 c 0,-0.70422 0.142508,-1.30655 0.432465,-1.80628 0.249447,-0.47503 0.556709,-0.87233 0.920751,-1.19226 0.377084,-0.30688 0.746941,-0.54508 1.110429,-0.71156 0.364043,-0.15344 0.645616,-0.26945 0.846505,-0.34576 0.853226,-0.25666 1.68826,-0.44222 2.503749,-0.55765 0.620565,-0.0574 1.064984,-0.0861 1.333165,-0.0862 z"
id="path4713"
style="opacity:0.5;fill:#000000;fill-opacity:1"
inkscape:connector-curvature="0" /></svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="32"
id="svg2"
version="1.1"
width="32"
inkscape:version="0.91 r13725"
sodipodi:docname="social-twitter.svg">
<metadata
id="metadata5269">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview5267"
showgrid="false"
inkscape:zoom="10.224"
inkscape:cx="-7.2593811"
inkscape:cy="16.128046"
inkscape:current-layer="svg2" />
<defs
id="defs4" />
<path
sodipodi:nodetypes="sscccccsscsccscsccsccss"
inkscape:connector-curvature="0"
style="opacity:0.5;fill:#000000;fill-opacity:1;fill-rule:nonzero"
id="rect2995"
d="m 21.611501,4.61946 c 0.05279,-0.002 0.106021,0 0.159127,0 1.770342,0 3.36956,0.74756 4.491932,1.94362 C 27.665067,6.2866 28.983178,5.77311 30.172539,5.06729 29.712752,6.50573 28.736679,7.71137 27.465106,8.4726 28.710494,8.32462 29.897115,7.99445 31,7.50421 c -0.824575,1.23442 -1.869002,2.31882 -3.071153,3.18481 0.01156,0.26431 0.01819,0.53117 0.01819,0.79791 C 27.947037,19.62063 21.755733,29 10.433964,29 6.9584454,29 3.7246302,27.98066 1,26.23346 c 0.481711,0.0572 0.9721881,0.0864 1.4685161,0.0864 2.8841872,0 5.5361434,-0.98372 7.6426469,-2.63469 -2.6929626,-0.0493 -4.9652637,-1.83087 -5.7490348,-4.27598 0.375747,0.0725 0.7622921,0.11139 1.1593551,0.11139 0.561492,0 1.1043981,-0.0759 1.6208231,-0.21596 -2.8159792,-0.56635 -4.9374873,-3.05156 -4.9374873,-6.03318 0,-0.0262 -4.66e-4,-0.054 0,-0.0796 0.830058,0.46101 1.7807801,0.73835 2.7892712,0.77063 -1.6515871,-1.10349 -2.7392592,-2.98649 -2.7392592,-5.12162 0,-1.12907 0.304455,-2.18754 0.834281,-3.09616 3.0358242,3.72399 7.5714429,6.17402 12.6869759,6.43101 -0.105355,-0.45126 -0.159128,-0.92088 -0.159128,-1.4026 0,-3.34627 2.669159,-6.0694 5.994545,-6.15366 z" />
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,206 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// @license magnet:?xt=urn:btih:3877d6d54b3accd4bc32f8a48bf32ebc0901502a&dn=mpl-2.0.txt MPL 2.0
document.addEventListener('DOMContentLoaded', function () {
'use strict';
/**
* 'Share' widget for GNU social
* http://code.chromic.org/project/view/2/
*
* We make a few assumptions about the target instance:
* 1) The API root is in the default location
* 2) Fancy URLs are enabled
* 3) CORS is allowed
* 4) The Bookmark plugin is enabled
*
* If 1), 3) or 4) are wrong, we fall back to a regular
* notice (instead of a bookmark notice)
*
* If 2) is wrong the user will be directed to a 404 :(
*/
// TODO: input sanitation [1], [2]
// TODO: server-side fallback if JS is disabled
var createForm,
bindClicks,
frm,
shareAsNotice,
shareAsBookmark,
extractURLParams,
shareURL,
shareTitle,
closest,
i18n = window.i18n;
/**
* Internationalization
*/
if (i18n === undefined) {
i18n = {
invalidId: 'The account id provided is invalid',
yourAcctId: 'Your account ID:',
idPlaceholder: 'user@example.org',
shareAsBookmark: 'Share as a bookmark'
};
}
shareAsNotice = function (title, url, domain) {
window.open('http://' + domain + '/notice/new?status_textarea=' + title + ' ' + url); // [1]
};
shareAsBookmark = function (title, url, domain) {
window.open('http://' + domain + '/main/bookmark/new?url=' + url + '&title=' + title); // [2]
};
/**
* Extract parameters from query string
*
* ex:
* ?foo=bar&baz=test
* will return:
* {foo: 'bar', baz: 'test'}
*/
extractURLParams = function (queryStr) {
var parts = queryStr.substr(1).split('&'),
i, len, keyVal, params = {};
for (i = 0, len = parts.length; i < len; i += 1) {
keyVal = parts[i].split('=');
params[keyVal[0]] = keyVal[1];
}
return params;
};
// Create the form that we'll re-use throughout the page
createForm = function () {
var err = document.createElement('div');
err.setAttribute('class', 'gs-share-err');
err.setAttribute('tabindex', '-1');
err.setAttribute('aria-hidden', 'true');
err.textContent = i18n.invalidId;
frm = document.createElement('form');
frm.setAttribute('class', 'gs-share-form');
frm.setAttribute('tabindex', '-1');
frm.setAttribute('aria-hidden', 'true');
frm.innerHTML = '<label for="gs-account">' + i18n.yourAcctId + '</label>' +
'<input type="text" id="gs-account" placeholder="' + i18n.idPlaceholder + '" />' +
'<input type="checkbox" id="gs-bookmark" /> <label for="gs-bookmark">' + i18n.shareAsBookmark + '</label>' +
'<input type="submit" value="Share"/>';
frm.insertBefore(err, frm.firstChild);
// Submit handler
frm.addEventListener('submit', function (e) {
e.preventDefault();
var accountParts = document.getElementById('gs-account').value.split('@'),
username, domain, xhr, bookmarkURL;
if (accountParts.length === 2) {
err.setAttribute('aria-hidden', 'true');
username = accountParts[0];
domain = accountParts[1];
bookmarkURL = 'http://' + domain + '/api/bookmarks/' + username + '.json';
// Try bookmark
if (document.getElementById('gs-bookmark').checked) {
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) { // Success
shareAsBookmark(shareTitle, shareURL, domain);
} else { // Failure, fallback to regular notice
shareAsNotice(shareTitle, shareURL, domain);
}
}
};
xhr.open('GET', bookmarkURL, true);
xhr.send();
} else { // Regular notice
shareAsNotice(shareTitle, shareURL, domain);
}
} else { // Invalid account id
err.setAttribute('aria-hidden', 'false');
err.focus();
}
});
// Keydown handler
frm.addEventListener('keydown', function (e) {
if (e.keyCode === 27) { // Escape key closes the dialog
frm.parentElement.getElementsByClassName('js-gs-share')[0].focus();
frm.setAttribute('aria-hidden', 'true');
}
});
document.body.appendChild(frm);
};
/**
* Something similar to jQuery.closest
*
* Given `elm`, return the closest parent with class `cls`
* or false if there is no matching ancestor.
*/
closest = function (elm, cls) {
while (elm !== document) {
if (elm.classList.contains(cls)) {
return elm;
}
elm = elm.parentNode;
}
return false;
};
bindClicks = function () {
document.addEventListener('click', function (e) {
var target = e.target,
urlParams,
lnk = closest(target, 'js-gs-share');
// Don't do anything on right/middle click or if ctrl or shift was pressed while left-clicking
if (!e.button && !e.ctrlKey && !e.shiftKey && lnk) {
e.preventDefault();
// Check for submission information in href first
if (lnk.search !== undefined) {
urlParams = extractURLParams(lnk.search);
shareURL = urlParams.url;
shareTitle = urlParams.title;
} else { // If it's not there, try data-* attributes. If not, use current document url and title
shareURL = lnk.getAttribute('data-url') || window.location.href;
shareTitle = lnk.getAttribute('data-title') || document.title;
}
// Move form after the clicked link
lnk.parentNode.appendChild(frm);
// Show form
frm.setAttribute('aria-hidden', 'false');
// Focus on form
frm.focus();
} else if (!frm.contains(target)) {
frm.setAttribute('aria-hidden', 'true');
}
});
};
// Flag that js is enabled
document.body.classList.add('js-gs-share-enabled');
createForm();
bindClicks();
});
// @license-end

View File

@ -0,0 +1,15 @@
$(document).ready(function() {
$('#fileSharingSettings button.pop-up').click(function() {
var url = $(this).data('url');
if (url) {
var width = 600;
var height = 400;
var left = (screen.width/2)-(width/2);
var top = (screen.height/2)-(height/2);
window.open(url, 'name', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left);
}
});
});

View File

@ -22,11 +22,20 @@
\OC_Util::checkLoggedIn();
$l = \OC::$server->getL10N('files_sharing');
$uid = \OC::$server->getUserSession()->getUser()->getUID();
$server = \OC::$server->getURLGenerator()->getAbsoluteURL('/');
$cloudID = $uid . '@' . rtrim(\OCA\Files_Sharing\Helper::removeProtocolFromUrl($server), '/');
$url = 'https://owncloud.org/federation#' . $cloudID;
$ownCloudLogoPath = \OC::$server->getURLGenerator()->imagePath('core', 'logo-icon.svg');
$tmpl = new OCP\Template('files_sharing', 'settings-personal');
$tmpl->assign('outgoingServer2serverShareEnabled', \OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled());
$tmpl->assign('message_with_URL', $l->t('Share with me through my #ownCloud Federated Cloud ID, see %s', [$url]));
$tmpl->assign('message_without_URL', $l->t('Share with me through my #ownCloud Federated Cloud ID', [$cloudID]));
$tmpl->assign('owncloud_logo_path', $ownCloudLogoPath);
$tmpl->assign('reference', $url);
$tmpl->assign('cloudId', $cloudID);
return $tmpl->fetchPage();

View File

@ -1,12 +1,73 @@
<?php
/** @var OC_L10N $l */
/** @var array $_ */
script('files_sharing', 'settings-personal');
style('files_sharing', 'settings-personal');
script('files_sharing', '3rdparty/gs-share/gs-share');
style('files_sharing', '3rdparty/gs-share/style');
?>
<div id="fileSharingSettings" class="section">
<h2><?php p($l->t('Federated Cloud'));?></h2>
<p>
<?php p($l->t('Your Federated Cloud ID: %s', [$_['cloudId']])); ?>
</p>
<?php if ($_['outgoingServer2serverShareEnabled']): ?>
<div id="fileSharingSettings" class="section">
<h2><?php p($l->t('Federated Cloud')); ?></h2>
</div>
<p>
<?php p($l->t('Your Federated Cloud ID:')); ?>
<strong><?php p($_['cloudId']); ?></strong>
</p>
<br>
<p>
<?php p($l->t('Share it:')); ?>
<div class="gs-share">
<button data-url="<?php p(urlencode($_['reference'])); ?>"
data-title='<?php p(urlencode($_['message_without_URL'])); ?>'
class='js-gs-share social-gnu'>
GNU Social
</button>
</div>
<button class="social-diaspora pop-up"
data-url='http://sharetodiaspora.github.io/?title=<?php p($_['message_without_URL']); ?>&url=<?php p(urlencode($_['reference'])); ?>'>
Diaspora
</button>
<button class="social-twitter pop-up"
data-url='https://twitter.com/intent/tweet?text=<?php p(urlencode($_['message_with_URL'])); ?>'>
Twitter
</button>
<button class="social-facebook pop-up"
data-url='https://www.facebook.com/sharer/sharer.php?u=<?php p(urlencode($_['reference'])); ?>'>
Facebook
</button>
<button class="social-googleplus pop-up"
data-url='https://plus.google.com/share?url=<?php p(urlencode($_['reference'])); ?>'/>
Google+
</button>
</p>
<br>
<p>
<?php p($l->t('Add it to your website:')); ?>
<a target="_blank" href="<?php p($_['reference']); ?>"
style="padding:10px;background-color:#1d2d44;color:#fff;border-radius:3px;padding-left:4px;">
<img src="<?php p($_['owncloud_logo_path']); ?>"
style="width:50px;position:relative;top:8px;">
<?php p($l->t('Share with me via ownCloud')); ?>
</a>
</p>
<p>
<?php p($l->t('HTML Code:')); ?>
<xmp><a target="_blank" href="<?php p($_['reference']); ?>"
style="padding:10px;background-color:#1d2d44;color:#fff;border-radius:3px;padding-left:4px;">
<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL($_['owncloud_logo_path'])); ?>"
style="width:50px;position:relative;top:8px;">
<?php p($l->t('Share with me via ownCloud')); ?>
</a></xmp>
</p>
</div>
<?php endif; ?>